mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Fix mqtt platform setup race (#112888)
This commit is contained in:
@@ -53,14 +53,12 @@ async def async_forward_entry_setup_and_setup_discovery(
|
||||
mqtt_data = get_mqtt_data(hass)
|
||||
platforms_loaded = mqtt_data.platforms_loaded
|
||||
new_platforms: set[Platform | str] = platforms - platforms_loaded
|
||||
platforms_loaded.update(new_platforms)
|
||||
tasks: list[asyncio.Task] = []
|
||||
if "device_automation" in new_platforms:
|
||||
# Local import to avoid circular dependencies
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from . import device_automation
|
||||
|
||||
new_platforms.remove("device_automation")
|
||||
tasks.append(
|
||||
create_eager_task(device_automation.async_setup_entry(hass, config_entry))
|
||||
)
|
||||
@@ -69,19 +67,19 @@ async def async_forward_entry_setup_and_setup_discovery(
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from . import tag
|
||||
|
||||
new_platforms.remove("tag")
|
||||
tasks.append(create_eager_task(tag.async_setup_entry(hass, config_entry)))
|
||||
if new_platforms:
|
||||
if new_entity_platforms := (new_platforms - {"tag", "device_automation"}):
|
||||
tasks.append(
|
||||
create_eager_task(
|
||||
hass.config_entries.async_forward_entry_setups(
|
||||
config_entry, new_platforms
|
||||
config_entry, new_entity_platforms
|
||||
)
|
||||
)
|
||||
)
|
||||
if not tasks:
|
||||
return
|
||||
await asyncio.gather(*tasks)
|
||||
platforms_loaded.update(new_platforms)
|
||||
|
||||
|
||||
def mqtt_config_entry_enabled(hass: HomeAssistant) -> bool | None:
|
||||
|
||||
Reference in New Issue
Block a user