From 7eebe2407aac85e1e964dae8d7b6043b7d9692aa Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Mon, 31 Jul 2023 16:27:16 -0700 Subject: [PATCH] Remove reset calls where not needed --- custom_components/adaptive_lighting/switch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 4229f0ac..1dfe89bd 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -1556,6 +1556,8 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): if event.context.parent_id and not self.manager.is_proactively_adapting( event.context.id, ): + # We don't reset manual_control because it might be set before + # the 'off' → 'on' event is fired. self.manager.reset(entity_id, reset_manual_control=False) lock = self._locks.setdefault(entity_id, asyncio.Lock()) @@ -2069,7 +2071,6 @@ class AdaptiveLightingManager: call.context.id, ) - self.reset(entity_id, reset_manual_control=False) self.clear_proactively_adapting(entity_id) transition = data[CONF_PARAMS].get(