mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-12 14:54:04 +02:00
slight refactor
This commit is contained in:
parent
46d5563697
commit
21f8beac8d
1 changed files with 5 additions and 15 deletions
|
|
@ -1128,28 +1128,18 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
|
|||
|
||||
if lights is None:
|
||||
lights = self._lights
|
||||
if not force and self._only_once:
|
||||
return
|
||||
|
||||
filtered_lights = []
|
||||
for light in lights:
|
||||
# Don't adapt lights that haven't finished prior transitions.
|
||||
if force or not self.turn_on_off_listener.transition_timers.get(light):
|
||||
filtered_lights.append(light)
|
||||
|
||||
if not filtered_lights:
|
||||
return
|
||||
|
||||
await self._adapt_lights(filtered_lights, transition, force, context)
|
||||
|
||||
if not force:
|
||||
if self._only_once:
|
||||
return
|
||||
for light in lights:
|
||||
# Don't adapt lights that haven't finished prior transitions.
|
||||
if self.turn_on_off_listener.transition_timers.get(light):
|
||||
lights.remove(light)
|
||||
if not len(lights):
|
||||
if not self.turn_on_off_listener.transition_timers.get(light):
|
||||
filtered_lights.append(light)
|
||||
else:
|
||||
filtered_lights = lights
|
||||
if not filtered_lights:
|
||||
return
|
||||
|
||||
await self._update_manual_control_and_maybe_adapt(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue