Core: PTZ actions are not supported on camera 'ONVIF Camera'

Created on 16 Oct 2019  ·  73Comments  ·  Source: home-assistant/core

Home Assistant release with the issue:
0.100.2

Last working Home Assistant release (if known):
Don't know

Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io

Integration:
https://www.home-assistant.io/integrations/onvif/

Description of problem:
When I try to use onvif command/service ( camera.onvif_ptz ) on a compatible camera from the logs I see this warning:
PTZ actions are not supported on camera 'ONVIF Camera'

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):
camera.yaml

- platform: onvif
  host: 10.10.20.128
  username: !secret e1user
  password: !secret e1pwd
  port: 8000

ui-lovelace.yaml

####################################################
#                                                  #
#                    Camera                        #
#                                                  #
####################################################
    # Title of the view. Will be used as the tooltip for tab icon
  - title: Video Camera
    path: VideoCamera
    cards:
      - type: picture-elements
        entity: camera.onvif_camera
        camera_image: camera.onvif_camera
        camera_view: live
        elements:
          - type: icon
            icon: 'mdi:arrow-up'
            style:
              background: 'rgba(255, 255, 255, 0.5)'
              right: 25px
              bottom: 50px
            tap_action:
              action: call-service
              service: camera.onvif_ptz
              service_data:
                tilt: UP
          - type: icon
            icon: 'mdi:arrow-down'
            style:
              background: 'rgba(255, 255, 255, 0.5)'
              right: 25px
              bottom: 0px
            tap_action:
              action: call-service
              service: camera.onvif_ptz
              service_data:
                tilt: DOWN
          - type: icon
            icon: 'mdi:arrow-left'
            style:
              background: 'rgba(255, 255, 255, 0.5)'
              right: 50px
              bottom: 25px
            tap_action:
              action: call-service
              service: camera.onvif_ptz
              service_data:                
                pan: LEFT
          - type: icon
            icon: 'mdi:arrow-right'
            style:
              background: 'rgba(255, 255, 255, 0.5)'
              right: 0px
              bottom: 25px
            tap_action:
              action: call-service
              service: camera.onvif_ptz
              service_data:
                pan: RIGHT
          - type: icon
            icon: 'mdi:arrow-top-left'
            style:
              background: 'rgba(255, 255, 255, 0.5)'
              right: 50px
              bottom: 50px
            tap_action:
              action: call-service
              service: camera.onvif_ptz
              service_data:
                tilt: UP
                pan: LEFT
          - type: icon
            icon: 'mdi:arrow-top-right'
            style:
              background: 'rgba(255, 255, 255, 0.5)'
              right: 0px
              bottom: 50px
            tap_action:
              action: call-service
              service: camera.onvif_ptz
              service_data:
                tilt: UP
                pan: RIGHT
          - type: icon
            icon: 'mdi:arrow-bottom-left'
            style:
              background: 'rgba(255, 255, 255, 0.5)'
              right: 50px
              bottom: 0px
            tap_action:
              action: call-service
              service: camera.onvif_ptz
              service_data:
                tilt: DOWN
                pan: LEFT
          - type: icon
            icon: 'mdi:arrow-bottom-right'
            style:
              background: 'rgba(255, 255, 255, 0.5)'
              right: 0px
              bottom: 0px
            tap_action:
              action: call-service
              service: camera.onvif_ptz
              service_data:
                tilt: DOWN
                pan: RIGHT

Traceback (if applicable):


Home Assistant logs:

2019-10-16 17:45:14 WARNING (MainThread) [homeassistant.components.onvif.camera] PTZ actions are not supported on camera 'ONVIF Camera'
2019-10-16 17:45:15 WARNING (MainThread) [homeassistant.components.onvif.camera] PTZ actions are not supported on camera 'ONVIF Camera'
2019-10-16 17:45:15 WARNING (MainThread) [homeassistant.components.onvif.camera] PTZ actions are not supported on camera 'ONVIF Camera'
2019-10-16 17:45:15 WARNING (MainThread) [homeassistant.components.onvif.camera] PTZ actions are not supported on camera 'ONVIF Camera'

Debug Logs:

2019-10-16 18:19:19 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera platform
2019-10-16 18:19:19 DEBUG (MainThread) [homeassistant.components.onvif.camera] Constructing the ONVIFHassCamera
2019-10-16 18:19:19 DEBUG (MainThread) [homeassistant.components.onvif.camera] Importing dependencies
2019-10-16 18:19:20 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera component
2019-10-16 18:19:20 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera device @ '10.10.20.128:8000'
2019-10-16 18:19:20 DEBUG (MainThread) [homeassistant.components.onvif.camera] Updating service addresses
2019-10-16 18:19:23 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF device management service
2019-10-16 18:19:25 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving current camera date/time
2019-10-16 18:19:25 DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera date/time: 2019-10-16 16:19:23+00:00
2019-10-16 18:19:25 DEBUG (MainThread) [homeassistant.components.onvif.camera] System date/time: 2019-10-16 16:19:25.059212+00:00
2019-10-16 18:19:25 DEBUG (MainThread) [homeassistant.components.onvif.camera] Connecting with ONVIF Camera: 10.10.20.128 on port 8000
2019-10-16 18:19:25 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving profiles
2019-10-16 18:19:26 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieved '2' profiles
2019-10-16 18:19:26 DEBUG (MainThread) [homeassistant.components.onvif.camera] Using profile index '0'
2019-10-16 18:19:26 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving stream uri
2019-10-16 18:19:26 DEBUG (MainThread) [homeassistant.components.onvif.camera] ONVIF Camera Using the following URL for ONVIF Camera: rtsp://<user>:<password>@10.10.20.128:554/h264Preview_01_main
2019-10-16 18:19:26 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF PTZ service
2019-10-16 18:19:26 DEBUG (MainThread) [homeassistant.components.onvif.camera] PTZ is not available
2019-10-16 18:19:26 DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera 'ONVIF Camera' added to hass

Additional information:
When I click on the lovelave button that recall the service camera.onvif_ptz in the logs I have the message 2019-10-16 17:45:15 WARNING (MainThread) [homeassistant.components.onvif.camera] PTZ actions are not supported on camera 'ONVIF Camera'

The Camera is a Reolink E1 Pro and it support Onvif 2.1 with Onvif profile S, I think other Onvif compatible camera have this problem too

onvif

Most helpful comment

@CiquattroFPV
@olijouve

Please see my feedback just posted on #30152

All 73 comments

Hello @CiquattroFPV, I haven't tested it yet, but a PTZ-related fix has been released, it may have resolved if you can test and give us feedback 😀.
PR: #27250

This change is already in 100.2.

I have the same problem with a different camera though.

I have same PTZ issue in HA 0.100.3 using Foscam FI9928P.

This Foscam camera, however, does work fine using the "ONVIF Device Manager" Version 2.2.2.250

Hi @REALogics, I'm working on the fix. But you could test the changes I made to my pull to see if it solves the problem, especially the line:
Replace this:

if self._camera.get_service("ptz", create=False) is None:
    _LOGGER.debug("PTZ is not available")
else:
    self._ptz_service = self._camera.create_ptz_service()
    _LOGGER.debug("Completed set up of the ONVIF camera component")

So:

self._ptz_service = self._camera.get_service("ptz")
if not self._ptz_service:
    _LOGGER.debug("PTZ is not available")

I will do that, hopefully this evening.

On Sun, Oct 27, 2019, 8:46 AM Diefferson Koderer Môro <
[email protected] wrote:

Hi @REALogics https://github.com/REALogics, I'm working on the fix. But
you could test the changes I made to my pull to see if it solves the
problem, especially the line:
Replace this:
"""
if self._camera.get_service("ptz", create=False) is None:
_LOGGER.debug("PTZ is not available")
else:
self._ptz_service = self._camera.create_ptz_service()
_LOGGER.debug("Completed set up of the ONVIF camera component")
"""
for this:
"""
self._ptz_service = self._camera.get_service("ptz")
if not self._ptz_service:
_LOGGER.debug("PTZ is not available")
"""


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/27744?email_source=notifications&email_token=ABYWER2VYQ4ZTQUQAIZPQI3QQWETFA5CNFSM4JBMZHN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECK5RVQ#issuecomment-546691286,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABYWER4SUAFY6QKC6I66GWTQQWETFANCNFSM4JBMZHNQ
.

Thank you for working on this. I'll be so excited to get my camera working!

I am no expert at testing, so not certain I proceeded correctly. I took the current release contents of HA 0.100.3 "onvif" directory and place it in my HA "config/custom_compontents/onvif directory. Then modify the camera.py within that directory as per your instructions above. I then rebooted HA and there were no PTZ setup errors. I then ran PTZ service on camera, and got ERROR: "unexpected keyword argument" see log below:

Rich

2019-10-27 15:07:11 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1843982864] Received {'type': 'call_service', 'domain': 'camera', 'service': 'onvif_ptz', 'service_data': {'entity_id': 'camera.sentinel', 'pan': 'LEFT'}, 'id': 31}
2019-10-27 15:07:11 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=camera, service=onvif_ptz, service_data=entity_id=camera.sentinel, pan=LEFT>
2019-10-27 15:07:11 DEBUG (MainThread) [custom_components.onvif.camera] Calling PTZ | Pan = -1 | Tilt = 0 | Zoom = 0
2019-10-27 15:07:11 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1843982864] {http://www.onvif.org/ver10/schema}Vector2D() got an unexpected keyword argument '_y'. Signature: `x: xsd:float, y: xsd:float, space: xsd:anyURI`
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1233, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/onvif/camera.py", line 107, in async_handle_ptz
    await camera.async_perform_ptz(pan, tilt, zoom)
  File "/config/custom_components/onvif/camera.py", line 332, in async_perform_ptz
    await self._ptz_service.ContinuousMove(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 68, in serialize
    body_value = self.body(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 57, in __call__
    instance = self.type(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 49, in __call__
    return self._value_class(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/valueobjects.py", line 95, in __init__
    items = _process_signature(self._xsd_type, args, kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/valueobjects.py", line 209, in _process_signature
    values = element.parse_kwargs(kwargs, None, available_kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/indicators.py", line 205, in parse_kwargs
    sub_result = element.parse_kwargs(kwargs, elm_name, available_kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 134, in parse_kwargs
    return self.type.parse_kwargs(kwargs, name or self.attr_name, available_kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 309, in parse_kwargs
    value = self._create_object(value, name)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 331, in _create_object
    return self(**value)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 49, in __call__
    return self._value_class(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/valueobjects.py", line 95, in __init__
    items = _process_signature(self._xsd_type, args, kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/valueobjects.py", line 209, in _process_signature
    values = element.parse_kwargs(kwargs, None, available_kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/indicators.py", line 205, in parse_kwargs
    sub_result = element.parse_kwargs(kwargs, elm_name, available_kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/elements/element.py", line 134, in parse_kwargs
    return self.type.parse_kwargs(kwargs, name or self.attr_name, available_kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 309, in parse_kwargs
    value = self._create_object(value, name)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 331, in _create_object
    return self(**value)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/types/complex.py", line 49, in __call__
    return self._value_class(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/valueobjects.py", line 95, in __init__
    items = _process_signature(self._xsd_type, args, kwargs)
  File "/usr/local/lib/python3.7/site-packages/zeep/xsd/valueobjects.py", line 235, in _process_signature
    xsd_type.signature(standalone=False),

@REALogics Did you modify the whole file as it is in Pull or just the line I commented on?

If you have only changed this part, I suggest replacing the whole file with this one:
https://raw.githubusercontent.com/home-assistant/home-assistant/1a5b27c1ab44229c1af916131a3170245eedd8de/homeassistant/components/onvif/camera.py

The error that happened to you is due to line 324 (in the original file, https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/onvif/camera.py#L324), which equals 375 (in the modified file, https://github.com/home-assistant/home-assistant/blob/1a5b27c1ab44229c1af916131a3170245eedd8de/homeassistant/components/onvif/camera.py#L375)

The initialization is working for me now. Unfortunately the PTZ service is not doing anything (moving the camera). There are no errors or warnings in the log regarding onvif though.

2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Constructing the ONVIFHassCamera
2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Importing dependencies
2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera component
2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera device @ '192.168.2.201:888'
2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Updating service addresses
2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF device management service
2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving current camera date/time
2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] TimeZone for date/time: UTC
2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera date/time: 2019-10-25 18:28:32+00:00
2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera date/time in UTC: 2019-10-25 18:28:32+00:00
2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] System date/time: 2019-10-25 18:28:34.352217+00:00
2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Connecting with ONVIF Camera: 192.168.2.201 on port 888
2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving profiles
2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieved '2' profiles
2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] Using profile index '0'
2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] ONVIF Camera Using the following URL for kitchen: rtsp://<user>:<password>@192.168.2.201:88/videoMain
2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF PTZ service
2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving profiles
2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieved '2' profiles
2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] Using profile index '0'
2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] {
    'Name': 'prof0_name',
    'VideoSourceConfiguration': {
        'Name': 'videosource_name0',
        'UseCount': 1,
        'SourceToken': 'videosource_sourcetoken0',
        'Bounds': {
            'x': 1,
            'y': 1,
            'width': 1920,
            'height': 1080
        },
        '_value_1': None,
        'Extension': None,
        'token': 'videosource_token0',
        '_attr_1': {
    }
    },
    'AudioSourceConfiguration': {
        'Name': 'audiosource_name0',
        'UseCount': 4,
        'SourceToken': 'audiosource_sourcetoken0',
        '_value_1': None,
        'token': 'audiosource_token0',
        '_attr_1': {
    }
    },
    'VideoEncoderConfiguration': {
        'Name': 'videoencoder_name0',
        'UseCount': 1,
        'Encoding': 'H264',
        'Resolution': {
            'Width': 1920,
            'Height': 1080
        },
        'Quality': 3.0,
        'RateControl': {
            'FrameRateLimit': 15,
            'EncodingInterval': 1,
            'BitrateLimit': 1024
        },
        'MPEG4': None,
        'H264': {
            'GovLength': 30,
            'H264Profile': 'Baseline'
        },
        'Multicast': {
            'Address': {
                'Type': 'IPv4',
                'IPv4Address': '192.168.2.201',
                'IPv6Address': None
            },
            'Port': 88,
            'TTL': 10,
            'AutoStart': True,
            '_value_1': None,
            '_attr_1': {
        }
        },
        'SessionTimeout': datetime.timedelta(0),
        '_value_1': None,
        'token': 'videoencoder_token0',
        '_attr_1': {
    }
    },
    'AudioEncoderConfiguration': {
        'Name': 'audioencoder_name0',
        'UseCount': 1,
        'Encoding': 'G711',
        'Bitrate': 16,
        'SampleRate': 8000,
        'Multicast': {
            'Address': {
                'Type': 'IPv4',
                'IPv4Address': '192.168.2.201',
                'IPv6Address': None
            },
            'Port': 88,
            'TTL': 0,
            'AutoStart': True,
            '_value_1': None,
            '_attr_1': {
        }
        },
        'SessionTimeout': datetime.timedelta(0, 0, 30000),
        '_value_1': None,
        'token': 'audioencoder_token0',
        '_attr_1': {
    }
    },
    'VideoAnalyticsConfiguration': None,
    'PTZConfiguration': {
        'Name': 'ptzname0',
        'UseCount': 0,
        'NodeToken': 'ptz0',
        'DefaultAbsolutePantTiltPositionSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
        'DefaultAbsoluteZoomPositionSpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
        'DefaultRelativePanTiltTranslationSpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace',
        'DefaultRelativeZoomTranslationSpace': None,
        'DefaultContinuousPanTiltVelocitySpace': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace',
        'DefaultContinuousZoomVelocitySpace': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace',
        'DefaultPTZSpeed': {
            'PanTilt': {
                'x': 0.5,
                'y': 0.5,
                'space': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace'
            },
            'Zoom': None
        },
        'DefaultPTZTimeout': datetime.timedelta(0, 0, 5000),
        'PanTiltLimits': None,
        'ZoomLimits': None,
        'Extension': None,
        'token': 'ptzconf0',
        '_attr_1': {
    }
    },
    'MetadataConfiguration': None,
    'Extension': None,
    'token': 'prof0',
    'fixed': True,
    '_attr_1': {
}
}
2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] Completed set up of the ONVIF camera component
2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera 'kitchen' added to hass

I copied/pasted camera.py from first link you provided. I verified camera.py has the line #375 (not on line #324) : "PanTilt": {"x": pan_val, "y": tilt_val},

Restarted HA and performed PTZ service and got same error.

TypeError: {http://www.onvif.org/ver10/schema}Vector2D() got an unexpected keyword argument '_y'. Signature: `x: xsd:float, y: xsd:float, space: xsd:anyURI`
2019-10-27 17:12:00 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1904763632] Sending {'id': 25, 'type': 'result', 'success': False, 'error': {'code': 'unknown_error', 'message': "{http://www.onvif.org/ver10/schema}Vector2D() got an unexpected keyword argument '_y'. Signature: `x: xsd:float, y: xsd:float, space: xsd:anyURI`"}}
2019-10-27 17:12:03 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.1904763632] Received {'type': 'call_service', 'domain': 'camera', 'service': 'onvif_ptz', 'service_data': {'entity_id': 'camera.sentinel', 'pan': 'RIGHT'}, 'id': 26}
2019-10-27 17:12:03 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=camera, service=onvif_ptz, service_data=entity_id=camera.sentinel, pan=RIGHT>
2019-10-27 17:12:03 DEBUG (MainThread) [custom_components.onvif.camera] Calling PTZ | Pan = 1 | Tilt = 0 | Zoom = 0
2019-10-27 17:12:03 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1904763632] {http://www.onvif.org/ver10/schema}Vector2D() got an unexpected keyword argument '_y'. Signature: `x: xsd:float, y: xsd:float, space: xsd:anyURI

Strange, as you can see, the mistake is because he doesn't try the _y keyword. This also happened, but it was in this line, since the parameters are without the underscore of the beginning

@REALogics Maybe it's conflict between the components. If possible, modify the camera.py file from within the HA component folder. And delete the custom_component you created

@aak038 This is weird. Did you put the correct IDs on the card? Does the camera image appear?

Yes, it streams to HA front end.

On Oct 27, 2019 5:40 PM, "Diefferson Koderer Môro" notifications@github.com
wrote:

The initialization is working for me now. Unfortunately the PTZ service is
not doing anything (moving the camera). There are no errors or warnings in
the log regarding onvif though.

2019-10-25 11:28:33 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Constructing the ONVIFHassCamera
2019-10-25 11:28:33 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Importing dependencies
2019-10-25 11:28:33 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Setting up the ONVIF camera
component
2019-10-25 11:28:33 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Setting up the ONVIF camera device
@ '192.168.2.201:888'
2019-10-25 11:28:33 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Updating service addresses
2019-10-25 11:28:34 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Setting up the ONVIF device
management service
2019-10-25 11:28:34 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Retrieving current camera date/time
2019-10-25 11:28:34 DEBUG (MainThread)
[homeassistant.components.onvif.camera] TimeZone for date/time: UTC
2019-10-25 11:28:34 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Camera date/time: 2019-10-25
18:28:32+00:00
2019-10-25 11:28:34 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Camera date/time in UTC: 2019-10-25
18:28:32+00:00
2019-10-25 11:28:34 DEBUG (MainThread)
[homeassistant.components.onvif.camera] System date/time: 2019-10-25
18:28:34.352217+00:00
2019-10-25 11:28:34 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Connecting with ONVIF Camera:
192.168.2.201 on port 888
2019-10-25 11:28:34 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Retrieving profiles
2019-10-25 11:28:35 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Retrieved '2' profiles
2019-10-25 11:28:35 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Using profile index '0'
2019-10-25 11:28:35 DEBUG (MainThread)
[homeassistant.components.onvif.camera] ONVIF Camera Using the following
URL for kitchen: rtsp://:@192.168.2.201:88/videoMain
2019-10-25 11:28:35 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Setting up the ONVIF PTZ service
2019-10-25 11:28:35 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Retrieving profiles
2019-10-25 11:28:36 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Retrieved '2' profiles
2019-10-25 11:28:36 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Using profile index '0'
2019-10-25 11:28:36 DEBUG (MainThread)
[homeassistant.components.onvif.camera] {
'Name': 'prof0_name',
'VideoSourceConfiguration': {
'Name': 'videosource_name0',
'UseCount': 1,
'SourceToken': 'videosource_sourcetoken0',
'Bounds': {
'x': 1,
'y': 1,
'width': 1920,
'height': 1080
},
'_value_1': None,
'Extension': None,
'token': 'videosource_token0',
'_attr_1': {
}
},
'AudioSourceConfiguration': {
'Name': 'audiosource_name0',
'UseCount': 4,
'SourceToken': 'audiosource_sourcetoken0',
'_value_1': None,
'token': 'audiosource_token0',
'_attr_1': {
}
},
'VideoEncoderConfiguration': {
'Name': 'videoencoder_name0',
'UseCount': 1,
'Encoding': 'H264',
'Resolution': {
'Width': 1920,
'Height': 1080
},
'Quality': 3.0,
'RateControl': {
'FrameRateLimit': 15,
'EncodingInterval': 1,
'BitrateLimit': 1024
},
'MPEG4': None,
'H264': {
'GovLength': 30,
'H264Profile': 'Baseline'
},
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '192.168.2.201',
'IPv6Address': None
},
'Port': 88,
'TTL': 10,
'AutoStart': True,
'_value_1': None,
'_attr_1': {
}
},
'SessionTimeout': datetime.timedelta(0),
'_value_1': None,
'token': 'videoencoder_token0',
'_attr_1': {
}
},
'AudioEncoderConfiguration': {
'Name': 'audioencoder_name0',
'UseCount': 1,
'Encoding': 'G711',
'Bitrate': 16,
'SampleRate': 8000,
'Multicast': {
'Address': {
'Type': 'IPv4',
'IPv4Address': '192.168.2.201',
'IPv6Address': None
},
'Port': 88,
'TTL': 0,
'AutoStart': True,
'_value_1': None,
'_attr_1': {
}
},
'SessionTimeout': datetime.timedelta(0, 0, 30000),
'_value_1': None,
'token': 'audioencoder_token0',
'_attr_1': {
}
},
'VideoAnalyticsConfiguration': None,
'PTZConfiguration': {
'Name': 'ptzname0',
'UseCount': 0,
'NodeToken': 'ptz0',
'DefaultAbsolutePantTiltPositionSpace': '
http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace',
'DefaultAbsoluteZoomPositionSpace': '
http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace',
'DefaultRelativePanTiltTranslationSpace': '
http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace',
'DefaultRelativeZoomTranslationSpace': None,
'DefaultContinuousPanTiltVelocitySpace': '
http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace',
'DefaultContinuousZoomVelocitySpace': '
http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace',
'DefaultPTZSpeed': {
'PanTilt': {
'x': 0.5,
'y': 0.5,
'space': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace'
},
'Zoom': None
},
'DefaultPTZTimeout': datetime.timedelta(0, 0, 5000),
'PanTiltLimits': None,
'ZoomLimits': None,
'Extension': None,
'token': 'ptzconf0',
'_attr_1': {
}
},
'MetadataConfiguration': None,
'Extension': None,
'token': 'prof0',
'fixed': True,
'_attr_1': {
}
}
2019-10-25 11:28:36 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Completed set up of the ONVIF
camera component
2019-10-25 11:28:36 DEBUG (MainThread)
[homeassistant.components.onvif.camera] Camera 'kitchen' added to hass

This is weird. Did you put the correct IDs on the card? Does the camera
image appear?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/home-assistant/issues/27744?email_source=notifications&email_token=ABYWER7CAWRO4CM3D2E2F5DQQYDEJA5CNFSM4JBMZHN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECLIZJQ#issuecomment-546737318,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABYWER4GCAZTHPNOFGN5ZGTQQYDEJANCNFSM4JBMZHNQ
.

@djpremier sorry I was busy these days.. I wasn't able to check github.. yes I can test this evening.. I will keep you updated on my test

Yes, it streams to HA front end. On Oct 27, 2019 5:40 PM, "Diefferson Koderer Môro" notifications@github.com wrote: The initialization is working for me now. Unfortunately the PTZ service is not doing anything (moving the camera). There are no errors or warnings in the log regarding onvif though. 2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Constructing the ONVIFHassCamera 2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Importing dependencies 2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera component 2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF camera device @ '192.168.2.201:888' 2019-10-25 11:28:33 DEBUG (MainThread) [homeassistant.components.onvif.camera] Updating service addresses 2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF device management service 2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving current camera date/time 2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] TimeZone for date/time: UTC 2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera date/time: 2019-10-25 18:28:32+00:00 2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera date/time in UTC: 2019-10-25 18:28:32+00:00 2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] System date/time: 2019-10-25 18:28:34.352217+00:00 2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Connecting with ONVIF Camera: 192.168.2.201 on port 888 2019-10-25 11:28:34 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving profiles 2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieved '2' profiles 2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] Using profile index '0' 2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] ONVIF Camera Using the following URL for kitchen: rtsp://:@192.168.2.201:88/videoMain 2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] Setting up the ONVIF PTZ service 2019-10-25 11:28:35 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving profiles 2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieved '2' profiles 2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] Using profile index '0' 2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] { 'Name': 'prof0_name', 'VideoSourceConfiguration': { 'Name': 'videosource_name0', 'UseCount': 1, 'SourceToken': 'videosource_sourcetoken0', 'Bounds': { 'x': 1, 'y': 1, 'width': 1920, 'height': 1080 }, '_value_1': None, 'Extension': None, 'token': 'videosource_token0', '_attr_1': { } }, 'AudioSourceConfiguration': { 'Name': 'audiosource_name0', 'UseCount': 4, 'SourceToken': 'audiosource_sourcetoken0', '_value_1': None, 'token': 'audiosource_token0', '_attr_1': { } }, 'VideoEncoderConfiguration': { 'Name': 'videoencoder_name0', 'UseCount': 1, 'Encoding': 'H264', 'Resolution': { 'Width': 1920, 'Height': 1080 }, 'Quality': 3.0, 'RateControl': { 'FrameRateLimit': 15, 'EncodingInterval': 1, 'BitrateLimit': 1024 }, 'MPEG4': None, 'H264': { 'GovLength': 30, 'H264Profile': 'Baseline' }, 'Multicast': { 'Address': { 'Type': 'IPv4', 'IPv4Address': '192.168.2.201', 'IPv6Address': None }, 'Port': 88, 'TTL': 10, 'AutoStart': True, '_value_1': None, '_attr_1': { } }, 'SessionTimeout': datetime.timedelta(0), '_value_1': None, 'token': 'videoencoder_token0', '_attr_1': { } }, 'AudioEncoderConfiguration': { 'Name': 'audioencoder_name0', 'UseCount': 1, 'Encoding': 'G711', 'Bitrate': 16, 'SampleRate': 8000, 'Multicast': { 'Address': { 'Type': 'IPv4', 'IPv4Address': '192.168.2.201', 'IPv6Address': None }, 'Port': 88, 'TTL': 0, 'AutoStart': True, '_value_1': None, '_attr_1': { } }, 'SessionTimeout': datetime.timedelta(0, 0, 30000), '_value_1': None, 'token': 'audioencoder_token0', '_attr_1': { } }, 'VideoAnalyticsConfiguration': None, 'PTZConfiguration': { 'Name': 'ptzname0', 'UseCount': 0, 'NodeToken': 'ptz0', 'DefaultAbsolutePantTiltPositionSpace': ' http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace', 'DefaultAbsoluteZoomPositionSpace': ' http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace', 'DefaultRelativePanTiltTranslationSpace': ' http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace', 'DefaultRelativeZoomTranslationSpace': None, 'DefaultContinuousPanTiltVelocitySpace': ' http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace', 'DefaultContinuousZoomVelocitySpace': ' http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace', 'DefaultPTZSpeed': { 'PanTilt': { 'x': 0.5, 'y': 0.5, 'space': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace' }, 'Zoom': None }, 'DefaultPTZTimeout': datetime.timedelta(0, 0, 5000), 'PanTiltLimits': None, 'ZoomLimits': None, 'Extension': None, 'token': 'ptzconf0', '_attr_1': { } }, 'MetadataConfiguration': None, 'Extension': None, 'token': 'prof0', 'fixed': True, '_attr_1': { } } 2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] Completed set up of the ONVIF camera component 2019-10-25 11:28:36 DEBUG (MainThread) [homeassistant.components.onvif.camera] Camera 'kitchen' added to hass This is weird. Did you put the correct IDs on the card? Does the camera image appear? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#27744?email_source=notifications&email_token=ABYWER7CAWRO4CM3D2E2F5DQQYDEJA5CNFSM4JBMZHN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECLIZJQ#issuecomment-546737318>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYWER4GCAZTHPNOFGN5ZGTQQYDEJANCNFSM4JBMZHNQ .

Yes, the camera is streaming. That was working even before this change. Code to call the service:
- entity: camera.kitchen
hold_action:
action: call-service
sercice: camera.onvif_ptz
service_data:
entity_id: camera.kitchen
pan: RIGHT
icon: 'mdi:arrow-right'
name: kitchen_right
tap_action:
action: call-service
sercice: camera.onvif_ptz
service_data:
entity_id: camera.kitchen
pan: RIGHT

@aak038, I don't know if you copied or entered your code. But if you look at the fourth and twelfth line, it says sercice: camera.onvif_ptz, and it should be service: camera.onvif_ptz

Great. That was probably me. If I fix it it looks like this now:
2019-10-28 08:47:55 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving image from camera 'kitchen'
2019-10-28 08:47:57 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving profiles
2019-10-28 08:47:58 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieved '2' profiles
2019-10-28 08:47:58 DEBUG (MainThread) [homeassistant.components.onvif.camera] Using profile index '0'
2019-10-28 08:47:58 DEBUG (MainThread) [homeassistant.components.onvif.camera] Calling PTZ | Pan = 1 | Tilt = 0 | Zoom = 0
2019-10-28 08:47:58 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140149118922592] None
Traceback (most recent call last):
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
connection.context(msg),
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1233, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1258, in _execute_service
await handler.func(service_call)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/homeassistant/components/onvif/camera.py", line 108, in async_handle_ptz
await camera.async_perform_ptz(pan, tilt, zoom)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/homeassistant/components/onvif/camera.py", line 388, in async_perform_ptz
await self._ptz_service.ContinuousMove(req)
File "/home/homeassistant/.homeassistant/deps/lib/python3.6/site-packages/zeep/asyncio/bindings.py", line 13, in send
options["address"], envelope, http_headers
File "/home/homeassistant/.homeassistant/deps/lib/python3.6/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
response = await self.post(address, message, headers)
File "/home/homeassistant/.homeassistant/deps/lib/python3.6/site-packages/zeep/asyncio/transport.py", line 95, in post
proxy=self.proxy,
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages/aiohttp/client.py", line 504, in _request
await resp.start(conn)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages/aiohttp/client_reqrep.py", line 847, in start
message, payload = await self._protocol.read() # type: ignore # noqa
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages/aiohttp/streams.py", line 591, in read
await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: None
2019-10-28 08:48:05 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving image from camera 'kitchen'
2019-10-28 08:48:31 DEBUG (MainThread) [homeassistant.components.onvif.camera] Retrieving image from camera 'kitchen'

@djpremier I have loaded the onvif custom component but when I try to use the PTZ command they don't work and I can see these error messages in the HA logs:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/onvif/camera.py", line 108, in async_handle_ptz
    await camera.async_perform_ptz(pan, tilt, zoom)
  File "/config/custom_components/onvif/camera.py", line 361, in async_perform_ptz
    profile = await self.async_obtain_profile()
  File "/config/custom_components/onvif/camera.py", line 265, in async_obtain_profile
    profiles = await self._media_service.GetProfiles()
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 13, in send
    options["address"], envelope, http_headers
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 95, in post
    proxy=self.proxy,
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service
2019-10-28 17:14:08 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 552, in write_bytes
    await self.body.write(writer)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/payload.py", line 231, in write
    await writer.write(self._value)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 101, in write
    self._write(chunk)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/onvif/camera.py", line 108, in async_handle_ptz
    await camera.async_perform_ptz(pan, tilt, zoom)
  File "/config/custom_components/onvif/camera.py", line 361, in async_perform_ptz
    profile = await self.async_obtain_profile()
  File "/config/custom_components/onvif/camera.py", line 265, in async_obtain_profile
    profiles = await self._media_service.GetProfiles()
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 13, in send
    options["address"], envelope, http_headers
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 95, in post
    proxy=self.proxy,
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service
2019-10-28 17:15:32 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1866095888] [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 552, in write_bytes
    await self.body.write(writer)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/payload.py", line 231, in write
    await writer.write(self._value)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 101, in write
    self._write(chunk)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1233, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/onvif/camera.py", line 108, in async_handle_ptz
    await camera.async_perform_ptz(pan, tilt, zoom)
  File "/config/custom_components/onvif/camera.py", line 361, in async_perform_ptz
    profile = await self.async_obtain_profile()
  File "/config/custom_components/onvif/camera.py", line 265, in async_obtain_profile
    profiles = await self._media_service.GetProfiles()
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 13, in send
    options["address"], envelope, http_headers
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 95, in post
    proxy=self.proxy,
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service

@CiquattroFPV Unfortunately this log does not bring many details, the camera IP and the port is correct? Because it seems to me that he is not getting a connection (at least the camera is not returning when prompted to create media_service)

@aak038 Where did you put your code? Icon and name attributes are not allowed in this part, so you can use them using the @CiquattroFPV code.

(Uma dica, quando compartilhar código, coloque entre ` para linha e 3 vezes para bloco)

The one of the video is this:

aspect_ratio: 50%
camera_image: camera.kitchen
entity: camera.camera_portao
hold_action:
  action: call-service
  service: camera.onvif_ptz
  service_data:
    entity_id: camera.kitchen
    pan: RIGHT
image: 'https://www.home-assistant.io/images/merchandise/shirt-frontpage.png'
tap_action:
  action: call-service
  service: camera.onvif_ptz
  service_data:
    entity_id: camera.kitchen
    pan: LEFT
type: picture-entity
camera_view: live

https://photos.app.goo.gl/v3KBUoWgZmRRtK1t8

@CiquattroFPV Unfortunately this log does not bring many details, the camera IP and the port is correct? Because it seems to me that he is not getting a connection (at least the camera is not returning when prompted to create media_service)

this is my configuration for camera:

- platform: onvif
  host: 10.10.20.128
  username: !secret e1user
  password: !secret e1pwd
  port: 8000

@djpremier The code is from the lovelace UI. I get a message in homeassistant "failed to call service onvif_ptz: none"

@CiquattroFPV Go to: http://10.10.20.128:8000 and check if something like the image is returned (an XML SOAP)
SOAP_XML_ONVIF

@CiquattroFPV Go to: http://10.10.20.128:8000 and check if something like the image is returned (an XML SOAP)
SOAP_XML_ONVIF

yes

image

@CiquattroFPV try again, because there may have been some communication problem

@djpremier I am monitoring the developments here. Let me know if there is any onvif camera testing I could do to assist... and thanks for looking into this... it is appreciated!

My action plan was this:

I have unloaded the onvif component and all the configuration and restarted Home assistant.

After the restart I have added the onvif component to the custom_component folder and re added the onvif configuration to the camera.yaml and restart.

after the restart I have tested the PTZ command but everytime I use the command I have this error in the HA logs.

2019-10-29 12:18:26 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for onvif which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

2019-10-29 12:20:36 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1897102384] [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 552, in write_bytes
    await self.body.write(writer)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/payload.py", line 231, in write
    await writer.write(self._value)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 101, in write
    self._write(chunk)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1233, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/onvif/camera.py", line 108, in async_handle_ptz
    await camera.async_perform_ptz(pan, tilt, zoom)
  File "/config/custom_components/onvif/camera.py", line 361, in async_perform_ptz
    profile = await self.async_obtain_profile()
  File "/config/custom_components/onvif/camera.py", line 265, in async_obtain_profile
    profiles = await self._media_service.GetProfiles()
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 13, in send
    options["address"], envelope, http_headers
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 95, in post
    proxy=self.proxy,
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service
2019-10-29 12:21:53 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 552, in write_bytes
    await self.body.write(writer)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/payload.py", line 231, in write
    await writer.write(self._value)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 101, in write
    self._write(chunk)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/onvif/camera.py", line 108, in async_handle_ptz
    await camera.async_perform_ptz(pan, tilt, zoom)
  File "/config/custom_components/onvif/camera.py", line 361, in async_perform_ptz
    profile = await self.async_obtain_profile()
  File "/config/custom_components/onvif/camera.py", line 265, in async_obtain_profile
    profiles = await self._media_service.GetProfiles()
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 13, in send
    options["address"], envelope, http_headers
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 95, in post
    proxy=self.proxy,
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service
2019-10-29 12:21:53 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 552, in write_bytes
    await self.body.write(writer)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/payload.py", line 231, in write
    await writer.write(self._value)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 101, in write
    self._write(chunk)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/onvif/camera.py", line 108, in async_handle_ptz
    await camera.async_perform_ptz(pan, tilt, zoom)
  File "/config/custom_components/onvif/camera.py", line 361, in async_perform_ptz
    profile = await self.async_obtain_profile()
  File "/config/custom_components/onvif/camera.py", line 265, in async_obtain_profile
    profiles = await self._media_service.GetProfiles()
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 13, in send
    options["address"], envelope, http_headers
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 95, in post
    proxy=self.proxy,
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service
2019-10-29 12:22:08 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1965966288] [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 552, in write_bytes
    await self.body.write(writer)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/payload.py", line 231, in write
    await writer.write(self._value)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 101, in write
    self._write(chunk)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1233, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/onvif/camera.py", line 108, in async_handle_ptz
    await camera.async_perform_ptz(pan, tilt, zoom)
  File "/config/custom_components/onvif/camera.py", line 361, in async_perform_ptz
    profile = await self.async_obtain_profile()
  File "/config/custom_components/onvif/camera.py", line 265, in async_obtain_profile
    profiles = await self._media_service.GetProfiles()
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 13, in send
    options["address"], envelope, http_headers
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 95, in post
    proxy=self.proxy,
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service

@REALogics great! At the moment I'm a little busy with work, but as soon as possible I'll make some changes. For now the tests I needed were to check if the changes allowed me to do the move because it has several other things to implement but I just wanted to move on after knowing that it works.

@REALogics I noticed in your last log that the PTZ version of your camera is the old one. I'll see if there's something specific for her, but could you pass me the model and maybe a camera picture for me to do a more accurate search. Another thing, you set up the card right? If possible forwards code, for example aak038 had two errors.

@REALogics Maybe it's conflict between the components. If possible, modify the camera.py file from within the HA component folder. And delete the custom_component you created

@djpremier I am using a headless Pi for HA. Using the SSH Terminal, I don't see where the onvif component would be found. Sorry, I am not an expert... do you know of a link explaining how to do what you suggest?

@REALogics I noticed in your last log that the PTZ version of your camera is the old one. I'll see if there's something specific for her, but could you pass me the model and maybe a camera picture for me to do a more accurate search. Another thing, you set up the card right? If possible forwards code, for example aak038 had two errors.

@djpremier following is configuration.yaml:

ffmpeg:
stream:
camera:
  - platform: onvif
    name: Sentinel
    host: 192.168.1.24
    username: !secret foscam_name
    password: !secret foscam_password

And the card configuration is:

camera_view: live
entity: camera.sentinel
type: picture-entity
aspect_ratio: 50%

Camera does stream to HA front end, and works with "ONVIF Device Manager" Version 2.2.250"
Camera is updated to latest versions available, which is as follows:

Model: FI9928P
System Firmware Version: 1.11.1.1
Application Firmware Version: 2.74.1.77
Plug-In Version: 5.1.0.13

FI9928P camera specs/pics can be found here and manual says it supports ONVIF 2.2.1

@REALogics Maybe it's conflict between the components. If possible, modify the camera.py file from within the HA component folder. And delete the custom_component you created

@djpremier I am using a headless Pi for HA. Using the SSH Terminal, I don't see where the onvif component would be found. Sorry, I am not an expert... do you know of a link explaining how to do what you suggest?

Try this directory: /usr/src/homeassistant/homeassistant/components/onvif or in /srv/homeassistant/

@REALogics From the configuration you submitted, the port is missing. For Onvif, the default is 5000, but in your camera documentation it says65533, make sure you have changed it, or if it is really incorrect. HA Onvif Documentation: https://www.home-assistant.io/integrations/onvif

About the card, the PTZ control part is missing for what you sent, put it like this:

camera_image: camera.sentinel
camera_view: live
elements:
  - icon: 'mdi:arrow-up'
    style:
      background: 'rgba(255, 255, 255, 0.5)'
      bottom: 50px
      right: 25px
    tap_action:
      action: call-service
      service: camera.onvif_ptz
      service_data:
        tilt: UP
    type: icon
  - icon: 'mdi:arrow-down'
    style:
      background: 'rgba(255, 255, 255, 0.5)'
      bottom: 0px
      right: 25px
    tap_action:
      action: call-service
      service: camera.onvif_ptz
      service_data:
        tilt: DOWN
    type: icon
  - icon: 'mdi:arrow-left'
    style:
      background: 'rgba(255, 255, 255, 0.5)'
      bottom: 25px
      right: 50px
    tap_action:
      action: call-service
      service: camera.onvif_ptz
      service_data:
        pan: LEFT
    type: icon
  - icon: 'mdi:arrow-right'
    style:
      background: 'rgba(255, 255, 255, 0.5)'
      bottom: 25px
      right: 0px
    tap_action:
      action: call-service
      service: camera.onvif_ptz
      service_data:
        pan: RIGHT
    type: icon
  - icon: 'mdi:arrow-top-left'
    style:
      background: 'rgba(255, 255, 255, 0.5)'
      bottom: 50px
      right: 50px
    tap_action:
      action: call-service
      service: camera.onvif_ptz
      service_data:
        pan: LEFT
        tilt: UP
    type: icon
  - icon: 'mdi:arrow-top-right'
    style:
      background: 'rgba(255, 255, 255, 0.5)'
      bottom: 50px
      right: 0px
    tap_action:
      action: call-service
      service: camera.onvif_ptz
      service_data:
        pan: RIGHT
        tilt: UP
    type: icon
  - icon: 'mdi:arrow-bottom-left'
    style:
      background: 'rgba(255, 255, 255, 0.5)'
      bottom: 0px
      right: 50px
    tap_action:
      action: call-service
      service: camera.onvif_ptz
      service_data:
        pan: LEFT
        tilt: DOWN
    type: icon
  - icon: 'mdi:arrow-bottom-right'
    style:
      background: 'rgba(255, 255, 255, 0.5)'
      bottom: 0px
      right: 0px
    tap_action:
      action: call-service
      service: camera.onvif_ptz
      service_data:
        pan: RIGHT
        tilt: DOWN
    type: icon
entity: camera.sentinel
type: picture-elements

Already in the PTZ part, I spoke of the version, because in the log is like "ver10", you can access http://192.168.1.24:PORT, and send a screenshot of XML / SOAP that appears. I left PORT, because I don't know what your camera is using for Onvif.

Log Details (ERROR)
Tue Oct 29 2019 21:10:30 GMT+0100 (Ora standard dell’Europa centrale)
[Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 552, in write_bytes
    await self.body.write(writer)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/payload.py", line 231, in write
    await writer.write(self._value)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 101, in write
    self._write(chunk)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1233, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
    await handler.func(service_call)
  File "/config/custom_components/onvif/camera.py", line 108, in async_handle_ptz
    await camera.async_perform_ptz(pan, tilt, zoom)
  File "/config/custom_components/onvif/camera.py", line 361, in async_perform_ptz
    profile = await self.async_obtain_profile()
  File "/config/custom_components/onvif/camera.py", line 265, in async_obtain_profile
    profiles = await self._media_service.GetProfiles()
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 13, in send
    options["address"], envelope, http_headers
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 107, in post_xml
    response = await self.post(address, message, headers)
  File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/transport.py", line 95, in post
    proxy=self.proxy,
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno None] Can not write request body for http://10.10.20.128:8000/onvif/media_service

@djpremier

That config you provided is pretty cool!!! Now I have buttons on the camera stream! However, I still get the same "unexpected keyword '_y' argument" errors when using the arrows as I did when invoking PTZ through the services of developer tool.

I had manually change the IP port for the camera to 5000. Apparently it is not HTTPS but HTTP.
Executing "http://192.168.1.24:5000" I get the following SOAP response:

<SOAP-ENV:Fault xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl">
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>HTTP GET method not implemented</faultstring>
</SOAP-ENV:Fault>

Thanks @REALogics, but thank the @CiquattroFPV, this code is what he put in creating the issue.

This error seems to me to be because the service being called is the original, but I can't guarantee it. Could you find the original component folder in PI?

@djpremier

I don't know how to find this on PI. I use the PI headless and created the SD using the hass.io image download. I have SSH Terminal add-on, and have looked around in the folders, but don't see where these components would be stored. Can you point me to a link that explains how to do this? Or is it simple for you to explain?

@REALogics, use this command to find onvif folder:
find /* -type d -name onvif

The error is quite similar to the one I get. Are there more changes than just the "camera.py" in the onvif folder? That's the only thing I see changed in #28192.

@djpremier

I only found onvif in the custom_components directory using the find command given. I am a newbie to this... is it possible that components are compiled binaries? Or hidden, like they can be in Windows?

I restarted my PI. Using services for PTZ, and I am not getting the "unexpected keyword '_y' argument" as before. I've attached my log from restart HA with services PTZ call towards end. This should give you the bigger picture.

The error is here (line 7821):

`2019-10-29 22:11:08 ERROR (MainThread)

@aak038 No, the changes are only in camera.py.

@REALogics, Yes, this is mandatory, whenever you modify the codes you have to restart the whole system.

It is dirty to you all, if possible, to follow the HA development process. Because it is possible to modify the files quietly and check if the problem is a change that needs to be made, or just because the module is in conflict.
https://developers.home-assistant.io/docs/en/development_environment.html

I was using "Server Control" tab and "Reload Core". I assumed that since it was recognizing the custom_component, that everything was fine. Possibly it had something to do with the camera card changes you recommended earlier this evening.

But then I did a "homeassistant.restart" service call, and that is when I got different results, but still not working.

It would be nice to set up the HA as a development environment, along with same being the in-service system if possible. I will look into this again, since I would be far more helpful in these situations.

I got to call it a night... thanks for looking into this. I am learning things, which is good!

on the Reolink camera still not supported the PTZ actions

@REALogics I hope you can keep helping us, but for your camera manufacturer, a straightforward integration has been made, maybe it will help you. (Just released in version 0.101)
https://www.home-assistant.io/integrations/foscam/

@djpremier

Unfortunately my camera does not support CGI, which is what this FOSCAM option utilizes.

It supports: HTTP / HTTPS / RTSP / TCP/IP / UDP / FTP / DHCP / DDNS / UPNP / SMTP / ONVIF

@REALogics I tried the code from #28192 and the component does complete the async_setup_ptz. When I issue a pan: LEFT command from the HA dev service tool I am seeing this error:
2019-12-05 01:13:03 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.139946537436048] The specified timeout argument is not within the supported timeout range Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 133, in handle_call_service connection.context(msg), File "/usr/src/homeassistant/homeassistant/core.py", line 1236, in async_call await asyncio.shield(self._execute_service(handler, service_call)) File "/usr/src/homeassistant/homeassistant/core.py", line 1261, in _execute_service await handler.func(service_call) File "/config/custom_components/onvif/camera.py", line 108, in async_handle_ptz await camera.async_perform_ptz(pan, tilt, zoom) File "/config/custom_components/onvif/camera.py", line 392, in async_perform_ptz await self._ptz_service.ContinuousMove(req) File "/usr/local/lib/python3.7/site-packages/zeep/asyncio/bindings.py", line 20, in send return self.process_reply(client, operation_obj, response) File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 195, in process_reply return self.process_error(doc, operation) File "/usr/local/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 362, in process_error subcodes=subcodes, zeep.exceptions.Fault: The specified timeout argument is not within the supported timeout range

FYI, the line numbers in camera.py may be off as I've added a few debug lines to try and narrow down the issue.

Printout of ptz_conf_options:
'{ 'Spaces': { 'AbsolutePanTiltPositionSpace': [ { 'URI': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace', 'XRange': { 'Min': -1.0, 'Max': 1.0 }, 'YRange': { 'Min': -1.0, 'Max': 1.0 } } ], 'AbsoluteZoomPositionSpace': [ { 'URI': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace', 'XRange': { 'Min': 0.0, 'Max': 1.0 } } ], 'RelativePanTiltTranslationSpace': [ { 'URI': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace', 'XRange': { 'Min': -1.0, 'Max': 1.0 }, 'YRange': { 'Min': -1.0, 'Max': 1.0 } } ], 'RelativeZoomTranslationSpace': [ { 'URI': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace', 'XRange': { 'Min': -1.0, 'Max': 1.0 } } ], 'ContinuousPanTiltVelocitySpace': [ { 'URI': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace', 'XRange': { 'Min': -1.0, 'Max': 1.0 }, 'YRange': { 'Min': -1.0, 'Max': 1.0 } } ], 'ContinuousZoomVelocitySpace': [ { 'URI': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace', 'XRange': { 'Min': -1.0, 'Max': 1.0 } } ], 'PanTiltSpeedSpace': [ { 'URI': 'http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace', 'XRange': { 'Min': 0.0, 'Max': 1.0 } } ], 'ZoomSpeedSpace': [ { 'URI': 'http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace', 'XRange': { 'Min': 0.0, 'Max': 1.0 } } ], 'Extension': None, '_attr_1': None }, 'PTZTimeout': { 'Min': datetime.timedelta(seconds=1), 'Max': datetime.timedelta(seconds=250) }, '_value_1': None, 'PTControlDirection': None, 'Extension': None, '_attr_1': None }'

I'm experienced programming, but a novice at python. Any suggestions to get past this timeout error?

Hello, I could solve the problem of PTZ configuration on Hass.io (HA version 0.103.2). It works for Sricam cameras SP017 and SP006. I modify the camera.py file with "custom_components" folder.
The code is here: https://github.com/SaulDiez/customHA/blob/master/onvif/camera.py

I just change methods "setup_ptz"(now is async) and "async_perform_ptz".

My configuration.yaml is:

script:   
     ptz_tilt_up:
        alias: up
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                tilt: 'UP'
    ptz_pan_right:
        alias: right
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                pan: 'RIGHT'
    ptz_tilt_down:
        alias: down
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                tilt: 'DOWN'
    ptz_pan_left:
        alias: left
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                pan: 'LEFT'
    ptz_zoom_in:
        alias: zoom in
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                zoom: 'ZOOM_IN'
    ptz_zoom_out:
        alias: zoom out
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                zoom: 'ZOOM_OUT'

camera:
  - platform: onvif
    name: 'sricam_360'
    host: xxx.xxx.xxx.xxx
    username: 'xxxx'
    password: 'xxxx'

I hope it could help

Hello, I could solve the problem of PTZ configuration on Hass.io (HA versoion 0.103.2). It works for Sricam cameras SP017 and SP006. I modify the camera.py file with "custom_components" folder.
The code is here: https://github.com/SaulDiez/customHA/blob/master/onvif/camera.py

I just change methods "setup_ptz"(now is async) and "async_perform_ptz".

My configuration.yaml is:

script:   
     ptz_tilt_up:
        alias: up
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                tilt: 'UP'
    ptz_pan_right:
        alias: right
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                pan: 'RIGHT'
    ptz_tilt_down:
        alias: down
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                tilt: 'DOWN'
    ptz_pan_left:
        alias: left
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                pan: 'LEFT'
    ptz_zoom_in:
        alias: zoom in
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                zoom: 'ZOOM_IN'
    ptz_zoom_out:
        alias: zoom out
        sequence:
          - service: camera.onvif_ptz
            data:
                entity_id: 'camera.sricam_360'
                zoom: 'ZOOM_OUT'

camera:
  - platform: onvif
    name: 'sricam_360'
    host: xxx.xxx.xxx.xxx
    username: 'xxxx'
    password: 'xxxx'

I hope it could help

I have tried your camera.py and the ptz command are working.. I have only a problem.. when I press the ptz command stops only when it reaches the end of the stroke.. is it possible to set a value for the PTZ action?

Awesome @SaulDiez. Its a first 👍 my Foscam FI9928P ONVIF camera PAN and TILT works !!! Thank you for coming up with this change. As @CiquattroFPV suggested, it would be nice to be able to set positions to move too. I should add that the ZOOM function still does not work for my camera with this change.

Thanks for your anwsers @CiquattroFPV and @REALogics . Until the end of the holidays I will not get access to the cameras, so I can only share some tips and info.

About pan / tilt move, when I press any command the Sricam cameras just move like 5 degrees and stop. There is an option in "_ContinuousMove_" command to stop. If you put this line in "_async_perform_ptz_" method, maybe your camera stops. Try more values for timeout.

        req = self._ptz_service.create_type("ContinuousMove")
        req.ProfileToken = profiles[self._profile_index].token

        #PUT ONLY this line HERE
        req.Timeout = 1

If you want to make other movement actions check this link. In this document you can see all PTZ commands. I try only "_ContinuousMove_" so I don't know too much about other commands. I recommend you to test "_AbsoluteMove_" and "_RelativeMove_" to make movements to an specific position and "_Stop_" to stop all ptz actions. For example, if you want to make an "_AbsoluteMove_" command should be something similar to this with Home Assistant:

        req = self._ptz_service.create_type("AbsoluteMove")
        req.ProfileToken = profiles[self._profile_index].token

        if self._ptz_service:
            pan_val = 1 if pan == DIR_RIGHT else -1 if pan == DIR_LEFT else 0
            tilt_val = 1 if tilt == DIR_UP else -1 if tilt == DIR_DOWN else 0
            req.Position = {"x": pan_val, "y": tilt_val}
            try:
                _LOGGER.debug(
                    "Calling PTZ | Pan = %d | Tilt = %d | ,
                    pan_val,
                    tilt_val,
                )

                await self._ptz_service.AbsoluteMove(req)

About the zoom commands, I have the same problem. Until your answers I thought my cameras can't make zoom, because I also tried with Sricam mobile APP and other apps with no success. The only idea that I have is remove this line in "_async_perform_ptz_" so you only call to the zoom function.

                "PanTilt": {"x": pan_val, "y": tilt_val},

Hi,
I've been working on onvif module since few weeks, already tested req.Timeout = 1 and it does not work, at least on my cam with poor onvif ptz/ver10/wsdl support.

I had added new features to fit more global uses and Hello, I've made a PR for that better PTZ support on ONVIF camera.
https://github.com/home-assistant/home-assistant/pull/30152
Onvif actula integration only supports RelativeMove where it should also supports AbsoluteMove, ContinuousMove and Stop.

For exemple chinese Goke GK7102 based IP camera only supports ContinuousMove mode.

This PR add those new modes with avaibility, per entity to select MovingMode and params in service call.

If you guys could give it a try and report on the PR it would be nice.

Hi,
I've been working on onvif module since few weeks, already tested req.Timeout = 1 and it does not work, at least on my cam with poor onvif ptz/ver10/wsdl support.

I had added new features to fit more global uses and Hello, I've made a PR for that better PTZ support on ONVIF camera.

30152

Onvif actula integration only supports RelativeMove where it should also supports AbsoluteMove, ContinuousMove and Stop.

For exemple chinese Goke GK7102 based IP camera only supports ContinuousMove mode.

This PR add those new modes with avaibility, per entity to select MovingMode and params in service call.

If you guys could give it a try and report on the PR it would be nice.

I have tried your commit and seems working with my camera.. I only have 8/12 seconds of delay when I press the command but it's okay.. it work. :-) thank you @olijouve

@CiquattroFPV, thanks for your feed back.

About the delay, I have the same behaviour but it comes from the stream component, not from the command itself.
I have a timestamp on my video and when i open the rtsp stream from both VLC and HA I can clearly see that 8/12 sec delay are only applied on the HA stream. VLC do live stream.
I didn't look at it but i think it's because HA stream need to transcode rtsp to an mp4 browser friendly format and might create some buffer.

Could you please do me/us a favour by commenting on Pull Request link ?
HA team will need reviewers to validate the PR before accepting to merge it and let it go in a release. The best would be to also report what move mode you are using, you've tested.

@CiquattroFPV, thanks for your feed back.

About the delay, I have the same behaviour but it comes from the stream component, not from the command itself.
I have a timestamp on my video and when i open the rtsp stream from both VLC and HA I can clearly see that 8/12 sec delay are only applied on the HA stream. VLC do live stream.
I didn't look at it but i think it's because HA stream need to transcode rtsp to an mp4 browser friendly format and might create some buffer.

Could you please do me/us a favour by commenting on Pull Request link ?
HA team will need reviewers to validate the PR before accepting to merge it and let it go in a release. The best would be to also report what move mode you are using, you've tested.

Yes for sure it's the stream component
Yes I will comment the pull request without problem.

@olijouve I will try to test this weekend. Thanks for working on this.

@olijouve I will try to test this weekend. Thanks for working on this.

@REALogics If you give me a positive feedback on this I'll proceed to close this issue.. from my side everything is working

@CiquattroFPV
@olijouve

Please see my feedback just posted on #30152

Hi,

nice work @SaulDiez and the others!

I just copied this over the original file within the HA install location. Works. Only thing: it does a complete zoom in and out, would be better it does for 1 or 2 sec and then stops and wait for the next zoom in or out.

I had the same issue when I was trying to script this directly in

https://github.com/FalkTannhaeuser/python-onvif-zeep

Same problem there. By using the continuous mode, it does not stop even when triggering

ptz.Stop({'ProfileToken': request.ProfileToken}) or using your timeout:

PUT ONLY this line HERE

    req.Timeout = 1

I never get that working. Now you can say maybe this cam does not implement is correctly? Maybe but it works when using Zoneminder's onvif netcat "Auto Stop Timeout" setting in the Zoneminder UI... wondering what netcat does different than python-onvif...

/Joerg

I did some quick tests with the original wsdl and soapui and look at the netcat perl code...

Looks like they trigger a extra stop command





000
true


... works like charm for me. Cam stops and does not completely zoom in / out. Maybe this extra web call can be added in case continuous_duration: setting goes not work - like for me.

I did some quick tests with the original wsdl and soapui and look at the netcat perl code...

Looks like they trigger a extra stop command


soap:Header/
soap:Body
wsdl:Stop
wsdl:ProfileToken000
wsdl:Zoomtrue


... works like charm for me. Cam stops and does not completely zoom in / out. Maybe this extra web call can be added in case it does not work - like for me.

@jkoenig72 yes is it what i do after a sleep call in my PR #30152

@olijouve: Hmmm... and that will be triggered by setting it like this, right?

camera:

  • platform: onvif
    name: Onvif1
    host: 192.168.xxx.yyy
    username: xyz
    port: 1234
    continuous_duration: 2
    move_mode: "ContinuousMove"

Hmm... guess not... :-)

ERROR (MainThread) [homeassistant.config] Invalid config for [camera.onvif]: [continuous_duration] is an invalid option for [camera.onvif]. Check: camera.onvif->continuous_duration. (See /home/homeassistant/.homeassistant/configuration.yaml, line 113). Please check the docs at https://home-assistant.io/integrations/onvif/
Jan 07 14:52:28 home hass[20077]: 2020-01-07 14:52:28 ERROR (MainThread) [homeassistant.config] Invalid config for [camera.onvif]: [continuous_duration] is an invalid option for [camera.onvif]. Check: camera.onvif->continuous_duration. (See /home/homeassistant/.homeassistant/configuration.yaml, line 120). Please check the docs at https://home-assistant.io/integrations/onvif/

I added the new parts for the services to:

homeassistant/components/camera/services.yaml

and also to

homeassistant/components/onvif/services.yaml

Anything I missed? For now, I simply copy the old camera.py to camera.py.old and use your pull-request code (in my HA src location, /srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/onvif)

Restart then go to the services dev tool page, from there you will be able to call onvif_ptz with parameters, parameters are documented directly in that page

I did - but the onvif component didi not start as those new parameters cause issues... see errors above.

continuous_duration] is an invalid option for [camera.onvif]

They are set in service calls so delete the additionals parameters you putted in your config:
continuous_duration: 2
move_mode: "ContinuousMove"

Yes, of cause! Sorry... will try that.

I did some quick tests with the original wsdl and soapui and look at the netcat perl code...

Looks like they trigger a extra stop command

http://www.onvif.org/ver20/ptz/wsdl">
soap:Header/
soap:Body
wsdl:Stop
wsdl:ProfileToken000
wsdl:Zoomtrue


... works like charm for me. Cam stops and does not completely zoom in / out. Maybe this extra web call can be added in case it does not work - like for me.

jkoenig72 where do i paste this code? Sory, I'm to noob

Hi, I have done custom_components for onvif and I put the new file in the directory, but I'm not be able to move my Sricam cam by step; if I click in the arrow (lovelance UI) the cam move but stop only when it reaches the end of the stroke. I don't understood to use PAn and TILT by step (I copied the new file camera.py and services.py). Could someone help me?
Thanks

Was this page helpful?
0 / 5 - 0 ratings