diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 82a5e9749cd0..b76cfc77e33f 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -914,7 +914,14 @@ async def ws_camera_stream( connection.send_result(msg["id"], {"url": url}) except HomeAssistantError as ex: _LOGGER.error("Error requesting stream: %s", ex) - connection.send_error(msg["id"], "start_stream_failed", str(ex)) + connection.send_error( + msg["id"], + "start_stream_failed", + str(ex), + translation_domain=ex.translation_domain, + translation_key=ex.translation_key, + translation_placeholders=ex.translation_placeholders, + ) except TimeoutError: _LOGGER.error("Timeout getting stream source") connection.send_error( diff --git a/homeassistant/components/camera/helper.py b/homeassistant/components/camera/helper.py index 0c37990ac841..db2deeb5ee29 100644 --- a/homeassistant/components/camera/helper.py +++ b/homeassistant/components/camera/helper.py @@ -5,7 +5,7 @@ from typing import TYPE_CHECKING from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError -from .const import DATA_COMPONENT, CameraEntityFeature +from .const import DATA_COMPONENT, DOMAIN, CameraEntityFeature if TYPE_CHECKING: from . import Camera @@ -53,7 +53,9 @@ async def async_stream_endpoint_url( stream = await camera.async_create_stream() if not stream: raise HomeAssistantError( - f"{camera.entity_id} does not support play stream service" + translation_domain=DOMAIN, + translation_key="stream_not_supported", + translation_placeholders={"entity_id": camera.entity_id}, ) stream.add_provider(fmt) diff --git a/homeassistant/components/camera/strings.json b/homeassistant/components/camera/strings.json index cbe97393b402..0778d629b599 100644 --- a/homeassistant/components/camera/strings.json +++ b/homeassistant/components/camera/strings.json @@ -44,6 +44,9 @@ "snapshot_timeout": { "message": "Unable to get snapshot: timed out after {timeout} seconds." }, + "stream_not_supported": { + "message": "Camera {entity_id} does not support streaming." + }, "write_failed": { "message": "Cannot write image to {filename}." }, diff --git a/tests/components/camera/test_media_source.py b/tests/components/camera/test_media_source.py index f06b44d5a88f..6ae70419cd67 100644 --- a/tests/components/camera/test_media_source.py +++ b/tests/components/camera/test_media_source.py @@ -146,6 +146,4 @@ async def test_resolving_errors(hass: HomeAssistant) -> None: await media_source.async_resolve_media( hass, "media-source://camera/camera.demo_camera", None ) - assert ( - str(exc_info.value) == "camera.demo_camera does not support play stream service" - ) + assert str(exc_info.value) == "Camera camera.demo_camera does not support streaming" diff --git a/tests/components/generic/test_camera.py b/tests/components/generic/test_camera.py index 5b74380dff72..1aeab6ce9f3d 100644 --- a/tests/components/generic/test_camera.py +++ b/tests/components/generic/test_camera.py @@ -422,7 +422,10 @@ async def test_stream_source_error( assert msg["success"] is False assert msg["error"] == { "code": "start_stream_failed", - "message": "camera.config_test does not support play stream service", + "message": "Camera camera.config_test does not support streaming", + "translation_domain": "camera", + "translation_key": "stream_not_supported", + "translation_placeholders": {"entity_id": "camera.config_test"}, } @@ -484,7 +487,10 @@ async def test_no_stream_source( assert msg["success"] is False assert msg["error"] == { "code": "start_stream_failed", - "message": "camera.config_test does not support play stream service", + "message": "Camera camera.config_test does not support streaming", + "translation_domain": "camera", + "translation_key": "stream_not_supported", + "translation_placeholders": {"entity_id": "camera.config_test"}, }