Skip to content

Commit

Permalink
Fix reloading the integration from hanging (#192)
Browse files Browse the repository at this point in the history
* fix reloading entities

* bump

* Fix conflict from main merge

---------

Co-authored-by: Ben Vezzani <[email protected]>
  • Loading branch information
knightzac19 and dotvezz authored Sep 16, 2024
1 parent 1f39d14 commit cefd4f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 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
2 changes: 1 addition & 1 deletion custom_components/dyson_local/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"import_executor": true,
"iot_class": "local_push",
"issue_tracker": "https://github.com/libdyson-wg/ha-dyson/issues",
"version": "1.4.1"
"version": "1.4.2"
}

0 comments on commit cefd4f5

Please sign in to comment.