From 8c4894371f245d90242cc329212c98d30ffd41b9 Mon Sep 17 00:00:00 2001 From: sibowler Date: Sun, 4 Sep 2022 14:02:06 +1000 Subject: [PATCH] Fix for cover issues with new state restore functionality --- custom_components/localtuya/cover.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/localtuya/cover.py b/custom_components/localtuya/cover.py index 060dbb6..fa7a4fd 100644 --- a/custom_components/localtuya/cover.py +++ b/custom_components/localtuya/cover.py @@ -190,7 +190,6 @@ class LocaltuyaCover(LocalTuyaEntity, CoverEntity): def status_updated(self): """Device status was updated.""" - super().status_updated() self._previous_state = self._state self._state = self.dps(self._dp_id) @@ -230,5 +229,10 @@ class LocaltuyaCover(LocalTuyaEntity, CoverEntity): # store the time of the last movement change self._timer_start = time.time() + # Keep record in last_state as long as not during connection/re-connection, + # as last state will be used to restore the previous state + if (self._state is not None) and (not self._device.is_connecting): + self._last_state = self._state + async_setup_entry = partial(async_setup_entry, DOMAIN, LocaltuyaCover, flow_schema)