Hi all,
@AlexxIT excellent work; stream delay was a major issue that you managed to overcome .
Has anyone managed to utilize the âcustomâ PTZ config example for a camera?
My issue is the following. I have two cameras for which I have found the URLs for PTZ movement. Examples (for right direction) are:
Camera 1 (wanscam):
PTZ start right: http:// 10.2.124.81:1027/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=right&-speed=45
PTZ stop: http:// 10.2.124.81:1027/web/cgi-bin/hi3510/ptzctrl.cgi?-step=0&-act=stop&-speed=45
Camera 2 (floureon):
PTZ start right: http:// 10.2.124.83/form/setPTZCfg?command=4&ZFSpeed=0&PTSpeed=0&panSpeed=8&tiltSpeed=8&focusSpeed=2&zoomSpeed=2
PTZ stop: http:// 10.2.124.83/form/setPTZCfg?command=0&ZFSpeed=0&PTSpeed=0&panSpeed=8&tiltSpeed=8&focusSpeed=2&zoomSpeed=2
In order to control my cameras via home assistant I have created a script that calls the necessary PTZ actions; and assign these to a button on the UI. For instance the below example works for the right movement - when I assign the âbalcony_cam_rightâ script to a UI button and press it, the camera moves right:
rest_command:
balcony_cam_start_right:
url: âhttp://10.2.124.83/form/setPTZCfg?command=4&ZFSpeed=0&PTSpeed=0&panSpeed=8&tiltSpeed=8&focusSpeed=2&zoomSpeed=2â
balcony_cam_stop:
url: âhttp://10.2.124.83/form/setPTZCfg?command=0&ZFSpeed=0&PTSpeed=0&panSpeed=8&tiltSpeed=8&focusSpeed=2&zoomSpeed=2â
script:
balcony_cam_right:
sequence:
- service: rest_command.balcony_cam_start_right
- service: rest_command.balcony_cam_stop
ThoughâŚ. I would like to avoid this and utilize the embedded PTZ controls offered by webrtc plugin.
In the lovelace card I have placed the below code:
type: custom:webrtc-camera
url: rtsp://10.2.124.83:1031/1/h264major
webrtc: true
ptz:
service: script.camera_ptz
data_left:
direction: 3
data_right:
direction: 4
data_up:
direction: 1
data_down:
direction: 2
I have tried to write the proper code in the yalm file but with no luck. Basically I do not know how I can retrieve the âdirectionâ parameter in the below code. Since each camera has its own PTZ functions (e.g. for right direction, one camera uses the â0â command, where the another one the ârightâ tag) I would like to create a script by which I can define these.
script:
camera_ptz:
sequence:
- service: >
{% if {{direction}} == 4 %} script.balcony_cam_right
{% else %} script.balcony_cam_down {% endif %}
If I manage to fix the above code, then I can enhance the âifâ statements so as to include all directions. Any help on the above âcamera_ptzâ script would be appreciated.
Thank you.