From 2c79adad5e67b16574885e4ae05b407da8553abd Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 11 May 2023 07:54:51 +0100 Subject: [PATCH] Fix lingering timer in flux (#92573) --- homeassistant/components/flux/switch.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/components/flux/switch.py b/homeassistant/components/flux/switch.py index d8a58192593..f71ccc87f05 100644 --- a/homeassistant/components/flux/switch.py +++ b/homeassistant/components/flux/switch.py @@ -226,6 +226,12 @@ class FluxSwitch(SwitchEntity, RestoreEntity): if last_state and last_state.state == STATE_ON: await self.async_turn_on() + async def async_will_remove_from_hass(self) -> None: + """Run when entity will be removed from hass.""" + if self.unsub_tracker: + self.unsub_tracker() + return await super().async_will_remove_from_hass() + async def async_turn_on(self, **kwargs: Any) -> None: """Turn on flux.""" if self.is_on: