From ec163b1bb2e34b62db1a85d3013e04fe5a86b541 Mon Sep 17 00:00:00 2001 From: Jason Rumney Date: Wed, 13 Mar 2024 22:15:01 +0900 Subject: [PATCH] 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) --- custom_components/tuya_local/light.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/tuya_local/light.py b/custom_components/tuya_local/light.py index b9392791f2..a18e159ed6 100644 --- a/custom_components/tuya_local/light.py +++ b/custom_components/tuya_local/light.py @@ -153,7 +153,7 @@ def _white_brightness(self): if self._brightness_dps: r = self._brightness_dps.range(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) return val