diff --git a/homeassistant/components/deconz/light.py b/homeassistant/components/deconz/light.py index 044c9bf203b..27038a07ac3 100644 --- a/homeassistant/components/deconz/light.py +++ b/homeassistant/components/deconz/light.py @@ -212,6 +212,10 @@ class DeconzBaseLight(DeconzDevice[_LightDeviceT], LightEntity): color_mode = ColorMode.BRIGHTNESS else: color_mode = ColorMode.ONOFF + if color_mode not in self._attr_supported_color_modes: + # Some lights controlled by ZigBee scenes can get unsupported color mode + return self._attr_color_mode + self._attr_color_mode = color_mode return color_mode @property diff --git a/tests/components/deconz/test_light.py b/tests/components/deconz/test_light.py index d38c65526c2..d1d5b983956 100644 --- a/tests/components/deconz/test_light.py +++ b/tests/components/deconz/test_light.py @@ -1179,9 +1179,19 @@ async def test_non_color_light_reports_color( await setup_deconz_integration(hass, aioclient_mock) assert len(hass.states.async_all()) == 3 + assert hass.states.get("light.group").attributes[ATTR_SUPPORTED_COLOR_MODES] == [ + ColorMode.COLOR_TEMP, + ColorMode.HS, + ColorMode.XY, + ] + assert ( + hass.states.get("light.group").attributes[ATTR_COLOR_MODE] + == ColorMode.COLOR_TEMP + ) assert hass.states.get("light.group").attributes[ATTR_COLOR_TEMP] == 250 - # Updating a scene will return a faulty color value for a non-color light causing an exception in hs_color + # Updating a scene will return a faulty color value + # for a non-color light causing an exception in hs_color event_changed_light = { "e": "changed", "id": "1", @@ -1200,7 +1210,9 @@ async def test_non_color_light_reports_color( await mock_deconz_websocket(data=event_changed_light) await hass.async_block_till_done() - # Bug is fixed if we reach this point, but device won't have neither color temp nor color + assert hass.states.get("light.group").attributes[ATTR_COLOR_MODE] == ColorMode.XY + # Bug is fixed if we reach this point + # device won't have neither color temp nor color with pytest.raises(AssertionError): assert hass.states.get("light.group").attributes.get(ATTR_COLOR_TEMP) is None assert hass.states.get("light.group").attributes.get(ATTR_HS_COLOR) is None