mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Fix lights reporting unsupported colormodes in deCONZ (#108812)
This commit is contained in:
parent
0628546a0e
commit
195ef6d769
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user