Allow multiple config entries in Honeywell (#108263)

* Address popping all entires when unloading

* optimize hass data
This commit is contained in:
mkmer 2024-01-17 21:35:53 -05:00 committed by GitHub
parent 154fe8631a
commit 484584084a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -85,8 +85,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
return False
data = HoneywellData(config_entry.entry_id, client, devices)
hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][config_entry.entry_id] = data
hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = data
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
config_entry.async_on_unload(config_entry.add_update_listener(update_listener))
@ -105,7 +104,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
config_entry, PLATFORMS
)
if unload_ok:
hass.data.pop(DOMAIN)
hass.data[DOMAIN].pop(config_entry.entry_id)
return unload_ok