Fix setting up remotes that lack a supported features list in homekit (#49152)

This commit is contained in:
J. Nick Koston 2021-04-13 00:44:07 -10:00 committed by GitHub
parent 51a7a724d6
commit 5365fb6c72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

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

View File

@ -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):