Reduce config entry setup/unload boilerplate N-P (#49777)
This commit is contained in:
parent
6df19205da
commit
3f3f77c6e6
36 changed files with 90 additions and 389 deletions
|
@ -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]()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue