mirror of
https://github.com/home-assistant/core.git
synced 2026-12-02 19:57:03 -04:00
Translate camera stream not supported error (#184576)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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}."
|
||||
},
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"},
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user