diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index d1331d59..e4685d63 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -1129,11 +1129,8 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): ) self.async_write_ha_state() - # Return here if there's no lights to adapt. if lights is None: lights = self._lights - if not len(lights): - return if not force: if self._only_once: @@ -1142,6 +1139,9 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): # 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): + return + await self._update_manual_control_and_maybe_adapt( lights, transition, force, context )