Cancel nordpool listener update timer on unload (#183304)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Franck Nijhof
2026-09-27 14:13:17 +02:00
committed by GitHub
co-authored by Claude
parent 168a6201a6
commit dafd99ca58
2 changed files with 11 additions and 0 deletions
@@ -74,6 +74,14 @@ class NordPoolDataUpdateCoordinator(DataUpdateCoordinator[DeliveryPeriodsData]):
)
self.async_update_listeners()
@override
async def async_shutdown(self) -> None:
"""Cancel the listener update timer and shut down the coordinator."""
if self.listener_unsub:
self.listener_unsub()
self.listener_unsub = None
await super().async_shutdown()
@override
async def _async_setup(self) -> None:
"""Set up the coordinator."""
+3
View File
@@ -40,9 +40,12 @@ async def test_unload_entry(hass: HomeAssistant, get_client: NordPoolClient) ->
await hass.async_block_till_done(wait_background_tasks=True)
assert entry.state is ConfigEntryState.LOADED
coordinator = entry.runtime_data
assert coordinator.listener_unsub is not None
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
assert entry.state is ConfigEntryState.NOT_LOADED
assert coordinator.listener_unsub is None
@pytest.mark.parametrize(