From 98ea78d3e2cf0e00e340cc8e7bbeafd050496dbd Mon Sep 17 00:00:00 2001 From: Marcus Ahlberg Date: Fri, 9 Oct 2026 17:08:31 +0200 Subject: [PATCH] Seed deCONZ group color modes from unreachable lights too (#185117) --- homeassistant/components/deconz/light.py | 3 +- tests/components/deconz/test_light.py | 54 ++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/deconz/light.py b/homeassistant/components/deconz/light.py index 6092f7ec95ae..e9c3ac3a6e53 100644 --- a/homeassistant/components/deconz/light.py +++ b/homeassistant/components/deconz/light.py @@ -173,8 +173,9 @@ async def async_setup_entry( lights = [ light for light_id in group.lights - if (light := hub.api.lights.lights.get(light_id)) and light.reachable + if (light := hub.api.lights.lights.get(light_id)) ] + lights.sort(key=lambda light: light.reachable) update_color_state(group, lights, True) async_add_entities([DeconzGroup(group, hub)]) diff --git a/tests/components/deconz/test_light.py b/tests/components/deconz/test_light.py index e7935ebff930..9bac39770349 100644 --- a/tests/components/deconz/test_light.py +++ b/tests/components/deconz/test_light.py @@ -1302,3 +1302,57 @@ async def test_verify_group_color_mode_fallback( group_state = hass.states.get("light.opbergruimte") assert group_state.state == STATE_ON assert group_state.attributes[ATTR_COLOR_MODE] is ColorMode.BRIGHTNESS + + +@pytest.mark.parametrize( + "group_payload", + [ + { + "1": { + "id": "Group1", + "name": "Group", + "type": "LightGroup", + "state": {"all_on": False, "any_on": True}, + "action": {}, + "scenes": [], + "lights": ["1", "2"], + }, + } + ], +) +@pytest.mark.parametrize( + "light_payload", + [ + { + "1": { + "ctmax": 454, + "ctmin": 155, + "name": "Tunable light", + "state": { + "on": True, + "bri": 100, + "colormode": "ct", + "ct": 2500, + "reachable": False, + }, + "type": "Color temperature light", + "uniqueid": "00:00:00:00:00:00:00:01-00", + }, + "2": { + "name": "Dimmable light", + "state": {"on": True, "bri": 255, "reachable": True}, + "type": "Dimmable light", + "uniqueid": "00:00:00:00:00:00:00:02-00", + }, + } + ], +) +@pytest.mark.usefixtures("config_entry_setup") +async def test_group_color_modes_include_unreachable_lights( + hass: HomeAssistant, +) -> None: + """Test that a light unreachable during setup still contributes its color modes.""" + group_state = hass.states.get("light.group") + assert group_state.attributes[ATTR_SUPPORTED_COLOR_MODES] == [ColorMode.COLOR_TEMP] + assert group_state.attributes[ATTR_COLOR_MODE] == ColorMode.COLOR_TEMP + assert group_state.attributes[ATTR_BRIGHTNESS] == 255