Reduce config entry setup/unload boilerplate Q-S (#49778)

This commit is contained in:
J. Nick Koston 2021-04-27 10:10:04 -10:00 committed by GitHub
parent d2fd504442
commit 87420627a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 119 additions and 436 deletions

View file

@ -202,24 +202,14 @@ async def async_setup_entry(hass, entry: config_entries.ConfigEntry):
)
return False
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
async def async_unload_entry(hass, entry: config_entries.ConfigEntry):
"""Unload RFXtrx component."""
if not all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, platform)
for platform in PLATFORMS
]
)
):
if not await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
return False
hass.services.async_remove(DOMAIN, SERVICE_SEND)