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

Handle brightness being None.

During initialisation, no data is available from the device yet. If we throw errors, the initialisation will fail.
Jason Rumney 4 лет назад
Родитель
Сommit
39ff311e3b
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      custom_components/tuya_local/generic/light.py

+ 2 - 1
custom_components/tuya_local/generic/light.py

@@ -86,7 +86,8 @@ class TuyaLocalLight(LightEntity):
         if self._switch_dps:
             return self._switch_dps.get_value(self._device)
         elif self._brightness_dps:
-            return self._brightness_dps.get_value(self._device) > 0
+            b = self.brightness
+            return isinstance(b, int) and b > 0
         else:
             # There shouldn't be lights without control, but if there are, assume always on
             return True