Skip to content

Commit

Permalink
Improve unload robustness2 (#1241)
Browse files Browse the repository at this point in the history
* improve unload robustness

* improve unload robustness
  • Loading branch information
lbbrhzn authored Jul 8, 2024
1 parent 4dc818d commit f99a39a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions custom_components/ocpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,15 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Handle removal of an entry."""
unloaded = False
if DOMAIN in hass.data:
central_sys = hass.data[DOMAIN][entry.entry_id]
central_sys._server.close()
await central_sys._server.wait_closed()
unloaded = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unloaded:
hass.data[DOMAIN].pop(entry.entry_id)
if entry.entry_id in hass.data[DOMAIN]:
central_sys = hass.data[DOMAIN][entry.entry_id]
central_sys._server.close()
await central_sys._server.wait_closed()
unloaded = await hass.config_entries.async_unload_platforms(
entry, PLATFORMS
)
if unloaded:
hass.data[DOMAIN].pop(entry.entry_id)

return unloaded

Expand Down

0 comments on commit f99a39a

Please sign in to comment.