mirror of
https://github.com/home-assistant/core.git
synced 2026-09-29 07:38:13 +01:00
Cancel nordpool listener update timer on unload (#183304)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -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."""
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user