mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-11 14:24:03 +02:00
Adapt lights simultaneously instead of one by one (#529)
* Update switch.py * Update test_switch.py * Revert "Update test_switch.py" This reverts commit87ea5243b9. * remove unnecessary create_task * remove unneeded len() * Revert "remove unnecessary create_task" This reverts commit2c5da6d739. * use `hass.async_create_task` --------- Co-authored-by: Bas Nijholt <basnijholt@gmail.com> Co-authored-by: Bas Nijholt <bas@nijho.lt>
This commit is contained in:
parent
d44cb66148
commit
fec50ad526
1 changed files with 8 additions and 2 deletions
|
|
@ -1399,7 +1399,7 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
|||
adapt_color = self.adapt_color_switch.is_on
|
||||
assert isinstance(adapt_brightness, bool)
|
||||
assert isinstance(adapt_color, bool)
|
||||
|
||||
tasks = []
|
||||
for light in filtered_lights:
|
||||
manually_controlled = (
|
||||
self._take_over_control
|
||||
|
|
@ -1446,7 +1446,13 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
|||
transition,
|
||||
context.id,
|
||||
)
|
||||
await self._adapt_light(light, context, transition, force=force)
|
||||
coro = self._adapt_light(light, context, transition, force=force)
|
||||
task = self.hass.async_create_task(
|
||||
coro,
|
||||
)
|
||||
tasks.append(task)
|
||||
if tasks:
|
||||
await asyncio.gather(*tasks)
|
||||
|
||||
async def _respond_to_off_to_on_event(self, entity_id: str, event: Event) -> None:
|
||||
assert not self.manager.is_proactively_adapting(event.context.id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue