Wait for config entry platform forwards (#73806)

This commit is contained in:
J. Nick Koston 2022-07-09 10:27:42 -05:00 committed by GitHub
parent 3a5cca3ff2
commit cd03c49fc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
386 changed files with 528 additions and 557 deletions

View file

@ -1,7 +1,6 @@
"""The motionEye integration."""
from __future__ import annotations
import asyncio
from collections.abc import Callable
import contextlib
from http import HTTPStatus
@ -392,20 +391,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
else:
device_registry.async_remove_device(device_entry.id)
async def setup_then_listen() -> None:
await asyncio.gather(
*(
hass.config_entries.async_forward_entry_setup(entry, platform)
for platform in PLATFORMS
)
)
entry.async_on_unload(
coordinator.async_add_listener(_async_process_motioneye_cameras)
)
await coordinator.async_refresh()
entry.async_on_unload(entry.add_update_listener(_async_entry_updated))
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(
coordinator.async_add_listener(_async_process_motioneye_cameras)
)
await coordinator.async_refresh()
entry.async_on_unload(entry.add_update_listener(_async_entry_updated))
hass.async_create_task(setup_then_listen())
return True