Reduce config entry setup/unload boilerplate N-P (#49777)

This commit is contained in:
J. Nick Koston 2021-04-27 08:42:21 -10:00 committed by GitHub
parent 6df19205da
commit 3f3f77c6e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 90 additions and 389 deletions

View file

@ -136,10 +136,7 @@ async def async_setup_entry_gw(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if single_master_thermostat is None:
platforms = SENSOR_PLATFORMS
for platform in platforms:
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, platform)
)
hass.config_entries.async_setup_platforms(entry, platforms)
return True
@ -154,13 +151,8 @@ async def _update_listener(hass: HomeAssistant, entry: ConfigEntry):
async def async_unload_entry_gw(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, platform)
for platform in PLATFORMS_GATEWAY
]
)
unload_ok = await hass.config_entries.async_unload_platforms(
entry, PLATFORMS_GATEWAY
)
hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]()