Only support remote activity on Alexa if feature is set and at least one feature is in the activity_list (#124567)

Only support remote activity on Alexa if feaure is set and at least one feature is in the activity_list
This commit is contained in:
Jan Bouwhuis 2024-08-25 15:09:08 +02:00 committed by GitHub
parent 51b520db0c
commit 5550b1a74e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 7 deletions

View file

@ -661,9 +661,12 @@ class RemoteCapabilities(AlexaEntity):
def interfaces(self) -> Generator[AlexaCapability]:
"""Yield the supported interfaces."""
yield AlexaPowerController(self.entity)
yield AlexaModeController(
self.entity, instance=f"{remote.DOMAIN}.{remote.ATTR_ACTIVITY}"
)
supported = self.entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
activities = self.entity.attributes.get(remote.ATTR_ACTIVITY_LIST) or []
if activities and supported & remote.RemoteEntityFeature.ACTIVITY:
yield AlexaModeController(
self.entity, instance=f"{remote.DOMAIN}.{remote.ATTR_ACTIVITY}"
)
yield AlexaEndpointHealth(self.hass, self.entity)
yield Alexa(self.entity)

View file

@ -70,6 +70,7 @@ async def test_discovery_remote(
{
"current_activity": current_activity,
"activity_list": activity_list,
"supported_features": 4,
},
)
msg = await smart_home.async_handle_message(hass, get_default_config(hass), request)
@ -790,22 +791,37 @@ async def test_report_remote_activity(hass: HomeAssistant) -> None:
hass.states.async_set(
"remote.unknown",
"on",
{"current_activity": "UNKNOWN"},
{
"current_activity": "UNKNOWN",
"supported_features": 4,
},
)
hass.states.async_set(
"remote.tv",
"on",
{"current_activity": "TV", "activity_list": ["TV", "MUSIC", "DVD"]},
{
"current_activity": "TV",
"activity_list": ["TV", "MUSIC", "DVD"],
"supported_features": 4,
},
)
hass.states.async_set(
"remote.music",
"on",
{"current_activity": "MUSIC", "activity_list": ["TV", "MUSIC", "DVD"]},
{
"current_activity": "MUSIC",
"activity_list": ["TV", "MUSIC", "DVD"],
"supported_features": 4,
},
)
hass.states.async_set(
"remote.dvd",
"on",
{"current_activity": "DVD", "activity_list": ["TV", "MUSIC", "DVD"]},
{
"current_activity": "DVD",
"activity_list": ["TV", "MUSIC", "DVD"],
"supported_features": 4,
},
)
properties = await reported_properties(hass, "remote#unknown")