Reduce config entry setup/unload boilerplate T-U (#49786)

This commit is contained in:
J. Nick Koston
2021-04-27 10:19:57 -10:00
committed by GitHub
parent 87420627a8
commit 4b74c57285
19 changed files with 64 additions and 198 deletions

View File

@@ -223,22 +223,20 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
upcloud_data.coordinators[config_entry.data[CONF_USERNAME]] = coordinator
# Forward entry setup
for domain in CONFIG_ENTRY_DOMAINS:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, domain)
)
hass.config_entries.async_setup_platforms(config_entry, CONFIG_ENTRY_DOMAINS)
return True
async def async_unload_entry(hass, config_entry):
"""Unload the config entry."""
for domain in CONFIG_ENTRY_DOMAINS:
await hass.config_entries.async_forward_entry_unload(config_entry, domain)
unload_ok = await hass.config_entries.async_unload_platforms(
config_entry, CONFIG_ENTRY_DOMAINS
)
hass.data[DATA_UPCLOUD].coordinators.pop(config_entry.data[CONF_USERNAME])
return True
return unload_ok
class UpCloudServerEntity(CoordinatorEntity):