Kaynağa Gözat

light: avoid brightness conversion when raw value is unavailable

If the brightness dp is not available, trying to get the light's
brightness will result in an exception. During startup this can cause the
light to fail initialisation, and remain unavailable even if the issue
resolves itself later.

Issue #1738 (related to earlier #1513 fix for fans)
Jason Rumney 2 yıl önce
ebeveyn
işleme
ec163b1bb2
1 değiştirilmiş dosya ile 1 ekleme ve 1 silme
  1. 1 1
      custom_components/tuya_local/light.py

+ 1 - 1
custom_components/tuya_local/light.py

@@ -153,7 +153,7 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
         if self._brightness_dps:
         if self._brightness_dps:
             r = self._brightness_dps.range(self._device)
             r = self._brightness_dps.range(self._device)
             val = self._brightness_dps.get_value(self._device)
             val = self._brightness_dps.get_value(self._device)
-            if r:
+            if r and val is not None:
                 val = color_util.value_to_brightness(r, val)
                 val = color_util.value_to_brightness(r, val)
             return val
             return val