mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use entry.async_on_unload in fireservicerota (#138360)
This commit is contained in:
parent
a6c51440e5
commit
2033dbdd90
@ -27,6 +27,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
if client.token_refresh_failure:
|
if client.token_refresh_failure:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
entry.async_on_unload(client.async_stop_listener)
|
||||||
coordinator = FireServiceUpdateCoordinator(hass, client, entry)
|
coordinator = FireServiceUpdateCoordinator(hass, client, entry)
|
||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
@ -43,10 +44,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Unload FireServiceRota config entry."""
|
"""Unload FireServiceRota config entry."""
|
||||||
|
|
||||||
await hass.async_add_executor_job(
|
|
||||||
hass.data[DOMAIN][entry.entry_id][DATA_CLIENT].websocket.stop_listener
|
|
||||||
)
|
|
||||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
del hass.data[DOMAIN][entry.entry_id]
|
del hass.data[DOMAIN][entry.entry_id]
|
||||||
|
@ -213,3 +213,7 @@ class FireServiceRotaClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
await self.update_call(self.fsr.set_incident_response, self.incident_id, value)
|
await self.update_call(self.fsr.set_incident_response, self.incident_id, value)
|
||||||
|
|
||||||
|
async def async_stop_listener(self) -> None:
|
||||||
|
"""Stop listener."""
|
||||||
|
await self._hass.async_add_executor_job(self.websocket.stop_listener)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user