Onvif - "PTZ is not available on this camera"

Hi guys,

I am trying to integrate my MIBAO camera into HA. I had to load the “DEV” version in order to get it working at all (with other versions, all I got was “400 - Bad request” error), so at least I get a picture in the dashboard and also get the video stream. However, I cannot get PTZ to work - during boot, I see a warning in the logs:

"WARNING (MainThread) [homeassistant.components.onvif.camera] PTZ is not available on this camera"

The relevant part of the config is:
configuration.yaml:

camera:
        platform: onvif
        host: <cam ip>
        port: 80 # (yeah, non-standard)
        username: <camuser>
        password: <campass>
        name: camname

scripts.yaml:

ptz_tilt_up:
  sequence:
    - service: camera.onvif_ptz
      data:
        entity_id: 'camera.camname'
        tilt: 'UP'
ptz_tilt_down:
  sequence:
    - service: camera.onvif_ptz
      data:
        entity_id: 'camera.camname'
        tilt: 'DOWN'
ptz_pan_left:
  sequence:
    - service: camera.onvif_ptz
      data:
        entity_id: 'camera.camname'
        pan: 'LEFT'
ptz_pan_right:
  sequence:
    - service: camera.onvif_ptz
      data:
        entity_id: 'camera.camname'
        pan: 'RIGHT'

Still, the logs say:

INFO (Thread-8) [homeassistant.loader] Loaded onvif from homeassistant.components.onvif
INFO (MainThread) [homeassistant.components.camera] Setting up camera.onvif
DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera platform
DEBUG (MainThread) [homeassistant.components.onvif.camera] Constructing the ONVIFHassCamera
DEBUG (MainThread) [homeassistant.components.onvif.camera] Importing dependencies
DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera component
DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera device @ '<correct_ip_and_port>'
DEBUG (MainThread) [homeassistant.components.onvif.camera] Updating service addresses
DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF device management service
DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving current camera date/time
DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera date/time: 2019-05-08 10:25:18+00:00
DEBUG (MainThread) [homeassistant.components.onvif.camera] System date/time: 2019-05-08 10:25:18.280057+00:00
DEBUG (MainThread) [homeassistant.components.onvif.camera] Obtaining input uri
DEBUG (MainThread) [homeassistant.components.onvif.camera] Connecting with ONVIF Camera: <ip> on port <port>
DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving profiles
DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieved '2' profiles
DEBUG (MainThread) [homeassistant.components.onvif.camera] Using profile index '0'
DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving stream uri
DEBUG (MainThread) [homeassistant.components.onvif.camera] ONVIF Camera Using the following URL for camname: rtsp://<user>:<password>@<ip>:554/live/ch0
DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF PTZ service
WARNING (MainThread) [homeassistant.components.onvif.camera] PTZ is not available on this camera
DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera 'camname' added to hass

Is there anything I can do about it? Onvif Device Manager can do PTZ action on this camera…

Hi,

Thanks for posting.

I can also confirm the issue on my setup: latest beta release on a NUC with a Reolink C1 camera.

There was an issue with one of the beta release where the ONVIF did not worked:

But this is now fixed.

Hi Cox,

many thanks for your response. With the newest DEV version, it is still the same :frowning:

I have the same issue with HA 0.93 Camera is Reolink C1 pro.
I can successfully initialise ONVIF protocol and I see the video. But no PTZ function.
I get the message in log:
WARNING (MainThread) [homeassistant.components.onvif.camera] PTZ is not available on this camera

Same here. Any news ?
Onvif device manager lets me ptz my cams but not ha

Same with version 0.97.2

onvif configured, and streaming is ok, but no PTZ, log shows the known message:
“[homeassistant.components.onvif.camera] PTZ is not available on this camera”

Same problem. Version 0.99.3, hass.io, RP4

Hello,

I’ve made a PR for better PTZ support on ONVIF camera. If any ONVIF user could give it a try it would be nice.


Adding support for other PTZ move modes of http://www.onvif.org/ver10/ptz/wsdl specs
Onvif integration only supports RelativeMove where it should also supports AbsoluteMove, ContinuousMove.

For exemple cheap and recent chinese Goke GK7102 based IP cameras only support ContinuousMove mode.
This PR add those new modes with avaibility, per entity to select MovingMode and params in service call.

I’m looking for early testers so if you know how to test it, do not hesitate to comment the PR. I know it’s working fine for my camera(ContinuousMode), but more feedback on other cameras would be appreciate. And especially for cameras that can support other moving modes.

But i will absolutly not encourage you to modify your system if you’re not sure to be skilled enought to do it and revert change by yourself, in this case just be patient for it to be fully tested, reviewed and merged to a release.

2 Likes

Hi, I’m happy to test and break stuff, can you tell me how to install? (I’m using hassio on debian)
Do I just create a custom_component folder called onvif2 and copy the files from github?

Yes that’s all for this version as it doesn’t add new config parameters.

You could also give a try to that more advanced version that add goto Preset feature. But it will only work if your camera Onvif implementation support it. https://github.com/olijouve/onvif2
Manufactors often implement partial/poor Onvif support in their cameras, for example for being able to says it is Onvif PTZ compatible, only ContinuousMove in mandatory to be implemented…
I have a Foscam and a Besder camera, both can zoom and deal goto preset from their own smartphone app but only Foscam implements presets in the Onvif interface and none of this 2 brands implements zoom in Onvif…
So if goto Preset doesn’t work for you that mean your camera doesn’t implement it in Onvif and there is nothing more to do for making it work. Only pray for a new firmware from your constructor that would support it, and/or write to them and complain about it.

I will give it a go this weekend

Sorry, I get a heap of errors.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 158, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/onvif/camera.py", line 249, in async_setup_platform
    await hass_camera.async_initialize()
  File "/config/custom_components/onvif/camera.py", line 311, in async_initialize
    await self.async_obtain_input_uri()
  File "/config/custom_components/onvif/camera.py", line 453, in async_obtain_input_uri
    stream_uri = await self._media_service.GetStreamUri(req)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 9, in send
    operation, args, kwargs, client=client, options=options
  File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 68, in _create
    serialized = operation_obj.create(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/definitions.py", line 215, in create
    return self.input.serialize(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/messages/soap.py", line 74, in serialize
    self.body.render(body, body_value)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 231, in render
    self._render_value_item(parent, value, render_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 255, in _render_value_item
    return self.type.render(node, value, None, render_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 279, in render
    element.render(parent, element_value, child_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/indicators.py", line 242, in render
    element.render(parent, element_value, child_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 231, in render
    self._render_value_item(parent, value, render_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 255, in _render_value_item
    return self.type.render(node, value, None, render_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 279, in render
    element.render(parent, element_value, child_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/indicators.py", line 242, in render
    element.render(parent, element_value, child_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 231, in render
    self._render_value_item(parent, value, render_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 255, in _render_value_item
    return self.type.render(node, value, None, render_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 279, in render
    element.render(parent, element_value, child_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/indicators.py", line 242, in render
    element.render(parent, element_value, child_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 225, in render
    self.validate(value, render_path)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 280, in validate
    "Missing element %s" % (self.name), path=render_path
zeep.exceptions.ValidationError: Missing element Protocol (GetStreamUri.StreamSetup.Transport.Protocol)

Did you add the 2 new attributes in your config as specified in the repository readme ?

I had the same issue, the key is at the bottom:

Missing element Protocol (GetStreamUri.StreamSetup.Transport.Protocol)

Check your config and make sure “rtsp_transport” is defined :slight_smile:

1 Like

Which particular MIBAO camera do you own?

totally missed that. Tnx. works now, now to get ptz working…

Got a cheap 4mp ptz ali express cam, identifies as IPC > IPD-D41M02-BS series

I’d would like to control my ptz with on screen buttons, can someone point me in the right direction on how to achieve that?

It’s not perfect but for a quick start you can look at foscam integration, there is have a code view sample with button controls embed in stream video, you will have to adapt service call to fit with this component.
You can first look at services ptz in dev tool to play with it and understand how to modify the foscam view.

I am asking because I got a couple of these

and I would like to get them to work with Home Assistant. They are also from MIBAO.

Thank you @olijouve, much appreciated.