Skip to content

Commit

Permalink
Merge remote-tracking branch 'pawlizio/master' into dumpfheimer/poll-…
Browse files Browse the repository at this point in the history
…states
  • Loading branch information
Christopher Hoch committed Aug 28, 2023
2 parents 513b774 + 2fcac01 commit 1123448
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
4 changes: 4 additions & 0 deletions pyvlx/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ class OperatingState(Enum):
def _missing_(cls, value):
return cls.UNKNOWN

@classmethod
def _missing_(cls, value):
return cls.UNDEFINED


class StatusReply(Enum):
"""Enum Class for Node Status Reply."""
Expand Down
24 changes: 20 additions & 4 deletions pyvlx/opening_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def __init__(
self.target_position = TargetPosition()
self.active_parameter=0

async def set_position(self, position: Position, wait_for_completion=True, curtain="dual"):
async def set_position(self, position: Position, velocity: Velocity | int | None = Velocity.DEFAULT, wait_for_completion=True, curtain="dual"):
"""Set window to desired position.
Parameters:
Expand All @@ -455,6 +455,19 @@ async def set_position(self, position: Position, wait_for_completion=True, curta
self.target_position = position
self.active_parameter=0


if (velocity is None or velocity is Velocity.DEFAULT) and self.use_default_velocity:
velocity = self.default_velocity

if isinstance(velocity, Velocity):
if velocity is not Velocity.DEFAULT:
if velocity is Velocity.SILENT:
kwargs['fp3'] = Parameter(raw=b"\x00\x00")
else:
kwargs['fp3'] = Parameter(raw=b"\xC8\x00")
elif isinstance(velocity, int):
kwargs['fp3'] = Position.from_percent(velocity)

command_send = CommandSend(
pyvlx=self.pyvlx,
wait_for_completion=wait_for_completion,
Expand All @@ -475,7 +488,7 @@ async def set_position(self, position: Position, wait_for_completion=True, curta
self.position = position
await self.after_update()

async def open(self, wait_for_completion=True, curtain="dual"):
async def open(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_for_completion=True, curtain="dual"):
"""Open window.
Parameters:
Expand All @@ -485,11 +498,12 @@ async def open(self, wait_for_completion=True, curtain="dual"):
"""
await self.set_position(
position=Position(position_percent=0),
velocity=velocity,
wait_for_completion=wait_for_completion,
curtain=curtain
)

async def close(self, wait_for_completion=True, curtain="dual"):
async def close(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_for_completion=True, curtain="dual"):
"""Close window.
Parameters:
Expand All @@ -498,14 +512,16 @@ async def close(self, wait_for_completion=True, curtain="dual"):
"""
await self.set_position(
position=Position(position_percent=100),
velocity=velocity,
wait_for_completion=wait_for_completion,
curtain=curtain
)

async def stop(self, wait_for_completion=True, curtain="dual"):
async def stop(self, velocity: Velocity | int | None = Velocity.DEFAULT, wait_for_completion=True, curtain="dual"):
"""Stop Blind position."""
await self.set_position(
position=CurrentPosition(),
velocity=velocity,
wait_for_completion=wait_for_completion,
curtain=curtain
)
Expand Down
2 changes: 1 addition & 1 deletion pyvlx/pyvlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, path=None, host=None, password=None, loop=None, heartbeat_int
self.version = None
self.protocol_version = None
self.klf200 = Klf200Gateway(pyvlx=self)
PYVLXLOG.debug("Loading https://github.com/pawlizio/pyvlx.git@Dual_roller_shutter v0.1.56")
PYVLXLOG.debug("Loading https://github.com/pawlizio/pyvlx.git@Dual_roller_shutter v0.1.58")

async def connect(self):
"""Connect to KLF 200."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

PKG_ROOT = os.path.dirname(__file__)

VERSION = "0.1.56"
VERSION = "0.1.58"


def get_long_description():
Expand Down

0 comments on commit 1123448

Please sign in to comment.