Skip to content

Commit 6f61fd0

Browse files
committedJan 22, 2025
chore(cover): revert state_action update from property
1 parent 1722081 commit 6f61fd0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎custom_components/localtuya/cover.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ def _current_state(self) -> str:
126126
if (state == STATE_CLOSING and curr_pos == 0) or (
127127
state == STATE_OPENING and curr_pos == 100
128128
):
129-
return STATE_STOPPED
129+
self._current_state_action = STATE_STOPPED
130130
if state in (STATE_SET_CLOSING, STATE_SET_OPENING):
131131
set_pos = self._set_new_position
132132
# Reset state whenn cover reached the position.
133133
if curr_pos - set_pos < 5 and curr_pos - set_pos >= -5:
134-
return STATE_STOPPED
134+
self._current_state_action = STATE_STOPPED
135135

136136
return self._current_state_action
137137

@@ -323,7 +323,9 @@ def status_updated(self):
323323

324324
def update_state(self, action, position=None):
325325
"""Update cover current states."""
326-
state = self._current_state_action
326+
if (state := self._current_state_action) == action:
327+
return
328+
327329
# using Commands.
328330
if position is None:
329331
self._current_state_action = action
@@ -341,7 +343,7 @@ def update_state(self, action, position=None):
341343
else:
342344
self._current_state_action = STATE_STOPPED
343345
# Write state data.
344-
self.async_write_ha_state()
346+
self.schedule_update_ha_state()
345347

346348

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

0 commit comments

Comments
 (0)