From 9d085778c270749a4079c415873dfe4b271b2ac7 Mon Sep 17 00:00:00 2001 From: youknowjack0 Date: Thu, 1 Apr 2021 09:32:59 -0700 Subject: [PATCH] Fix timer.finish to cancel callback (#48549) Timer.finish doesn't cancel the callback, which can lead to incorrect early cancellation of the timer if it is subsequently restarted. Bug reported here: https://community.home-assistant.io/t/timer-component-timer-stops-before-time-is-up/96038 --- homeassistant/components/timer/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/timer/__init__.py b/homeassistant/components/timer/__init__.py index 216ab3217a5..2ff408dcd81 100644 --- a/homeassistant/components/timer/__init__.py +++ b/homeassistant/components/timer/__init__.py @@ -327,7 +327,9 @@ class Timer(RestoreEntity): if self._state != STATUS_ACTIVE: return - self._listener = None + if self._listener: + self._listener() + self._listener = None self._state = STATUS_IDLE self._end = None self._remaining = None