소스 검색

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 년 전
부모
커밋
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