Onvif camera platform - How to do PTZ?

Ondrej. Tienes que crear una tarjeta en la pantalla inicial de Home Assistant.
Gracias por vuestros ejemplos.
Lo intento y ya os contaré.
(Mi ingles es pobre)

Many thanks for that. Works a treat on my Wansview W9.

Hi All, and how can i add a “night mode” button (infrared on/off)? thanks

With the visual editor I can add ptz functions. But when I use the code above, no icons are displayed on the camera view. What is wrong here.

entities:
- entity: camera.ptz_profile_000
tap_action:
action: call-service
service: onvif.ptz
service_data:
entity_id: camera.ptz_profile_000
pan: LEFT
speed: 0.5
distance: 0.5
move_mode: ContinuousMove
name: Pan Left
show_state: false
icon: ‘mdi:arrow-left’
show_icon: true

Please help.

Using pondguru’s code with my (amcrest) camera entity subbed in, the arrow buttons work for manual movement, but the preset buttons are resulting in an Unknown Error.

2022-03-31 09:37:06 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [2709857808] Unknown Error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 192, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1636, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1673, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 692, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 671, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 949, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 708, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/onvif/camera.py", line 202, in async_perform_ptz
    await self.device.async_perform_ptz(
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 441, in async_perform_ptz
    await ptz_service.GotoPreset(req)
  File "/usr/local/lib/python3.9/site-packages/zeep/proxy.py", line 64, in __call__
    return await self._proxy._binding.send_async(
  File "/usr/local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 164, in send_async
    return self.process_reply(client, operation_obj, response)
  File "/usr/local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 229, in process_reply
    return self.process_error(doc, operation)
  File "/usr/local/lib/python3.9/site-packages/zeep/wsdl/bindings/soap.py", line 391, in process_error
    raise Fault(
zeep.exceptions.Fault: Unknown Error

I definitely have the presets setup on the camera as I can use them in the camera’s web UI. Anyone have ideas about what’s gone wrong?

Thank you so much! This is so helpful. It worked great on my Reolink E1 Pro.

Hey, i know it’s almost 1 year ago, but did you solve your preset problem ?
I’ve just figured out that my camera was caseSensetive.
I had to change preset001 to Preset001 ( capital P )

After reading this thread, I was able to set up pan, tilt, zoom, and preset. When I click on the card, it expands, but the controls don’t appear in that expanded view. Is there any way to make that happen?

Blockquote

Hi everyone!

Blockquote

I am a Software Eng pretty new on this world of HomeAssistant.
I was trying to make work this Tuya PTZ cam, it has onvif so…lets use it.
At least it works flawless, Realtime view, PTZ controls works flawless…the only thing is the ZOOM…does anyone knows how to make it work?
I have created a nice custom card with ptz controls to be used by a Tablet control panel.

type: custom:webrtc-camera
entity: camera.ipcam_profile2
ptz:
  service: onvif.ptz
  data_left:
    entity_id: camera.ipcam_profile2
    pan: LEFT
    speed: 0.5
    distance: 0.1
    move_mode: ContinuousMove
  data_right:
    entity_id: camera.ipcam_profile2
    pan: RIGHT
    speed: 0.5
    distance: 0.1
    move_mode: ContinuousMove
  data_up:
    entity_id: camera.ipcam_profile2
    tilt: UP
    speed: 0.5
    distance: 0.1
    move_mode: ContinuousMove
  data_down:
    entity_id: camera.ipcam_profile2
    tilt: DOWN
    speed: 0.5
    distance: 0.1
    move_mode: ContinuousMove
  data_zoom_in:
    entity_id: camera.ipcam_profile2
    zoom: ZOOM_IN
  data_zoom_out:
    entity_id: camera.ipcam_profile2
    zoom: ZOOM_OUT

Sin título|690x292

3 Likes

Thank you!
Now when someone’s opening my garden shed at night my preset will take care of that👹

Pleas, where do I put this to get a picture with the buttons?
To configuration.yaml, service.yaml or somewhere else?
Thank you.

  1. edit dashboard
    2.add card
    3.select a glance image
  2. select the yaml editor
  3. paste the code
  4. save

Hi Tombon
i have it allready managed.
Only function GoToPrest don’t work for me.
Dziękuję bardzo

I have mine working with a generic IP Camera that is branded at SV3C with only slight modification to the YAML posted above. Pan and Tilt are working. Zoom is not and Presets are not. Working on those commands and then I will post my YAML for the card.

Does anyone know where the command set is for the onvif.ptz service??

Here, under “service onvif.ptz”

Tips for all the newbies like me:

  • The above codes are for a Lovelace picture-glance card: You should use ‘Add card’ on the dashboard and then input the code into the code editor for the card. You must change the entity to your camera stream entity.
  • The presets differ from camera to camera, thus you can try with a random format (e.g., preset = 1) and if the camera does not respond, go to home-assistant.log file in your root folder to view the log (go to the bottom to view the latest logs). The log will tell you which preset locations are available.

I know this is a bit late, but can you post your YAML for the SV3C camera please. I’m just about ready to box it up and send it back otherwise.

Still not managing to get the PTZ working on a Vikylin / hikvision compatible camera. These are the entities that get installed for my camera: Am I missing something?

Hi, I have the exact same issue. I bought Annke WZ500. And those are the only entities I got. What camera did you buy?

Now, I am wondering how to set up the buttons so that you can hold them to activate the PTX presets, I have tried the hold_action instead of the tap action with no success. Has anyone managed?