From 6b2fbf7c9bbce70a5d47a2c37baa21c228ac15a6 Mon Sep 17 00:00:00 2001 From: Benjamin Auquite Date: Mon, 3 Apr 2023 01:35:53 -0500 Subject: [PATCH] Update switch.py --- custom_components/adaptive_lighting/switch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 )