diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 8f8d9132137..3a07804afe3 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -512,16 +512,19 @@ class ConfigEntry: ) result = False + # + # After successfully calling async_setup_entry, it is important that this function + # does not yield to the event loop by using `await` or `async with` or + # similar until after the state has been set by calling self._async_set_state. + # + # Otherwise we risk that any `call_soon`s + # created by an integration will be executed before the state is set. + # + # Only store setup result as state if it was not forwarded. if not domain_is_integration: return - # - # It is important that this function does not yield to the - # event loop by using `await` or `async with` or similar until - # after the state has been set. Otherwise we risk that any `call_soon`s - # created by an integration will be executed before the state is set. - # if result: self._async_set_state(hass, ConfigEntryState.LOADED, None) else: