mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Store alternative domain for Zeroconf homekit discovery (#79240)
This commit is contained in:
parent
aa6f15b1e2
commit
6e893d9162
@ -404,6 +404,7 @@ class ZeroconfDiscovery:
|
||||
|
||||
_LOGGER.debug("Discovered new device %s %s", name, info)
|
||||
props: dict[str, str] = info.properties
|
||||
domain = None
|
||||
|
||||
# If we can handle it as a HomeKit discovery, we do that here.
|
||||
if service_type in HOMEKIT_TYPES and (
|
||||
@ -458,10 +459,17 @@ class ZeroconfDiscovery:
|
||||
|
||||
matcher_domain = matcher["domain"]
|
||||
assert isinstance(matcher_domain, str)
|
||||
context = {
|
||||
"source": config_entries.SOURCE_ZEROCONF,
|
||||
}
|
||||
if domain:
|
||||
# Domain of integration that offers alternative API to handle this device.
|
||||
context["alternative_domain"] = domain
|
||||
|
||||
discovery_flow.async_create_flow(
|
||||
self.hass,
|
||||
matcher_domain,
|
||||
{"source": config_entries.SOURCE_ZEROCONF},
|
||||
context,
|
||||
info,
|
||||
)
|
||||
|
||||
|
@ -327,6 +327,7 @@ async def test_zeroconf_match_macaddress(hass, mock_async_zeroconf):
|
||||
assert len(mock_service_browser.mock_calls) == 1
|
||||
assert len(mock_config_flow.mock_calls) == 1
|
||||
assert mock_config_flow.mock_calls[0][1][0] == "shelly"
|
||||
assert mock_config_flow.mock_calls[0][2]["context"] == {"source": "zeroconf"}
|
||||
|
||||
|
||||
async def test_zeroconf_match_manufacturer(hass, mock_async_zeroconf):
|
||||
@ -533,6 +534,10 @@ async def test_homekit_match_partial_space(hass, mock_async_zeroconf):
|
||||
# One for HKC, and one for LIFX since lifx is local polling
|
||||
assert len(mock_config_flow.mock_calls) == 2
|
||||
assert mock_config_flow.mock_calls[0][1][0] == "lifx"
|
||||
assert mock_config_flow.mock_calls[1][2]["context"] == {
|
||||
"source": "zeroconf",
|
||||
"alternative_domain": "lifx",
|
||||
}
|
||||
|
||||
|
||||
async def test_homekit_match_partial_dash(hass, mock_async_zeroconf):
|
||||
|
Loading…
x
Reference in New Issue
Block a user