home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.66k stars 30.8k forks source link

PTZ actions are not supported on camera 'ONVIF Camera' #27744

Closed CiquattroFPV closed 4 years ago

CiquattroFPV commented 5 years ago

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

djpremier commented 5 years ago

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

aak038 commented 5 years ago

This change is already in 100.2.

I have the same problem with a different camera though.

ReaLogics commented 5 years ago

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

djpremier commented 5 years ago

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")
ReaLogics commented 5 years ago

I will do that, hopefully this evening.

On Sun, Oct 27, 2019, 8:46 AM Diefferson Koderer Môro < notifications@github.com 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 .

ReaLogics commented 5 years ago

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),
djpremier commented 5 years ago

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

djpremier commented 5 years ago

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)

aak038 commented 5 years ago

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
ReaLogics commented 5 years ago

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
djpremier commented 5 years ago

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

djpremier commented 5 years ago

@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 commented 5 years ago

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

ReaLogics commented 5 years ago

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 .

CiquattroFPV commented 5 years ago

@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

aak038 commented 5 years ago

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:

djpremier commented 5 years ago

@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

aak038 commented 5 years ago

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'

CiquattroFPV commented 5 years ago

@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
djpremier commented 5 years ago

@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)

djpremier commented 5 years ago

@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 commented 5 years ago

@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
aak038 commented 5 years ago

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

djpremier commented 5 years ago

@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 commented 5 years ago

@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

djpremier commented 5 years ago

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

ReaLogics commented 5 years ago

@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!

CiquattroFPV commented 5 years ago

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
djpremier commented 5 years ago

@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.

djpremier commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

@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

djpremier commented 5 years ago

@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/

djpremier commented 5 years ago

@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.

CiquattroFPV commented 5 years ago
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
ReaLogics commented 5 years ago

@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>
djpremier commented 5 years ago

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?

ReaLogics commented 5 years ago

@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?

djpremier commented 5 years ago

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

aak038 commented 5 years ago

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.

ReaLogics commented 5 years ago

@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)

djpremier commented 5 years ago

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

djpremier commented 5 years ago

@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

ReaLogics commented 5 years ago

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!

CiquattroFPV commented 5 years ago

on the Reolink camera still not supported the PTZ actions

djpremier commented 5 years ago

@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/

ReaLogics commented 5 years ago

@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

Troublebrewing commented 4 years ago

@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?

SaulDiez commented 4 years ago

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

CiquattroFPV commented 4 years ago

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?