mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Send commands to Hue grouped lights all at once (#62973)
This commit is contained in:
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,8 +174,9 @@ 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.bridge.async_request_call(
|
||||||
self.api.lights.set_state,
|
self.api.lights.set_state,
|
||||||
light.id,
|
light.id,
|
||||||
on=True,
|
on=True,
|
||||||
@ -185,6 +187,9 @@ class GroupedHueLight(HueBaseEntity, LightEntity):
|
|||||||
alert=AlertEffectType.BREATHE if flash is not None else None,
|
alert=AlertEffectType.BREATHE if flash is not None else None,
|
||||||
allowed_errors=ALLOWED_ERRORS,
|
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.bridge.async_request_call(
|
||||||
self.api.lights.set_state,
|
self.api.lights.set_state,
|
||||||
light.id,
|
light.id,
|
||||||
on=False,
|
on=False,
|
||||||
transition_time=transition,
|
transition_time=transition,
|
||||||
allowed_errors=ALLOWED_ERRORS,
|
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…
x
Reference in New Issue
Block a user