Skip to content

Commit

Permalink
chore(cover): revert state_action update from property
Browse files Browse the repository at this point in the history
  • Loading branch information
xZetsubou committed Jan 22, 2025
1 parent 1722081 commit 6f61fd0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions custom_components/localtuya/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ def _current_state(self) -> str:
if (state == STATE_CLOSING and curr_pos == 0) or (
state == STATE_OPENING and curr_pos == 100
):
return STATE_STOPPED
self._current_state_action = STATE_STOPPED
if state in (STATE_SET_CLOSING, STATE_SET_OPENING):
set_pos = self._set_new_position
# Reset state whenn cover reached the position.
if curr_pos - set_pos < 5 and curr_pos - set_pos >= -5:
return STATE_STOPPED
self._current_state_action = STATE_STOPPED

return self._current_state_action

Expand Down Expand Up @@ -323,7 +323,9 @@ def status_updated(self):

def update_state(self, action, position=None):
"""Update cover current states."""
state = self._current_state_action
if (state := self._current_state_action) == action:
return

# using Commands.
if position is None:
self._current_state_action = action
Expand All @@ -341,7 +343,7 @@ def update_state(self, action, position=None):
else:
self._current_state_action = STATE_STOPPED
# Write state data.
self.async_write_ha_state()
self.schedule_update_ha_state()


async_setup_entry = partial(async_setup_entry, DOMAIN, LocalTuyaCover, flow_schema)

0 comments on commit 6f61fd0

Please sign in to comment.