Procházet zdrojové kódy

Handle brightness being None.

During initialisation, no data is available from the device yet. If we throw errors, the initialisation will fail.
Jason Rumney před 4 roky
rodič
revize
39ff311e3b
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  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