mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-08-30 06:29:39 +02:00
Destroy integration data only after unload platform is successful
This commit is contained in:
parent
a918a039ab
commit
07a9db9854
1 changed files with 6 additions and 6 deletions
|
@ -102,15 +102,15 @@ async def async_setup_entry(hass, config_entry):
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# async_unload_entry
|
# async_unload_entry
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
async def async_unload_entry(hass, config_entry):
|
async def async_unload_entry(hass, config_entry) -> bool:
|
||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
controller = hass.data[DOMAIN][DATA_CLIENT][config_entry.entry_id]
|
|
||||||
await controller.async_reset()
|
|
||||||
hass.services.async_remove(DOMAIN, RUN_SCRIPT_COMMAND)
|
|
||||||
hass.data[DOMAIN][DATA_CLIENT].pop(config_entry.entry_id)
|
|
||||||
|
|
||||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
config_entry, PLATFORMS
|
config_entry, PLATFORMS
|
||||||
)
|
)
|
||||||
|
if unload_ok:
|
||||||
|
controller = hass.data[DOMAIN][DATA_CLIENT][config_entry.entry_id]
|
||||||
|
await controller.async_reset()
|
||||||
|
hass.services.async_remove(DOMAIN, RUN_SCRIPT_COMMAND)
|
||||||
|
hass.data[DOMAIN][DATA_CLIENT].pop(config_entry.entry_id)
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue