Hello
WIth the help of some hardcore Googling i found and midified this card, so it works with my OnVif PTZ camera.
It pans and tilts, and work as expected.
My only problem is, i have no idea how to SET the position presets.
I have read the OnVif documentation 20 times, but i simply don’t understand how to define the preset position.
I can see there is a preset command i can put in, but where in the code, and how to activate that command, so a preset with a specific number is stored i have nu idea.
As you can see i have made two buttons that calls preset 1 and 2, but for now they don’t do anything.
type: picture-glance
entities:
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
pan: LEFT
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Pan Left
show_state: false
icon: mdi:arrow-left
show_icon: true
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
tilt: UP
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Tilt Up
icon: mdi:arrow-up
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
tilt: DOWN
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Tilt Down
icon: mdi:arrow-down
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
pan: RIGHT
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Pan Right
icon: mdi:arrow-right
show_icon: true
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
preset: 1
speed: 0.5
distance: 0.5
move_mode: GotoPreset
name: Preset 1
show_state: false
icon: mdi:numeric-1-box
show_icon: true
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
preset: 2
speed: 0.5
distance: 0.5
move_mode: GotoPreset
name: Preset 2
show_state: false
icon: mdi:numeric-2-box
show_icon: true
camera_image: camera.skurcam_mainstreamprofile
camera_view: live
1 Like
Ok - i searched for hours, and finally learned, that you cant define the preset positions in the Homa Assistant ONVIF integration. You have to do it in the Cameras web interface or API.
Turns out the the command line:
preset: 1
Was my problem. My camera defines that postions as Preset001, so it was supposed to be:
preset: Preset001
Here is my complete code, for other that might struggle:
type: picture-glance
entities:
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
pan: LEFT
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Pan Left
show_state: false
icon: mdi:arrow-left
show_icon: true
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
tilt: UP
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Tilt Up
icon: mdi:arrow-up
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
tilt: DOWN
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Tilt Down
icon: mdi:arrow-down
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
pan: RIGHT
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Pan Right
icon: mdi:arrow-right
show_icon: true
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
preset: Preset001
speed: 0.5
distance: 0.5
move_mode: GotoPreset
name: Preset 1
show_state: false
icon: mdi:numeric-1-box
show_icon: true
- entity: camera.skurcam_mainstreamprofile
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.skurcam_mainstreamprofile
preset: Preset002
speed: 0.5
distance: 0.5
move_mode: GotoPreset
name: Preset 2
show_state: false
icon: mdi:numeric-2-box
show_icon: true
camera_image: camera.skurcam_mainstreamprofile
camera_view: live
1 Like
carlosead
(Carlos Dias)
May 17, 2023, 3:33am
3
Hello Pete
Well, not sure if you remember details about this post… LOL
Please, how did you discovered your camera defines position as Preset001? I still didn’t understand how my camera saves its presets, so I’m facing the same problem that you was…
Thanks for any help
I used a freeware program called ONVIF device manager. In there under the camera and PTZ control, you can see the preset naming convention
1 Like
carlosead
(Carlos Dias)
November 30, 2023, 2:50pm
5
Hello again Pete… how long… LOL…
After you indicated me this app (thanks a lot), I bought two cameras from China (the last one few days ago…). Both of them gave me the same problem, it doesn’t show me the “official” preset list from the camera.
In App I can save new presets, but when I restart the camera I lost they.
So now I have two questions: First, did you had this kind of problem too? Second: could you please indicate your camera model (maybe show me where to buy)?
Thanks a lot…
jarionut
(Jarionut)
September 24, 2024, 4:27pm
6
Thank you so much, you example was the most useful from all over the internet and worked like a charm. your explanation also is very clear and helpful
jarionut
(Jarionut)
September 24, 2024, 5:02pm
7
My working code inspired from this example with zoom and presets. Thank you again
type: picture-glance
entities:
- entity: camera.hikvision_ds_2de4225iw_de_mainstream
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.hikvision_ds_2de4225iw_de_mainstream
pan: LEFT
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Pan Left
show_state: false
icon: mdi:arrow-left
show_icon: true
- entity: camera.hikvision_ds_2de4225iw_de_mainstream
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.hikvision_ds_2de4225iw_de_mainstream
tilt: UP
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Tilt Up
icon: mdi:arrow-up
- entity: camera.hikvision_ds_2de4225iw_de_mainstream
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.hikvision_ds_2de4225iw_de_mainstream
tilt: DOWN
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Tilt Down
icon: mdi:arrow-down
- entity: camera.hikvision_ds_2de4225iw_de_mainstream
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.hikvision_ds_2de4225iw_de_mainstream
pan: RIGHT
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: Pan Right
icon: mdi:arrow-right
show_icon: true
- entity: camera.hikvision_ds_2de4225iw_de_mainstream
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.hikvision_ds_2de4225iw_de_mainstream
preset: 1
speed: 0.1
distance: 0.5
move_mode: GotoPreset
name: Home
show_state: false
icon: mdi:home
show_icon: true
- entity: camera.hikvision_ds_2de4225iw_de_mainstream
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.hikvision_ds_2de4225iw_de_mainstream
preset: 2
speed: 0.5
distance: 0.5
move_mode: GotoPreset
name: Preset 2
show_state: false
icon: mdi:numeric-2-box
show_icon: true
- entity: camera.hikvision_ds_2de4225iw_de_mainstream
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.hikvision_ds_2de4225iw_de_mainstream
preset: 3
speed: 0.5
distance: 0.5
move_mode: GotoPreset
name: 3
show_state: false
icon: mdi:numeric-3-box
show_icon: true
- entity: camera.hikvision_ds_2de4225iw_de_mainstream
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.hikvision_ds_2de4225iw_de_mainstream
zoom: ZOOM_IN
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: zoomin
show_state: false
icon: mdi:magnify-plus
show_icon: true
- entity: camera.hikvision_ds_2de4225iw_de_mainstream
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.hikvision_ds_2de4225iw_de_mainstream
zoom: ZOOM_OUT
speed: 1
distance: 0.3
move_mode: ContinuousMove
name: zoomout
show_state: false
icon: mdi:magnify-minus
show_icon: true
camera_image: camera.hikvision_ds_2de4225iw_de_mainstream
camera_view: live
1 Like
Fr4nkR
(Frank Reiß)
December 10, 2024, 12:01pm
8
Thank you, I tried a lot of code snippets…this has ended my wanderings