4
0
Эх сурвалжийг харах

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 жил өмнө
parent
commit
0e0c26f327

+ 5 - 4
custom_components/tuya_local/cover.py

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