Просмотр исходного кода

fix (cover): don't trust position when current_position is None

When current_position dp is defined, but the device is not
broadcasting it, we don't really know where the cover is.

This scenario arises because of multi-device configs, such as the
recent updates to simple_blinds.yaml, though it has been a possibility
for a while.
Jason Rumney 3 дней назад
Родитель
Сommit
d1d6c39335
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      custom_components/tuya_local/cover.py

+ 5 - 1
custom_components/tuya_local/cover.py

@@ -147,7 +147,11 @@ class TuyaLocalCover(TuyaLocalEntity, CoverEntity):
         elif pos > 95:
             return "opened"
 
-        if self._currentpos_dp and self._position_dp:
+        if (
+                self._currentpos_dp
+                and self._currentpos_dp.get_value(self._device) is not None
+                and self._position_dp
+        ):
             setpos = self._position_dp.get_value(self._device)
             if setpos == pos:
                 # if the current position is around the set position,