Fix deCONZ group state regression (#73907)

This commit is contained in:
Robert Svensson 2022-06-23 20:26:51 +02:00 committed by GitHub
parent edb386c736
commit b3b4707579
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 5 deletions

View File

@ -287,7 +287,6 @@ async def get_deconz_session(
config[CONF_HOST],
config[CONF_PORT],
config[CONF_API_KEY],
legacy_add_device=False,
)
try:
async with async_timeout.timeout(10):

View File

@ -105,7 +105,10 @@ async def async_setup_entry(
@callback
def async_add_group(_: EventType, group_id: str) -> None:
"""Add group from deCONZ."""
"""Add group from deCONZ.
Update group states based on its sum of related lights.
"""
if (
not gateway.option_allow_deconz_groups
or (group := gateway.api.groups[group_id])
@ -113,6 +116,16 @@ async def async_setup_entry(
):
return
first = True
for light_id in group.lights:
if (
(light := gateway.api.lights.lights.get(light_id))
and light.ZHATYPE == Light.ZHATYPE
and light.reachable
):
group.update_color_state(light, update_all_attributes=first)
first = False
async_add_entities([DeconzGroup(group, gateway)])
config_entry.async_on_unload(
@ -289,6 +302,16 @@ class DeconzLight(DeconzBaseLight[Light]):
"""Return the coldest color_temp that this light supports."""
return self._device.min_color_temp or super().min_mireds
@callback
def async_update_callback(self) -> None:
"""Light state will also reflect in relevant groups."""
super().async_update_callback()
if self._device.reachable and "attr" not in self._device.changed_keys:
for group in self.gateway.api.groups.values():
if self._device.resource_id in group.lights:
group.update_color_state(self._device)
class DeconzGroup(DeconzBaseLight[Group]):
"""Representation of a deCONZ group."""

View File

@ -3,7 +3,7 @@
"name": "deCONZ",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/deconz",
"requirements": ["pydeconz==94"],
"requirements": ["pydeconz==95"],
"ssdp": [
{
"manufacturer": "Royal Philips Electronics",

View File

@ -1441,7 +1441,7 @@ pydaikin==2.7.0
pydanfossair==0.1.0
# homeassistant.components.deconz
pydeconz==94
pydeconz==95
# homeassistant.components.delijn
pydelijn==1.0.0

View File

@ -968,7 +968,7 @@ pycoolmasternet-async==0.1.2
pydaikin==2.7.0
# homeassistant.components.deconz
pydeconz==94
pydeconz==95
# homeassistant.components.dexcom
pydexcom==0.2.3