Reduce boilerplate to setup config entry platforms A-C (#49681)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
922eec0909
commit
51be2f860a
34 changed files with 119 additions and 409 deletions
|
@ -1,5 +1,4 @@
|
|||
"""The AccuWeather component."""
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
|
@ -46,23 +45,15 @@ async def async_setup_entry(hass, config_entry) -> bool:
|
|||
UNDO_UPDATE_LISTENER: undo_listener,
|
||||
}
|
||||
|
||||
for platform in PLATFORMS:
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_forward_entry_setup(config_entry, platform)
|
||||
)
|
||||
hass.config_entries.async_setup_platforms(config_entry, PLATFORMS)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass, config_entry):
|
||||
"""Unload a config entry."""
|
||||
unload_ok = all(
|
||||
await asyncio.gather(
|
||||
*[
|
||||
hass.config_entries.async_forward_entry_unload(config_entry, platform)
|
||||
for platform in PLATFORMS
|
||||
]
|
||||
)
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||
config_entry, PLATFORMS
|
||||
)
|
||||
|
||||
hass.data[DOMAIN][config_entry.entry_id][UNDO_UPDATE_LISTENER]()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue