@@ -126,12 +126,12 @@ def _current_state(self) -> str:
126
126
if (state == STATE_CLOSING and curr_pos == 0 ) or (
127
127
state == STATE_OPENING and curr_pos == 100
128
128
):
129
- return STATE_STOPPED
129
+ self . _current_state_action = STATE_STOPPED
130
130
if state in (STATE_SET_CLOSING , STATE_SET_OPENING ):
131
131
set_pos = self ._set_new_position
132
132
# Reset state whenn cover reached the position.
133
133
if curr_pos - set_pos < 5 and curr_pos - set_pos >= - 5 :
134
- return STATE_STOPPED
134
+ self . _current_state_action = STATE_STOPPED
135
135
136
136
return self ._current_state_action
137
137
@@ -323,7 +323,9 @@ def status_updated(self):
323
323
324
324
def update_state (self , action , position = None ):
325
325
"""Update cover current states."""
326
- state = self ._current_state_action
326
+ if (state := self ._current_state_action ) == action :
327
+ return
328
+
327
329
# using Commands.
328
330
if position is None :
329
331
self ._current_state_action = action
@@ -341,7 +343,7 @@ def update_state(self, action, position=None):
341
343
else :
342
344
self ._current_state_action = STATE_STOPPED
343
345
# Write state data.
344
- self .async_write_ha_state ()
346
+ self .schedule_update_ha_state ()
345
347
346
348
347
349
async_setup_entry = partial (async_setup_entry , DOMAIN , LocalTuyaCover , flow_schema )
0 commit comments