Adjust config entry state checks in qbus (#138911)
parent
a2ceeb19dc
commit
0949f7d0ba
|
@ -71,17 +71,14 @@ async def async_unload_entry(hass: HomeAssistant, entry: QbusConfigEntry) -> boo
|
|||
|
||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||
entry.runtime_data.shutdown()
|
||||
cleanup(hass, entry)
|
||||
_cleanup(hass, entry)
|
||||
|
||||
return unload_ok
|
||||
|
||||
|
||||
def cleanup(hass: HomeAssistant, entry: QbusConfigEntry) -> None:
|
||||
def _cleanup(hass: HomeAssistant, entry: QbusConfigEntry) -> None:
|
||||
"""Shutdown if no more entries are loaded."""
|
||||
entries = hass.config_entries.async_loaded_entries(DOMAIN)
|
||||
count = len(entries)
|
||||
|
||||
# During unloading of the entry, it is not marked as unloaded yet. So
|
||||
# count can be 1 if it is the last one.
|
||||
if count <= 1 and (config_coordinator := hass.data.get(QBUS_KEY)):
|
||||
if not hass.config_entries.async_loaded_entries(DOMAIN) and (
|
||||
config_coordinator := hass.data.get(QBUS_KEY)
|
||||
):
|
||||
config_coordinator.shutdown()
|
||||
|
|
Loading…
Reference in New Issue