Send commands to Hue grouped lights all at once (#62973)
parent
67663dd31a
commit
bc7e51b992
|
@ -1,6 +1,7 @@
|
||||||
"""Support for Hue groups (room/zone)."""
|
"""Support for Hue groups (room/zone)."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohue.v2 import HueBridgeV2
|
from aiohue.v2 import HueBridgeV2
|
||||||
|
@ -173,18 +174,22 @@ class GroupedHueLight(HueBaseEntity, LightEntity):
|
||||||
|
|
||||||
# redirect all other feature commands to underlying lights
|
# redirect all other feature commands to underlying lights
|
||||||
# note that this silently ignores params sent to light that are not supported
|
# note that this silently ignores params sent to light that are not supported
|
||||||
for light in self.controller.get_lights(self.resource.id):
|
await asyncio.gather(
|
||||||
await self.bridge.async_request_call(
|
*[
|
||||||
self.api.lights.set_state,
|
self.bridge.async_request_call(
|
||||||
light.id,
|
self.api.lights.set_state,
|
||||||
on=True,
|
light.id,
|
||||||
brightness=brightness if light.supports_dimming else None,
|
on=True,
|
||||||
color_xy=xy_color if light.supports_color else None,
|
brightness=brightness if light.supports_dimming else None,
|
||||||
color_temp=color_temp if light.supports_color_temperature else None,
|
color_xy=xy_color if light.supports_color else None,
|
||||||
transition_time=transition,
|
color_temp=color_temp if light.supports_color_temperature else None,
|
||||||
alert=AlertEffectType.BREATHE if flash is not None else None,
|
transition_time=transition,
|
||||||
allowed_errors=ALLOWED_ERRORS,
|
alert=AlertEffectType.BREATHE if flash is not None else None,
|
||||||
)
|
allowed_errors=ALLOWED_ERRORS,
|
||||||
|
)
|
||||||
|
for light in self.controller.get_lights(self.resource.id)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the light off."""
|
"""Turn the light off."""
|
||||||
|
@ -202,14 +207,18 @@ class GroupedHueLight(HueBaseEntity, LightEntity):
|
||||||
return
|
return
|
||||||
|
|
||||||
# redirect all other feature commands to underlying lights
|
# redirect all other feature commands to underlying lights
|
||||||
for light in self.controller.get_lights(self.resource.id):
|
await asyncio.gather(
|
||||||
await self.bridge.async_request_call(
|
*[
|
||||||
self.api.lights.set_state,
|
self.bridge.async_request_call(
|
||||||
light.id,
|
self.api.lights.set_state,
|
||||||
on=False,
|
light.id,
|
||||||
transition_time=transition,
|
on=False,
|
||||||
allowed_errors=ALLOWED_ERRORS,
|
transition_time=transition,
|
||||||
)
|
allowed_errors=ALLOWED_ERRORS,
|
||||||
|
)
|
||||||
|
for light in self.controller.get_lights(self.resource.id)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def on_update(self) -> None:
|
def on_update(self) -> None:
|
||||||
|
|
Loading…
Reference in New Issue