Browse Source

cover: handle control_dp being cleared to None.

Some devices clear the command once the curtain is moving.  Some also have
a "continue" command, which is not recognised by HA. So change the conditions
for opening and closing to only exclude the opposite command and "stop".

Related to PR #655
Jason Rumney 2 years ago
parent
commit
0e0c26f327
1 changed files with 5 additions and 4 deletions
  1. 5 4
      custom_components/tuya_local/cover.py

+ 5 - 4
custom_components/tuya_local/cover.py

@@ -122,10 +122,12 @@ class TuyaLocalCover(TuyaLocalEntity, CoverEntity):
                 return action == "opening"
         # Otherwise use last command and check it hasn't completed
         if self._control_dp:
+            cmd = self._control_dp.get_value(self._device)
             pos = self.current_cover_position
             if pos is not None:
                 return (
-                    self._control_dp.get_value(self._device) == "open"
+                    cmd != "close"
+                    and cmd != "stop"
                     and self.current_cover_position < 95
                 )
 
@@ -140,10 +142,9 @@ class TuyaLocalCover(TuyaLocalEntity, CoverEntity):
         # Otherwise use last command and check it hasn't completed
         if self._control_dp:
             closed = self.is_closed
+            cmd = self._control_dp.get_value(self._device)
             if closed is not None:
-                return (
-                    self._control_dp.get_value(self._device) == "close" and not closed
-                )
+                return cmd != "open" and cmd != "stop" and not closed
 
     @property
     def is_closed(self):