Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ability to use templates for RTSP URL. #348

Closed
GaryOkie opened this issue Aug 31, 2022 · 5 comments
Closed

Support ability to use templates for RTSP URL. #348

GaryOkie opened this issue Aug 31, 2022 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@GaryOkie
Copy link

GaryOkie commented Aug 31, 2022

Currently the webrtc-camera card requires a static RTSP URL (or Entity), but it would be very useful if the URL could be dynamically defined with templates. For example, to be able to specify a specific channel for an NVR or start/end times for playback of recorded video.

Example:

type: custom:webrtc-camera
  url:>-
    rtsp://admin:password@192.168.x.x:554/cam/realmonitor?channel={{states.input_select.nvr_channel.state}}&subtype=0

There is a custom Lovelace card-templater that allows the use of HASS/Jinja templates for any card by modifying the options with a "_template" suffix. However, your webrtc-camera card rejects "url_template" saying "Error: missing URL or Entity".

BTW, I reported this as templater issue#59. Maybe webrtc-camera JS code could be tweaked to accept "url_template" so templating could work with very little effort?

If not, then having this card support templates natively is something I hope you can consider adding in the future.

@AlexxIT AlexxIT added the enhancement New feature or request label Aug 31, 2022
@AlexxIT AlexxIT added this to the v3.0 milestone Jan 2, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Jan 2, 2023

Added to master version. Will be in next release

@Daniel-dev22
Copy link

Daniel-dev22 commented Jan 4, 2023

Added to master version. Will be in next release

The current implementation only works for detecting templates with {{ }}. Templates can also have {% %} and no {{ }} at all.

Example.

{% if true %}
doorbell
{% elif false %}
test
{% endif %}

@GaryOkie
Copy link
Author

GaryOkie commented Jan 4, 2023

well, that's great! Having native Jinja2 template support is ideal. The use of other cards in conjunction with webrtc-camera for templating (eg. Lovelace_card_templater) is now not needed - a very useful simplification.

I did find later that the config-template-card does work with webrtc-camera to modify the URL, but it requires Javascript syntax, not Jinja2, which is more commonly preferred for templating.

@Aristocrat55
Copy link

Как изменить url при динамически меняющемся ip адреса у камеры?

@AlexxIT
Copy link
Owner

AlexxIT commented Jan 20, 2023

Should be fixed in v3

@AlexxIT AlexxIT closed this as completed Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants