Fix homekit_controller discovery via zeroconf (#37725)
parent
aabf0dab88
commit
bfbb2826bc
|
@ -198,7 +198,7 @@ def setup(hass, config):
|
|||
|
||||
# If we can handle it as a HomeKit discovery, we do that here.
|
||||
if service_type == HOMEKIT_TYPE:
|
||||
handle_homekit(hass, info)
|
||||
discovery_was_forwarded = handle_homekit(hass, info)
|
||||
# Continue on here as homekit_controller
|
||||
# still needs to get updates on devices
|
||||
# so it can see when the 'c#' field is updated.
|
||||
|
@ -207,7 +207,8 @@ def setup(hass, config):
|
|||
# if the device is already paired in order to avoid
|
||||
# offering a second discovery for the same device
|
||||
if (
|
||||
HOMEKIT_PROPERTIES in info
|
||||
discovery_was_forwarded
|
||||
and HOMEKIT_PROPERTIES in info
|
||||
and HOMEKIT_PAIRED_STATUS_FLAG in info[HOMEKIT_PROPERTIES]
|
||||
):
|
||||
try:
|
||||
|
|
|
@ -215,6 +215,25 @@ async def test_homekit_invalid_paring_status(hass, mock_zeroconf):
|
|||
assert mock_config_flow.mock_calls[0][1][0] == "tado"
|
||||
|
||||
|
||||
async def test_homekit_not_paired(hass, mock_zeroconf):
|
||||
"""Test that an not paired device is sent to homekit_controller."""
|
||||
with patch.dict(
|
||||
zc_gen.ZEROCONF, {zeroconf.HOMEKIT_TYPE: ["homekit_controller"]}, clear=True
|
||||
), patch.object(
|
||||
hass.config_entries.flow, "async_init"
|
||||
) as mock_config_flow, patch.object(
|
||||
zeroconf, "HaServiceBrowser", side_effect=service_update_mock
|
||||
) as mock_service_browser:
|
||||
mock_zeroconf.get_service_info.side_effect = get_homekit_info_mock(
|
||||
"this_will_not_match_any_integration", HOMEKIT_STATUS_UNPAIRED
|
||||
)
|
||||
assert await async_setup_component(hass, zeroconf.DOMAIN, {zeroconf.DOMAIN: {}})
|
||||
|
||||
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] == "homekit_controller"
|
||||
|
||||
|
||||
async def test_info_from_service_non_utf8(hass):
|
||||
"""Test info_from_service handles non UTF-8 property keys and values correctly."""
|
||||
service_type = "_test._tcp.local."
|
||||
|
|
Loading…
Reference in New Issue