I have implemented something similar with custom ui elements. Its working pretty ok for now but there are many hard coded strings etc. For now, there are simply four buttons which activate a service on the server side (using manual switches atm, but this service could get integrated into e.g. the camera platform in some fashion [e.g., enable_motion_detection and disable_motion_detection are already there]).
Generally speaking, does anybody know what the current status regarding this is? This is the only thread I have found so far, maybe this has been discussed elsewhere.
There are also other things that have to be considered, e.g.:
there are many different ways to control ptz: (e.g. SOAP requests for onvif, general http requests, custom python library)
as far as I can estimate this, the service could be residing in many different locations and be referenced by the config? (e.g. in the onvif platform for onvif ptz cameras)
So far this is working for me great (as a custom ui element) but would love to help creating an general approach.
2 Likes
I might tackle this next weekend. I want this as well. Here’s my goals:
add ui for ptz controls
make ptz presets available as services to control via automation
Longer term goals:
send audio output to the camera
send images to aws rekognition to identity faces and then send personalized audio responses back
1 Like
emouawad
(Elie Mouawad)
November 10, 2018, 12:37am
9
did u manage to implement it? ui maybe
1 Like
danny
(Daniel Mason)
November 10, 2018, 1:20am
10
I am working on this for amcrest, see here
Could you share your YAML code for the PTZ camera control buttons (UP / DOWN / LEFT / RIGHT)? Thanks!
grea09
(Antoine Gréa)
February 8, 2019, 11:55am
12
Hi,
I have my own home made solution for that. It’s quite simple:
First a bit of API to trigger the PTZ
rest_command :
ptz_goto:
url: !secret camera_ptz_goto
ptz_manual:
url: !secret camera_ptz_manual
Then a couple of automation with an input_number
representing the ptz view number
automation:
- alias: ptz_auto
initial_state: true
trigger:
platform: state
entity_id: input_number.ptz
action:
service: rest_command.ptz_goto
data_template:
preset: "{{ states('input_number.ptz') | int }}"
Then lots of switches to control manually or using PTZ views
switch :
- platform: template
switches:
camera_up:
value_template: "on"
turn_on:
service: rest_command.ptz_manual
data_template:
command: up
turn_off:
service: rest_command.ptz_manual
data_template:
command: up
- platform: template
switches:
camera_down:
value_template: "on"
turn_on:
service: rest_command.ptz_manual
data_template:
command: down
turn_off:
service: rest_command.ptz_manual
data_template:
command: down
- platform: template
switches:
camera_left:
value_template: "on"
turn_on:
service: rest_command.ptz_manual
data_template:
command: right
turn_off:
service: rest_command.ptz_manual
data_template:
command: right
- platform: template
switches:
camera_right:
value_template: "on"
turn_on:
service: rest_command.ptz_manual
data_template:
command: left
turn_off:
service: rest_command.ptz_manual
data_template:
command: left
- platform: template
switches:
camera_diag:
value_template: "{{ (states('input_number.ptz') | int) == 0}}"
turn_on:
service: input_number.set_value
data_template:
entity_id: input_number.ptz
value: 0
turn_off:
service: input_number.set_value
data_template:
entity_id: input_number.ptz
value: 0
- platform: template
switches:
camera_desk:
value_template: "{{ (states('input_number.ptz') | int) == 1}}"
turn_on:
service: input_number.set_value
data_template:
entity_id: input_number.ptz
value: 1
turn_off:
service: input_number.set_value
data_template:
entity_id: input_number.ptz
value: 0
- platform: template
switches:
camera_sofa:
value_template: "{{ (states('input_number.ptz') | int) == 2}}"
turn_on:
service: input_number.set_value
data_template:
entity_id: input_number.ptz
value: 2
turn_off:
service: input_number.set_value
data_template:
entity_id: input_number.ptz
value: 0
- platform: template
switches:
camera_bed:
value_template: "{{ (states('input_number.ptz') | int) == 3}}"
turn_on:
service: input_number.set_value
data_template:
entity_id: input_number.ptz
value: 3
turn_off:
service: input_number.set_value
data_template:
entity_id: input_number.ptz
value: 0
The result using picture-glance
:
Hope it helps
3 Likes
prates
April 10, 2019, 3:44pm
13
I will try something like this, thanks for sharing.
Just to confirm, is the image updated in real time? I mean, when I hit the icon to move the camera, the image keeps still until I click to view the stream, right?
grea09
(Antoine Gréa)
April 23, 2019, 8:00am
14
You’ll need two web browser for doing that. When you trigger the PTZ it will make the camera rotate but the camera card is a picture card with low refresh rate so it will take time. If you access the stream by clicking on the picture on another page it will update in real time or close to it.
hi can you please share the picture glance card code?
jonhgaspar
(João Gaspar)
September 1, 2019, 12:03pm
16
where did you go for the passwords??
empenoso
(Mike)
September 17, 2019, 6:26am
17
jonhgaspar
(João Gaspar)
September 23, 2019, 12:08pm
18
I have the escam qf001I can not know what is the link for ptz to work.
Some help?
jonhgaspar
(João Gaspar)
October 19, 2019, 8:08pm
19
I already find the commands, how do I get them working in HASSIO?
command=ptz_req&req=start¶m=directionleft&channel=1&stream=0
command=ptz_req&req=start¶m=directionright&channel=1&stream=0
command=ptz_req&req=start¶m=directiondown&channel=1&stream=1
command=ptz_req&req=start¶m=directionup&channel=1&stream=1
danielo515
(Daniel Rodríguez Rivero)
January 24, 2020, 8:06am
20
Does anyone know the correct settings for reolink cameras?
which reolink camera do you have?
I have a RLC-23 and I saved preset locations to point at in the camera web interface and setup a restful command to that tell the camera to point at the saved preset locations.
danielo515
(Daniel Rodríguez Rivero)
January 29, 2020, 9:47am
24
that is exactly what I need. Would you mind sharing those rest commands?
danielo515
(Daniel Rodríguez Rivero)
January 29, 2020, 9:54am
25
Ok, I figured it out.
For those who want to know how:
Open the admin page of your camera. Mine was on http://192.168.0.121
Go to the PTZ section and see your pre-configured locations
Open your debug tools of your browser (on mac, F12) and select the network tab
Execute the command to move to default location
Take a look at the network tab to see which url was called
Enjoy
One example:
http://192.168.0.121/cgi-bin/api.cgi?cmd=PtzCtrl&token=xxxxxxx
Glad you figured it.
If you are on use Chrome Ctrl+Shift+i to bring up the network panel.
rest_command:
poolcamptz1:
url: http://192.168.1.128/cgi-bin/api.cgi?cmd=PtzCtrl&token=xxxxxxxxxxxx
method: POST
payload: '[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":1}}]'
"id"1 refers to saved camera position 1
1 Like