Fix HOMEASSISTANT_STOP unsubscribe in data update coordinator (#145809)

* initial commit

* a better approach

* Add comment
This commit is contained in:
David Bonnes 2025-05-28 17:52:51 +01:00 committed by Bram Kragten
parent 83af5ec36b
commit 612861061c

View File

@ -138,6 +138,8 @@ class DataUpdateCoordinator(BaseDataUpdateCoordinatorProtocol, Generic[_DataT]):
async def _on_hass_stop(_: Event) -> None:
"""Shutdown coordinator on HomeAssistant stop."""
# Already cleared on EVENT_HOMEASSISTANT_STOP, via async_fire_internal
self._unsub_shutdown = None
await self.async_shutdown()
self._unsub_shutdown = self.hass.bus.async_listen_once(