Fix lingering timer in generic_hygrostat (#92575)

pull/92713/head
epenet 2023-05-07 01:28:10 +02:00 committed by GitHub
parent 7e19bb4ee0
commit 7cb25e9710
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -172,7 +172,11 @@ class GenericHygrostat(HumidifierEntity, RestoreEntity):
)
if self._keep_alive:
async_track_time_interval(self.hass, self._async_operate, self._keep_alive)
self.async_on_remove(
async_track_time_interval(
self.hass, self._async_operate, self._keep_alive
)
)
async def _async_startup(event):
"""Init on startup."""
@ -216,6 +220,12 @@ class GenericHygrostat(HumidifierEntity, RestoreEntity):
await _async_startup(None) # init the sensor
async def async_will_remove_from_hass(self) -> None:
"""Run when entity will be removed from hass."""
if self._remove_stale_tracking:
self._remove_stale_tracking()
return await super().async_will_remove_from_hass()
@property
def available(self):
"""Return True if entity is available."""