Guard against 0 value for color temp in WiZ when turning off (#66295)

This commit is contained in:
J. Nick Koston 2022-02-10 18:12:36 -06:00 committed by GitHub
parent c1760683a0
commit cb2e486f6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,9 +108,8 @@ class WizBulbEntity(WizToggleEntity, LightEntity):
assert color_modes is not None
if (brightness := state.get_brightness()) is not None:
self._attr_brightness = max(0, min(255, brightness))
if (
COLOR_MODE_COLOR_TEMP in color_modes
and (color_temp := state.get_colortemp()) is not None
if COLOR_MODE_COLOR_TEMP in color_modes and (
color_temp := state.get_colortemp()
):
self._attr_color_mode = COLOR_MODE_COLOR_TEMP
self._attr_color_temp = color_temperature_kelvin_to_mired(color_temp)