mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove Alexa.InputController from devices without supported inputs in Alexa (#31450)
* Yield Alexa.InputController only for supported inputs. * Add Comment. * Comment fix.
This commit is contained in:
parent
119566f280
commit
4602d7370c
@ -749,6 +749,13 @@ class AlexaInputController(AlexaCapability):
|
||||
source_list = self.entity.attributes.get(
|
||||
media_player.ATTR_INPUT_SOURCE_LIST, []
|
||||
)
|
||||
input_list = AlexaInputController.get_valid_inputs(source_list)
|
||||
|
||||
return input_list
|
||||
|
||||
@staticmethod
|
||||
def get_valid_inputs(source_list):
|
||||
"""Return list of supported inputs."""
|
||||
input_list = []
|
||||
for source in source_list:
|
||||
formatted_source = (
|
||||
|
@ -526,7 +526,13 @@ class MediaPlayerCapabilities(AlexaEntity):
|
||||
yield AlexaSeekController(self.entity)
|
||||
|
||||
if supported & media_player.SUPPORT_SELECT_SOURCE:
|
||||
yield AlexaInputController(self.entity)
|
||||
inputs = AlexaInputController.get_valid_inputs(
|
||||
self.entity.attributes.get(
|
||||
media_player.const.ATTR_INPUT_SOURCE_LIST, []
|
||||
)
|
||||
)
|
||||
if len(inputs) > 0:
|
||||
yield AlexaInputController(self.entity)
|
||||
|
||||
if supported & media_player.const.SUPPORT_PLAY_MEDIA:
|
||||
yield AlexaChannelController(self.entity)
|
||||
|
@ -887,6 +887,7 @@ async def test_media_player(hass):
|
||||
| SUPPORT_VOLUME_MUTE
|
||||
| SUPPORT_VOLUME_SET,
|
||||
"volume_level": 0.75,
|
||||
"source_list": ["hdmi", "tv"],
|
||||
},
|
||||
)
|
||||
appliance = await discovery_test(device, hass)
|
||||
@ -1047,7 +1048,6 @@ async def test_media_player_power(hass):
|
||||
"Alexa",
|
||||
"Alexa.ChannelController",
|
||||
"Alexa.EndpointHealth",
|
||||
"Alexa.InputController",
|
||||
"Alexa.PlaybackController",
|
||||
"Alexa.PlaybackStateReporter",
|
||||
"Alexa.PowerController",
|
||||
@ -1176,6 +1176,41 @@ async def test_media_player_inputs(hass):
|
||||
assert call.data["source"] == "tv"
|
||||
|
||||
|
||||
async def test_media_player_no_supported_inputs(hass):
|
||||
"""Test media player discovery with no supported inputs."""
|
||||
device = (
|
||||
"media_player.test_no_inputs",
|
||||
"off",
|
||||
{
|
||||
"friendly_name": "Test media player",
|
||||
"supported_features": SUPPORT_SELECT_SOURCE,
|
||||
"volume_level": 0.75,
|
||||
"source_list": [
|
||||
"foo",
|
||||
"foo_2",
|
||||
"vcr",
|
||||
"betamax",
|
||||
"record_player",
|
||||
"f.m.",
|
||||
"a.m.",
|
||||
"tape_deck",
|
||||
"laser_disc",
|
||||
"hd_dvd",
|
||||
],
|
||||
},
|
||||
)
|
||||
appliance = await discovery_test(device, hass)
|
||||
|
||||
assert appliance["endpointId"] == "media_player#test_no_inputs"
|
||||
assert appliance["displayCategories"][0] == "TV"
|
||||
assert appliance["friendlyName"] == "Test media player"
|
||||
|
||||
# Assert Alexa.InputController is not in capabilities list.
|
||||
assert_endpoint_capabilities(
|
||||
appliance, "Alexa", "Alexa.EndpointHealth", "Alexa.PowerController"
|
||||
)
|
||||
|
||||
|
||||
async def test_media_player_speaker(hass):
|
||||
"""Test media player with speaker interface."""
|
||||
device = (
|
||||
|
Loading…
x
Reference in New Issue
Block a user