Fix lingering timer in jewish_calendar (#92470)

This commit is contained in:
epenet 2023-05-04 11:38:24 +02:00 committed by GitHub
parent a4a795e35b
commit 7dc5d131b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -116,6 +116,13 @@ class JewishCalendarBinarySensor(BinarySensorEntity):
await super().async_added_to_hass()
self._schedule_update()
async def async_will_remove_from_hass(self) -> None:
"""Run when entity will be removed from hass."""
if self._update_unsub:
self._update_unsub()
self._update_unsub = None
return await super().async_will_remove_from_hass()
@callback
def _update(self, now: datetime | None = None) -> None:
"""Update the state of the sensor."""