Support homekit matches that have a dash after the model (#33274)

pull/33297/head
J. Nick Koston 2020-03-26 17:15:35 -05:00 committed by GitHub
parent f5a6c3484d
commit f93e4e3de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -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(

View File

@ -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(