mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Restore removed guard for non-string inputs in Alexa (#104263)
This commit is contained in:
parent
29ac3a8f66
commit
5c72d3c2d8
@ -857,16 +857,18 @@ class AlexaInputController(AlexaCapability):
|
|||||||
|
|
||||||
def inputs(self) -> list[dict[str, str]] | None:
|
def inputs(self) -> list[dict[str, str]] | None:
|
||||||
"""Return the list of valid supported inputs."""
|
"""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, []
|
media_player.ATTR_INPUT_SOURCE_LIST, []
|
||||||
)
|
)
|
||||||
return AlexaInputController.get_valid_inputs(source_list)
|
return AlexaInputController.get_valid_inputs(source_list)
|
||||||
|
|
||||||
@staticmethod
|
@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."""
|
"""Return list of supported inputs."""
|
||||||
input_list: list[dict[str, str]] = []
|
input_list: list[dict[str, str]] = []
|
||||||
for source in source_list:
|
for source in source_list:
|
||||||
|
if not isinstance(source, str):
|
||||||
|
continue
|
||||||
formatted_source = (
|
formatted_source = (
|
||||||
source.lower().replace("-", "").replace("_", "").replace(" ", "")
|
source.lower().replace("-", "").replace("_", "").replace(" ", "")
|
||||||
)
|
)
|
||||||
|
@ -183,7 +183,7 @@ async def test_api_increase_color_temp(
|
|||||||
("domain", "payload", "source_list", "idx"),
|
("domain", "payload", "source_list", "idx"),
|
||||||
[
|
[
|
||||||
("media_player", "GAME CONSOLE", ["tv", "game console", 10000], 1),
|
("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", "SATELLITE TV", ["satellite_tv", "game console"], 0),
|
||||||
("media_player", "BAD DEVICE", ["satellite_tv", "game console"], None),
|
("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.PLAY
|
||||||
| MediaPlayerEntityFeature.STOP,
|
| MediaPlayerEntityFeature.STOP,
|
||||||
"volume_level": 0.75,
|
"volume_level": 0.75,
|
||||||
|
"source_list": [None],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1439,6 +1439,8 @@ async def test_media_player_inputs(hass: HomeAssistant) -> None:
|
|||||||
"aux",
|
"aux",
|
||||||
"input 1",
|
"input 1",
|
||||||
"tv",
|
"tv",
|
||||||
|
0,
|
||||||
|
None,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user