diff --git a/homeassistant/components/zeroconf/__init__.py b/homeassistant/components/zeroconf/__init__.py index 206f529344f..16a7d2f000c 100644 --- a/homeassistant/components/zeroconf/__init__.py +++ b/homeassistant/components/zeroconf/__init__.py @@ -132,7 +132,11 @@ def handle_homekit(hass, info) -> bool: return False for test_model in HOMEKIT: - if model != test_model and not model.startswith(test_model + " "): + if ( + model != test_model + and not model.startswith(test_model + " ") + and not model.startswith(test_model + "-") + ): continue hass.add_job( diff --git a/tests/components/zeroconf/test_init.py b/tests/components/zeroconf/test_init.py index a74c81ba307..4e086978be1 100644 --- a/tests/components/zeroconf/test_init.py +++ b/tests/components/zeroconf/test_init.py @@ -68,7 +68,7 @@ async def test_setup(hass, mock_zeroconf): assert len(mock_config_flow.mock_calls) == expected_flow_calls * 2 -async def test_homekit_match_partial(hass, mock_zeroconf): +async def test_homekit_match_partial_space(hass, mock_zeroconf): """Test configured options for a device are loaded via config entry.""" with patch.dict( zc_gen.ZEROCONF, {zeroconf.HOMEKIT_TYPE: ["homekit_controller"]}, clear=True @@ -83,6 +83,23 @@ async def test_homekit_match_partial(hass, mock_zeroconf): assert mock_config_flow.mock_calls[0][1][0] == "lifx" +async def test_homekit_match_partial_dash(hass, mock_zeroconf): + """Test configured options for a device are loaded via config entry.""" + with patch.dict( + zc_gen.ZEROCONF, {zeroconf.HOMEKIT_TYPE: ["homekit_controller"]}, clear=True + ), patch.object(hass.config_entries, "flow") as mock_config_flow, patch.object( + zeroconf, "ServiceBrowser", side_effect=service_update_mock + ) as mock_service_browser: + mock_zeroconf.get_service_info.side_effect = get_homekit_info_mock( + "Rachio-fa46ba" + ) + 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) == 2 + assert mock_config_flow.mock_calls[0][1][0] == "rachio" + + async def test_homekit_match_full(hass, mock_zeroconf): """Test configured options for a device are loaded via config entry.""" with patch.dict(