Skip to content

Commit

Permalink
Fix issue with Alexa setting position #74
Browse files Browse the repository at this point in the history
  • Loading branch information
rstrouse committed Jul 11, 2024
1 parent f723034 commit 7c69ead
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions custom_components/espsomfy_rts/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ def __init__(self, controller: ESPSomfyController, data) -> None:
def _handle_state_update(self, data) -> None:
"""Handle the state update."""
upd = False

if "remoteAddress" in data and self._state_attributes.get(
"remote_address", 0
) != int(data["remoteAddress"]):
Expand Down Expand Up @@ -477,12 +478,12 @@ def _handle_state_update(self, data) -> None:
if "tiltPosition" in data and self._tilt_position != data.get(
"tiltPosition", -1
):
self._position = int(data["tiltPosition"])
self._tilt_position = int(data["tiltPosition"])
upd = True
if "tiltDirection" in data and self._tilt_direction != data.get(
"tiltDirection", 0
):
self._direction = int(data["tiltDirection"])
self._tilt_direction = int(data["tiltDirection"])
upd = True
if "tiltTarget" in data and self._state_attributes.get(
"tilt_target", 0
Expand All @@ -495,6 +496,12 @@ def _handle_state_update(self, data) -> None:
self._state_attributes["my_tilt_pos"] = int(data["myTiltPos"])
upd = True
if upd:
if self._has_lift:
self._attr_current_cover_position = self.current_cover_position
if self._has_tilt:
self._attr_current_cover_tilt_position = (
self.current_cover_tilt_position
)
self.async_write_ha_state()

def _handle_state_command(self, data) -> None:
Expand Down

0 comments on commit 7c69ead

Please sign in to comment.