mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Use discovery flow helper for hardware integrations (#111437)
* Use discovery flow helper for hardware integrations The discovery flow helper defers loading discovered integrations until after startup to improve startup reliability. * Use discovery flow helper for hardware integrations The discovery flow helper defers loading discovered integrations until after startup to improve startup reliability. Since hardware was not listed in as a discovery integration, the notification for new discoveries was missing.
This commit is contained in:
parent
f85a8c5041
commit
4624c859e1
@ -7,9 +7,10 @@ from homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon
|
||||
get_zigbee_socket,
|
||||
multi_pan_addon_using_device,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.config_entries import SOURCE_HARDWARE, ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||
from homeassistant.helpers import discovery_flow
|
||||
|
||||
from .const import DOMAIN
|
||||
from .util import get_usb_service_info
|
||||
@ -51,9 +52,10 @@ async def _async_usb_scan_done(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
},
|
||||
"radio_type": "ezsp",
|
||||
}
|
||||
await hass.config_entries.flow.async_init(
|
||||
discovery_flow.async_create_flow(
|
||||
hass,
|
||||
"zha",
|
||||
context={"source": "hardware"},
|
||||
context={"source": SOURCE_HARDWARE},
|
||||
data=hw_discovery_data,
|
||||
)
|
||||
|
||||
|
@ -7,9 +7,10 @@ from homeassistant.components.homeassistant_hardware.silabs_multiprotocol_addon
|
||||
get_zigbee_socket,
|
||||
multi_pan_addon_using_device,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.config_entries import SOURCE_HARDWARE, ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||
from homeassistant.helpers import discovery_flow
|
||||
|
||||
from .const import RADIO_DEVICE, ZHA_HW_DISCOVERY_DATA
|
||||
|
||||
@ -47,9 +48,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"radio_type": "ezsp",
|
||||
}
|
||||
|
||||
await hass.config_entries.flow.async_init(
|
||||
discovery_flow.async_create_flow(
|
||||
hass,
|
||||
"zha",
|
||||
context={"source": "hardware"},
|
||||
context={"source": SOURCE_HARDWARE},
|
||||
data=hw_discovery_data,
|
||||
)
|
||||
|
||||
|
@ -78,6 +78,7 @@ _LOGGER = logging.getLogger(__name__)
|
||||
SOURCE_BLUETOOTH = "bluetooth"
|
||||
SOURCE_DHCP = "dhcp"
|
||||
SOURCE_DISCOVERY = "discovery"
|
||||
SOURCE_HARDWARE = "hardware"
|
||||
SOURCE_HASSIO = "hassio"
|
||||
SOURCE_HOMEKIT = "homekit"
|
||||
SOURCE_IMPORT = "import"
|
||||
@ -159,6 +160,7 @@ DISCOVERY_SOURCES = {
|
||||
SOURCE_BLUETOOTH,
|
||||
SOURCE_DHCP,
|
||||
SOURCE_DISCOVERY,
|
||||
SOURCE_HARDWARE,
|
||||
SOURCE_HOMEKIT,
|
||||
SOURCE_IMPORT,
|
||||
SOURCE_INTEGRATION_DISCOVERY,
|
||||
|
@ -976,7 +976,7 @@ async def test_hardware(onboarded, hass: HomeAssistant) -> None:
|
||||
"homeassistant.components.onboarding.async_is_onboarded", return_value=onboarded
|
||||
):
|
||||
result1 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": "hardware"}, data=data
|
||||
DOMAIN, context={"source": config_entries.SOURCE_HARDWARE}, data=data
|
||||
)
|
||||
|
||||
if onboarded:
|
||||
@ -1029,7 +1029,7 @@ async def test_hardware_already_setup(hass: HomeAssistant) -> None:
|
||||
},
|
||||
}
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": "hardware"}, data=data
|
||||
DOMAIN, context={"source": config_entries.SOURCE_HARDWARE}, data=data
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
@ -1043,7 +1043,7 @@ async def test_hardware_invalid_data(hass: HomeAssistant, data) -> None:
|
||||
"""Test onboarding flow -- invalid data."""
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": "hardware"}, data=data
|
||||
DOMAIN, context={"source": config_entries.SOURCE_HARDWARE}, data=data
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
|
Loading…
x
Reference in New Issue
Block a user