Skip to content

Commit

Permalink
Do not restore light group external state attributes (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly authored Jul 8, 2024
1 parent 130d75c commit a62f188
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,21 @@ async def test_zha_group_light_entity(
# test that the lights were created and are off
assert bool(entity.state["on"]) is False

# Group entities do not support state restoration
entity.restore_external_state_attributes(
state=True,
off_with_transition=False,
off_brightness=12,
brightness=34,
color_temp=500,
xy_color=(1, 2),
hs_color=(3, 4),
color_mode=ColorMode.XY,
effect="colorloop",
)

assert bool(entity.state["on"]) is False

# test turning the lights on and off from the client
await async_test_on_off_from_client(zha_gateway, group_cluster_on_off, entity)
await _async_shift_time(zha_gateway)
Expand Down
16 changes: 16 additions & 0 deletions zha/application/platforms/light/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,3 +1394,19 @@ def _make_members_assume_group_state(

for platform_entity in self.group.get_platform_entities(Light.PLATFORM):
platform_entity._assume_group_state(update_params)

def restore_external_state_attributes(
self,
*,
state: bool | None,
off_with_transition: bool | None,
off_brightness: int | None,
brightness: int | None,
color_temp: int | None,
xy_color: tuple[float, float] | None,
hs_color: tuple[float, float] | None,
color_mode: ColorMode | None,
effect: str | None,
) -> None:
"""Restore extra state attributes."""
# Groups do not restore external state attributes

0 comments on commit a62f188

Please sign in to comment.