From 76a0f898d935d48bcc9627c9d2b8b26703900ef8 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 9 Aug 2023 17:41:33 -0700 Subject: [PATCH] Fix autoreset_control_seconds_test on dev HA core --- custom_components/adaptive_lighting/switch.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 150f2ef4..697c5857 100644 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -2030,14 +2030,33 @@ class AdaptiveLightingManager: reset_coroutine: Callable[[], Coroutine[Any, Any, None]], ) -> None: timer = timers_dict.get(light) + _LOGGER.debug( + "Timer for light %s: %s", + light, + timer, + ) if timer is not None: if delay is None: # Timer object exists, but should not anymore + _LOGGER.debug( + "Cancelling timer for light %s", + light, + ) timer.cancel() timers_dict.pop(light) else: # Timer object already exists, just update the delay and restart it + _LOGGER.debug( + "Timer for light %s already exists, updating delay to %s", + light, + delay, + ) timer.delay = delay timer.start() elif delay is not None: # Timer object does not exist, create it + _LOGGER.debug( + "Creating timer for light %s with delay %s", + light, + delay, + ) timer = _AsyncSingleShotTimer(delay, reset_coroutine) timers_dict[light] = timer timer.start()