Fix lingering timer in flux (#92573)

pull/92973/head
epenet 2023-05-11 07:54:51 +01:00 committed by GitHub
parent fbd06e0745
commit 2c79adad5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -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: