Skip to content

Commit

Permalink
Support homekit matches that have a dash after the model (home-assist…
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Mar 26, 2020
1 parent f5a6c34 commit f93e4e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion homeassistant/components/zeroconf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 18 additions & 1 deletion tests/components/zeroconf/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit f93e4e3

Please sign in to comment.