diff --git a/homeassistant/components/homekit/util.py b/homeassistant/components/homekit/util.py index a746355e124..673abc5da67 100644 --- a/homeassistant/components/homekit/util.py +++ b/homeassistant/components/homekit/util.py @@ -507,5 +507,5 @@ def state_needs_accessory_mode(state): or state.domain == MEDIA_PLAYER_DOMAIN and state.attributes.get(ATTR_DEVICE_CLASS) == DEVICE_CLASS_TV or state.domain == REMOTE_DOMAIN - and state.attributes.get(ATTR_SUPPORTED_FEATURES) & SUPPORT_ACTIVITY + and state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) & SUPPORT_ACTIVITY ) diff --git a/tests/components/homekit/test_config_flow.py b/tests/components/homekit/test_config_flow.py index 26804675265..c06e8aaa5ad 100644 --- a/tests/components/homekit/test_config_flow.py +++ b/tests/components/homekit/test_config_flow.py @@ -145,6 +145,8 @@ async def test_setup_creates_entries_for_accessory_mode_devices(hass): hass.states.async_set("camera.one", "on") hass.states.async_set("camera.existing", "on") hass.states.async_set("media_player.two", "on", {"device_class": "tv"}) + hass.states.async_set("remote.standard", "on") + hass.states.async_set("remote.activity", "on", {"supported_features": 4}) bridge_mode_entry = MockConfigEntry( domain=DOMAIN, @@ -178,7 +180,7 @@ async def test_setup_creates_entries_for_accessory_mode_devices(hass): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - {"include_domains": ["camera", "media_player", "light"]}, + {"include_domains": ["camera", "media_player", "light", "remote"]}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM assert result2["step_id"] == "pairing" @@ -205,7 +207,7 @@ async def test_setup_creates_entries_for_accessory_mode_devices(hass): "filter": { "exclude_domains": [], "exclude_entities": [], - "include_domains": ["media_player", "light"], + "include_domains": ["media_player", "light", "remote"], "include_entities": [], }, "exclude_accessory_mode": True, @@ -222,7 +224,8 @@ async def test_setup_creates_entries_for_accessory_mode_devices(hass): # 3 - new bridge # 4 - camera.one in accessory mode # 5 - media_player.two in accessory mode - assert len(mock_setup_entry.mock_calls) == 5 + # 6 - remote.activity in accessory mode + assert len(mock_setup_entry.mock_calls) == 6 async def test_import(hass):