mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Fix race in MQTT platform setup (#72344)
Make sure MQTT platforms setup locks discovery
This commit is contained in:
parent
cf5e21a996
commit
eb988f7792
@ -816,14 +816,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
hass.data[DATA_CONFIG_ENTRY_LOCK] = asyncio.Lock()
|
hass.data[DATA_CONFIG_ENTRY_LOCK] = asyncio.Lock()
|
||||||
hass.data[CONFIG_ENTRY_IS_SETUP] = set()
|
hass.data[CONFIG_ENTRY_IS_SETUP] = set()
|
||||||
|
|
||||||
async with hass.data[DATA_CONFIG_ENTRY_LOCK]:
|
async def async_forward_entry_setup():
|
||||||
for component in PLATFORMS:
|
"""Forward the config entry setup to the platforms."""
|
||||||
config_entries_key = f"{component}.mqtt"
|
async with hass.data[DATA_CONFIG_ENTRY_LOCK]:
|
||||||
if config_entries_key not in hass.data[CONFIG_ENTRY_IS_SETUP]:
|
for component in PLATFORMS:
|
||||||
hass.data[CONFIG_ENTRY_IS_SETUP].add(config_entries_key)
|
config_entries_key = f"{component}.mqtt"
|
||||||
hass.async_create_task(
|
if config_entries_key not in hass.data[CONFIG_ENTRY_IS_SETUP]:
|
||||||
hass.config_entries.async_forward_entry_setup(entry, component)
|
hass.data[CONFIG_ENTRY_IS_SETUP].add(config_entries_key)
|
||||||
)
|
await hass.config_entries.async_forward_entry_setup(
|
||||||
|
entry, component
|
||||||
|
)
|
||||||
|
|
||||||
|
hass.async_create_task(async_forward_entry_setup())
|
||||||
|
|
||||||
if conf.get(CONF_DISCOVERY):
|
if conf.get(CONF_DISCOVERY):
|
||||||
await _async_setup_discovery(hass, conf, entry)
|
await _async_setup_discovery(hass, conf, entry)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user