mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Manage unsupported sources on Samsung TV (#144221)
This commit is contained in:
parent
57217b46ed
commit
c9a9488ff5
@ -386,4 +386,8 @@ class SamsungTVDevice(SamsungTVEntity, MediaPlayerEntity):
|
||||
await self._async_send_keys([SOURCES[source]])
|
||||
return
|
||||
|
||||
LOGGER.error("Unsupported source")
|
||||
raise HomeAssistantError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="source_unsupported",
|
||||
translation_placeholders={"entity": self.entity_id, "source": source},
|
||||
)
|
||||
|
@ -68,6 +68,9 @@
|
||||
"service_unsupported": {
|
||||
"message": "Entity {entity} does not support this action."
|
||||
},
|
||||
"source_unsupported": {
|
||||
"message": "Entity {entity} does not support source {source}."
|
||||
},
|
||||
"error_set_volume": {
|
||||
"message": "Unable to set volume level on {host}: {error}"
|
||||
},
|
||||
|
@ -1105,17 +1105,27 @@ async def test_select_source(hass: HomeAssistant, remote: Mock) -> None:
|
||||
|
||||
async def test_select_source_invalid_source(hass: HomeAssistant) -> None:
|
||||
"""Test for select_source with invalid source."""
|
||||
|
||||
source = "INVALID"
|
||||
|
||||
with patch("homeassistant.components.samsungtv.bridge.Remote") as remote:
|
||||
await setup_samsungtv_entry(hass, MOCK_CONFIG)
|
||||
remote.reset_mock()
|
||||
with pytest.raises(HomeAssistantError) as exc_info:
|
||||
await hass.services.async_call(
|
||||
MP_DOMAIN,
|
||||
SERVICE_SELECT_SOURCE,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_INPUT_SOURCE: "INVALID"},
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_INPUT_SOURCE: source},
|
||||
True,
|
||||
)
|
||||
# control not called
|
||||
assert remote.control.call_count == 0
|
||||
assert exc_info.value.translation_domain == DOMAIN
|
||||
assert exc_info.value.translation_key == "source_unsupported"
|
||||
assert exc_info.value.translation_placeholders == {
|
||||
"entity": ENTITY_ID,
|
||||
"source": source,
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("rest_api")
|
||||
|
Loading…
x
Reference in New Issue
Block a user