Restore removed guard for non-string inputs in Alexa (#104263)

This commit is contained in:
Jan Bouwhuis 2023-11-21 07:59:39 +01:00 committed by GitHub
parent 29ac3a8f66
commit 5c72d3c2d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

@ -857,16 +857,18 @@ class AlexaInputController(AlexaCapability):
def inputs(self) -> list[dict[str, str]] | None:
"""Return the list of valid supported inputs."""
source_list: list[str] = self.entity.attributes.get(
source_list: list[Any] = self.entity.attributes.get(
media_player.ATTR_INPUT_SOURCE_LIST, []
)
return AlexaInputController.get_valid_inputs(source_list)
@staticmethod
def get_valid_inputs(source_list: list[str]) -> list[dict[str, str]]:
def get_valid_inputs(source_list: list[Any]) -> list[dict[str, str]]:
"""Return list of supported inputs."""
input_list: list[dict[str, str]] = []
for source in source_list:
if not isinstance(source, str):
continue
formatted_source = (
source.lower().replace("-", "").replace("_", "").replace(" ", "")
)

View File

@ -183,7 +183,7 @@ async def test_api_increase_color_temp(
("domain", "payload", "source_list", "idx"),
[
("media_player", "GAME CONSOLE", ["tv", "game console", 10000], 1),
("media_player", "SATELLITE TV", ["satellite-tv", "game console"], 0),
("media_player", "SATELLITE TV", ["satellite-tv", "game console", None], 0),
("media_player", "SATELLITE TV", ["satellite_tv", "game console"], 0),
("media_player", "BAD DEVICE", ["satellite_tv", "game console"], None),
],
@ -864,6 +864,7 @@ async def test_report_playback_state(hass: HomeAssistant) -> None:
| MediaPlayerEntityFeature.PLAY
| MediaPlayerEntityFeature.STOP,
"volume_level": 0.75,
"source_list": [None],
},
)

View File

@ -1439,6 +1439,8 @@ async def test_media_player_inputs(hass: HomeAssistant) -> None:
"aux",
"input 1",
"tv",
0,
None,
],
},
)