Seed deCONZ group color modes from unreachable lights too (#185117)

This commit is contained in:
Marcus Ahlberg
2026-10-09 19:10:18 +00:00
committed by Franck Nijhof
parent 1aba15b81f
commit 98ea78d3e2
2 changed files with 56 additions and 1 deletions
+2 -1
View File
@@ -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)])
+54
View File
@@ -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