Migrate system flows to use the discovery helper (#112291)
Ensures we are not creating new flows or loading their platforms until the started event once the import executor has clamed downpull/112391/head
parent
7cb8a8bbc9
commit
a277d0c4b5
|
@ -11,7 +11,7 @@ from hass_nabucasa import Cloud
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import alexa, google_assistant
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.config_entries import SOURCE_SYSTEM, ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_DESCRIPTION,
|
||||
CONF_MODE,
|
||||
|
@ -304,7 +304,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
return
|
||||
loaded = True
|
||||
|
||||
await hass.config_entries.flow.async_init(DOMAIN, context={"source": "system"})
|
||||
await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_SYSTEM}
|
||||
)
|
||||
|
||||
async def _on_connect() -> None:
|
||||
"""Handle cloud connect."""
|
||||
|
|
|
@ -14,7 +14,7 @@ import voluptuous as vol
|
|||
from homeassistant.auth.const import GROUP_ID_ADMIN
|
||||
from homeassistant.components import panel_custom
|
||||
from homeassistant.components.homeassistant import async_set_stop_handler
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.config_entries import SOURCE_SYSTEM, ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_NAME,
|
||||
EVENT_CORE_CONFIG_UPDATE,
|
||||
|
@ -30,7 +30,11 @@ from homeassistant.core import (
|
|||
callback,
|
||||
)
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
from homeassistant.helpers import (
|
||||
config_validation as cv,
|
||||
device_registry as dr,
|
||||
discovery_flow,
|
||||
)
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.event import async_call_later
|
||||
from homeassistant.helpers.storage import Store
|
||||
|
@ -490,11 +494,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
|
|||
return
|
||||
if (hw_integration := HARDWARE_INTEGRATIONS.get(board)) is None:
|
||||
return
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
hw_integration, context={"source": "system"}
|
||||
),
|
||||
eager_start=True,
|
||||
discovery_flow.async_create_flow(
|
||||
hass, hw_integration, context={"source": SOURCE_SYSTEM}, data={}
|
||||
)
|
||||
|
||||
async_setup_hardware_integration_job = HassJob(
|
||||
|
@ -502,12 +503,9 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # noqa:
|
|||
)
|
||||
|
||||
_async_setup_hardware_integration()
|
||||
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(DOMAIN, context={"source": "system"}),
|
||||
eager_start=True,
|
||||
discovery_flow.async_create_flow(
|
||||
hass, DOMAIN, context={"source": SOURCE_SYSTEM}, data={}
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ SOURCE_IMPORT = "import"
|
|||
SOURCE_INTEGRATION_DISCOVERY = "integration_discovery"
|
||||
SOURCE_MQTT = "mqtt"
|
||||
SOURCE_SSDP = "ssdp"
|
||||
SOURCE_SYSTEM = "system"
|
||||
SOURCE_USB = "usb"
|
||||
SOURCE_USER = "user"
|
||||
SOURCE_ZEROCONF = "zeroconf"
|
||||
|
|
Loading…
Reference in New Issue