Skip to content

Commit

Permalink
Use entry.async_on_unload in fireservicerota (#138360)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Feb 12, 2025
1 parent a6c5144 commit 2033dbd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 1 addition & 4 deletions homeassistant/components/fireservicerota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if client.token_refresh_failure:
return False

entry.async_on_unload(client.async_stop_listener)
coordinator = FireServiceUpdateCoordinator(hass, client, entry)

await coordinator.async_config_entry_first_refresh()
Expand All @@ -43,10 +44,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""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)
if unload_ok:
del hass.data[DOMAIN][entry.entry_id]
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/fireservicerota/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,7 @@ async def async_set_response(self, value) -> None:
)

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)

0 comments on commit 2033dbd

Please sign in to comment.