mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Add exceptions translation to SamsungTV (#142406)
* Add exceptions translation to SmasungTV * Update strings.json Co-authored-by: Franck Nijhof <frenck@frenck.nl> --------- Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
a4904a3f2d
commit
e1d223f726
@ -15,6 +15,7 @@ from homeassistant.helpers.trigger import TriggerActionType, TriggerInfo
|
|||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
from . import trigger
|
from . import trigger
|
||||||
|
from .const import DOMAIN
|
||||||
from .helpers import (
|
from .helpers import (
|
||||||
async_get_client_by_device_entry,
|
async_get_client_by_device_entry,
|
||||||
async_get_device_entry_by_device_id,
|
async_get_device_entry_by_device_id,
|
||||||
@ -75,4 +76,8 @@ async def async_attach_trigger(
|
|||||||
hass, trigger_config, action, trigger_info
|
hass, trigger_config, action, trigger_info
|
||||||
)
|
)
|
||||||
|
|
||||||
raise HomeAssistantError(f"Unhandled trigger type {trigger_type}")
|
raise HomeAssistantError(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="unhandled_trigger_type",
|
||||||
|
translation_placeholders={"trigger_type": trigger_type},
|
||||||
|
)
|
||||||
|
@ -106,5 +106,7 @@ class SamsungTVEntity(CoordinatorEntity[SamsungTVDataUpdateCoordinator], Entity)
|
|||||||
self.entity_id,
|
self.entity_id,
|
||||||
)
|
)
|
||||||
raise HomeAssistantError(
|
raise HomeAssistantError(
|
||||||
f"Entity {self.entity_id} does not support this service."
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="service_unsupported",
|
||||||
|
translation_placeholders={"entity": self.entity_id},
|
||||||
)
|
)
|
||||||
|
@ -60,5 +60,13 @@
|
|||||||
"trigger_type": {
|
"trigger_type": {
|
||||||
"samsungtv.turn_on": "Device is requested to turn on"
|
"samsungtv.turn_on": "Device is requested to turn on"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"exceptions": {
|
||||||
|
"unhandled_trigger_type": {
|
||||||
|
"message": "Unhandled trigger type {trigger_type}."
|
||||||
|
},
|
||||||
|
"service_unsupported": {
|
||||||
|
"message": "Entity {entity} does not support this action."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,9 +122,14 @@ async def test_turn_on_wol(hass: HomeAssistant) -> None:
|
|||||||
async def test_turn_on_without_turnon(hass: HomeAssistant, remote: Mock) -> None:
|
async def test_turn_on_without_turnon(hass: HomeAssistant, remote: Mock) -> None:
|
||||||
"""Test turn on."""
|
"""Test turn on."""
|
||||||
await setup_samsungtv_entry(hass, MOCK_CONFIG)
|
await setup_samsungtv_entry(hass, MOCK_CONFIG)
|
||||||
with pytest.raises(HomeAssistantError, match="does not support this service"):
|
with pytest.raises(HomeAssistantError) as exc_info:
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
REMOTE_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
REMOTE_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}, True
|
||||||
)
|
)
|
||||||
# nothing called as not supported feature
|
# nothing called as not supported feature
|
||||||
assert remote.control.call_count == 0
|
assert remote.control.call_count == 0
|
||||||
|
assert exc_info.value.translation_domain == DOMAIN
|
||||||
|
assert exc_info.value.translation_key == "service_unsupported"
|
||||||
|
assert exc_info.value.translation_placeholders == {
|
||||||
|
"entity": ENTITY_ID,
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user