Skip to content

Commit

Permalink
light: avoid brightness conversion when raw value is unavailable
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
make-all committed Mar 13, 2024
1 parent 2a5fc00 commit ec163b1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/tuya_local/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ec163b1

Please sign in to comment.