Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions custom_components/frigate/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,23 @@ def __init__(
else:
self._restream_type = "rtsp"
self._attr_frontend_stream_type = StreamType.HLS
streaming_template = config_entry.options.get(
CONF_RTSP_URL_TEMPLATE, ""
).strip()

if streaming_template:
# Can't use homeassistant.helpers.template as it requires hass which
# is not available in the constructor, so use direct jinja2
# template instead. This means templates cannot access HomeAssistant
# state, but rather only the camera config.
self._stream_source = Template(streaming_template).render(
**self._camera_config
)
else:
self._stream_source = (
f"rtsp://{URL(self._url).host}:8554/{self._cam_name}"
)

streaming_template = config_entry.options.get(
CONF_RTSP_URL_TEMPLATE, ""
).strip()

if streaming_template:
# Can't use homeassistant.helpers.template as it requires hass which
# is not available in the constructor, so use direct jinja2
# template instead. This means templates cannot access HomeAssistant
# state, but rather only the camera config.
self._stream_source = Template(streaming_template).render(
**self._camera_config
)
else:
self._stream_source = (
f"rtsp://{URL(self._url).host}:8554/{self._cam_name}"
)
elif self._camera_config.get("rtmp", {}).get("enabled"):
self._restream_type = "rtmp"
streaming_template = config_entry.options.get(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async def test_frigate_camera_setup_web_rtc(
assert entity_state.attributes["frontend_stream_type"] == StreamType.WEB_RTC

source = await async_get_stream_source(hass, TEST_CAMERA_FRONT_DOOR_ENTITY_ID)
assert source is None
assert source == "rtsp://example.com:8554/front_door"

aioclient_mock.post(
"http://example.com/api/go2rtc/webrtc?src=front_door",
Expand Down