Onvif.ptz service error

I have several ONVIF IP cameras working well with Synology surveillance station (streaming, ptz, etc.)

I’ve managed to stream the cameras with Home Assistant (Home Assistant 0.107.6 using Hass.io with the HassOS image) with the following configuration (for one of the cameras):
ffmpeg:

camera:

  • platform: onvif
    host: 192.168.1.x
    port: 554
    username: aaa
    password: bbb
  • platform: ffmpeg
    name: cam3
    input: rtsp://aaa:@192.168.1.x:554/

However, I cannot control the cameras with the onvif.ptz service.

For example, for a this camera, with these attributes:
Entity attributes:
access_token: ccc
friendly_name: cam3
entity_picture: /api/camera_proxy/camera.cam3?token=ccc
supported_features: 2

When I invoke the following code:
entity_id: camera.cam3
tilt: UP
distance: 0.1
speed: 0.5
continuous_duration: 0.5
move_mode: ContinuousMove

I receive the error: Failed to call service onvif/ptz. ‘onvif’

With the following log:
‘onvif’
9:59:56 AM – websocket_api (ERROR) - message first occurred at 9:28:24 AM and shows up 10 times

Log Details (ERROR)
Logger: homeassistant.components.websocket_api.http.connection.1779581328
Source: components/onvif/camera.py:121
Integration: websocket_api (documentation, issues)
First occurred: 9:28:24 AM (10 occurrences)
Last logged: 9:59:56 AM

‘onvif’
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 134, in handle_call_service
connection.context(msg),
File “/usr/src/homeassistant/homeassistant/core.py”, line 1234, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File “/usr/src/homeassistant/homeassistant/core.py”, line 1257, in _execute_service
await handler.func(service_call)
File “/usr/src/homeassistant/homeassistant/components/onvif/camera.py”, line 121, in async_handle_ptz
all_cameras = hass.data[ONVIF_DATA][ENTITIES]
KeyError: 'onvif

Any ideas how to solve the error?

Even if pan tilt and zoom values are optionnals, attributes must be present :

entity_id: camera.cam3
tilt: UP
pan:
zoom:
distance: 0.1
speed: 0.5
continuous_duration: 0.5
move_mode: ContinuousMove

Thanks. However, the suggested code is not working:

Failed to call service onvif/ptz. value is not allowed for dictionary value @ data[‘pan’]

Log Details (ERROR)

Logger: homeassistant.components.websocket_api.http.connection.1747680368
Source: core.py:1212
Integration: websocket_api
First occurred: 1:20:35 PM (1 occurrences)
Last logged: 1:20:35 PM

value is not allowed for dictionary value @ data[‘pan’]

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 134, in handle_call_service connection.context(msg), File “/usr/src/homeassistant/homeassistant/core.py”, line 1212, in async_call processed_data = handler.schema(service_data) File “/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py”, line 272, in call return self._compiled([], data) File “/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py”, line 594, in validate_dict return base_validate(path, iteritems(data), out) File “/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py”, line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: value is not allowed for dictionary value @ data[‘pan’]

If I add RIGHT/LEFT to the pan attribute, the error is with the zoom attribute.

As the cameras does not support zoom, if I add ZOOM_IN, the following error is logged:

Log Details (ERROR)

Logger: homeassistant.components.websocket_api.http.connection.1747680368
Source: components/onvif/camera.py:121
Integration: websocket_api
First occurred: 1:22:48 PM (1 occurrences)
Last logged: 1:22:48 PM

‘onvif’

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py”, line 134, in handle_call_service connection.context(msg), File “/usr/src/homeassistant/homeassistant/core.py”, line 1234, in async_call await asyncio.shield(self._execute_service(handler, service_call)) File “/usr/src/homeassistant/homeassistant/core.py”, line 1257, in _execute_service await handler.func(service_call) File “/usr/src/homeassistant/homeassistant/components/onvif/camera.py”, line 121, in async_handle_ptz all_cameras = hass.data[ONVIF_DATA][ENTITIES] KeyError: ‘onvif’