Skip to content

Commit

Permalink
fix reloading entities
Browse files Browse the repository at this point in the history
  • Loading branch information
knightzac19 committed Sep 14, 2024
1 parent 1428038 commit c84e400
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions custom_components/dyson_local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,16 @@ def stop_discovery(_):

async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload Dyson local."""
device = hass.data[DOMAIN][DATA_DEVICES][entry.entry_id]
ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in _async_get_platforms(device)
]
)
)
if ok:
device: DysonDevice = hass.data[DOMAIN][DATA_DEVICES][entry.entry_id]

unload_ok = await hass.config_entries.async_unload_platforms(entry, _async_get_platforms(device))

if unload_ok:
hass.data[DOMAIN][DATA_DEVICES].pop(entry.entry_id)
hass.data[DOMAIN][DATA_COORDINATORS].pop(entry.entry_id)
await hass.async_add_executor_job(device.disconnect)
# TODO: stop discovery
return ok
return unload_ok


@callback
Expand Down

0 comments on commit c84e400

Please sign in to comment.