Skip to content

Commit

Permalink
Support is_opening/closing when moving position
Browse files Browse the repository at this point in the history
  • Loading branch information
tetienne committed Jun 13, 2021
1 parent 39f485e commit 13053f3
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions custom_components/tahoma/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
CORE_CLOSURE_OR_ROCKER_POSITION_STATE = "core:ClosureOrRockerPositionState"
CORE_DEPLOYMENT_STATE = "core:DeploymentState"
CORE_MEMORIZED_1_POSITION_STATE = "core:Memorized1PositionState"
CORE_MOVING_STATE = "core:MovingState"
CORE_OPEN_CLOSED_PARTIAL_STATE = "core:OpenClosedPartialState"
CORE_OPEN_CLOSED_STATE = "core:OpenClosedState"
CORE_OPEN_CLOSED_UNKNOWN_STATE = "core:OpenClosedUnknownState"
Expand Down Expand Up @@ -145,7 +146,6 @@ def current_cover_position(self):

position = self.select_state(
CORE_CLOSURE_STATE,
CORE_TARGET_CLOSURE_STATE,
CORE_CLOSURE_OR_ROCKER_POSITION_STATE,
)

Expand Down Expand Up @@ -317,20 +317,50 @@ async def async_my(self, **_):
@property
def is_opening(self):
"""Return if the cover is opening or not."""
return any(
if any(
execution.get("deviceurl") == self.device.deviceurl
and execution.get("command_name") in COMMANDS_OPEN + COMMANDS_OPEN_TILT
for execution in self.coordinator.executions.values()
)
):
return True
is_moving = self.select_state(CORE_MOVING_STATE)
if not is_moving:
return False

if self.is_awning():
# TODO
return False

if self.select_state(CORE_CLOSURE_STATE) > self.select_state(
CORE_TARGET_CLOSURE_STATE
):
return True

return False

@property
def is_closing(self):
"""Return if the cover is closing or not."""
return any(
if any(
execution.get("deviceurl") == self.device.deviceurl
and execution.get("command_name") in COMMANDS_CLOSE + COMMANDS_CLOSE_TILT
for execution in self.coordinator.executions.values()
)
):
return True
is_moving = self.select_state(CORE_MOVING_STATE)
if not is_moving:
return False

if self.is_awning():
# TODO
return False

if self.select_state(CORE_CLOSURE_STATE) < self.select_state(
CORE_TARGET_CLOSURE_STATE
):
return True

return False

@property
def device_state_attributes(self):
Expand Down

0 comments on commit 13053f3

Please sign in to comment.