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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 64 additions and 198 deletions

View file

@ -362,12 +362,7 @@ class UniFiController:
self.wireless_clients = wireless_clients.get_data(self.config_entry)
self.update_wireless_clients()
for platform in PLATFORMS:
self.hass.async_create_task(
self.hass.config_entries.async_forward_entry_setup(
self.config_entry, platform
)
)
self.hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
self.api.start_websocket()
@ -452,16 +447,10 @@ class UniFiController:
"""
self.api.stop_websocket()
unload_ok = all(
await asyncio.gather(
*[
self.hass.config_entries.async_forward_entry_unload(
self.config_entry, platform
)
for platform in PLATFORMS
]
)
unload_ok = await self.hass.config_entries.async_unload_platforms(
self.config_entry, PLATFORMS
)
if not unload_ok:
return False