Skip to content

Commit

Permalink
Restore removed guard for non-string inputs in Alexa (#104263)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbouwh authored and frenck committed Nov 22, 2023
1 parent a5d48da commit ae2ff92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions homeassistant/components/alexa/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,16 +857,18 @@ def name(self) -> str:

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(" ", "")
)
Expand Down
3 changes: 2 additions & 1 deletion tests/components/alexa/test_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
Expand Down Expand Up @@ -864,6 +864,7 @@ async def test_report_playback_state(hass: HomeAssistant) -> None:
| MediaPlayerEntityFeature.PLAY
| MediaPlayerEntityFeature.STOP,
"volume_level": 0.75,
"source_list": [None],
},
)

Expand Down
2 changes: 2 additions & 0 deletions tests/components/alexa/test_smart_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,8 @@ async def test_media_player_inputs(hass: HomeAssistant) -> None:
"aux",
"input 1",
"tv",
0,
None,
],
},
)
Expand Down

0 comments on commit ae2ff92

Please sign in to comment.