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
72.7k stars 30.45k forks source link

ONVIF: Transport Error 404 with gm8135_v2 camera #84551

Closed TechHummel closed 1 year ago

TechHummel commented 1 year ago

The problem

I tried adding a Winees IP camera to my Homeassistant installation with the ONVIF integration. The integration detects the camera and lists it as "IPCAM". When trying to add the camera, I receive an error and the camera cannot be added.

This might be related to https://github.com/home-assistant/core/issues/36523.

The software Agent DVR recognizes the camera and allows streaming the video:

Discovery (GetServices): Camera 3: ONVIF v2.4
Discovery: Camera 3: Using Media Version 1
Discovery: Camera 3: Media available at http://192.168.2.138:80/onvif/media
Discovery: Camera 3: Events available at http://192.168.2.138:80/onvif/events
Discovery: Camera 3: PTZ available at http://192.168.2.138:80/onvif/events
PTZ Discovery: Camera 3: Could not get PTZ config for Onvif Device - using defaults

image

Two video streams are recognized: 1920x1080: rtsp://:PW@192.168.2.138:554/live/XX_p0_XX

I tried using the stream URLs with VLC media player but couldn't get it to work.

What version of Home Assistant Core has the issue?

2022.12.8

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

ONVIF

Link to integration documentation on our website

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

Diagnostics information

home-assistant_onvif_debug-logs.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-12-25 14:37:47.903 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry IPCAM - AE:CA:06:04:XX for onvif
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 372, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/onvif/__init__.py", line 30, in async_setup_entry
    if not await device.async_setup():
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 110, in async_setup
    self.capabilities = await self.async_get_capabilities()
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 283, in async_get_capabilities
    media_capabilities = await media_service.GetServiceCapabilities()
  File "/usr/local/lib/python3.10/site-packages/zeep/proxy.py", line 64, in __call__
    return await self._proxy._binding.send_async(
  File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 164, in send_async
    return self.process_reply(client, operation_obj, response)
  File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 181, in process_reply
    raise TransportError(
zeep.exceptions.TransportError: Server returned HTTP status 404 (no content available)

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @hunterjm, mind taking a look at this issue as it has been labeled with an integration (onvif) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `onvif` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign onvif` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


onvif documentation onvif source (message by IssueLinks)

karolisbu commented 1 year ago

@TechHummel have you got any solution to this problem? I'm having the same issue with Winees IP camera

TechHummel commented 1 year ago

No, no yet!

TechHummel commented 1 year ago

Today, I tested it again with the Homeassistant 2023.4.2, but I am still receiving errors:

When using a different time

2023-04-11 22:03:57.169 DEBUG (MainThread) [homeassistant.components.onvif] Starting ONVIF discovery
2023-04-11 22:04:00.180 DEBUG (MainThread) [homeassistant.components.onvif] Discovered ONVIF devices [{'deviceid': None, 'host': '192.168.2.138', 'name': 'IPCAM', 'port': 80}]
2023-04-11 22:04:07.006 DEBUG (MainThread) [homeassistant.components.onvif] Fetching profiles from ONVIF device {'host': '192.168.2.138',
 'name': 'IPCAM',
 'password': '',
 'port': 80,
 'username': ''}
2023-04-11 22:04:18.187 INFO (MainThread) [homeassistant.setup] Setting up onvif
2023-04-11 22:04:18.187 INFO (MainThread) [homeassistant.setup] Setup of domain onvif took 0.0 seconds
2023-04-11 22:04:19.290 DEBUG (MainThread) [homeassistant.components.onvif] Setting up the ONVIF device management service
2023-04-11 22:04:19.291 DEBUG (MainThread) [homeassistant.components.onvif] Retrieving current device date/time
2023-04-11 22:04:19.740 DEBUG (MainThread) [homeassistant.components.onvif] Device time: {
    'DateTimeType': 'Manual',
    'DaylightSavings': False,
    'TimeZone': {
        'TZ': 'CET-1CEST,M3.5.0,M10.5.0/3'
    },
    'UTCDateTime': {
        'Time': {
            'Hour': 22,
            'Minute': 4,
            'Second': 19
        },
        'Date': {
            'Year': 2023,
            'Month': 4,
            'Day': 11
        }
    },
    'LocalDateTime': {
        'Time': {
            'Hour': 20,
            'Minute': 4,
            'Second': 19
        },
        'Date': {
            'Year': 2023,
            'Month': 4,
            'Day': 11
        }
    },
    'Extension': None,
    '_attr_1': None
}
2023-04-11 22:04:19.745 DEBUG (MainThread) [homeassistant.components.onvif] Device date/time: 2023-04-11 22:04:19+00:00 | System date/time: 2023-04-11 20:04:19.291160+00:00
2023-04-11 22:04:19.746 WARNING (MainThread) [homeassistant.components.onvif] The date/time on IPCAM (UTC) is '2023-04-11 22:04:19+00:00', which is different from the system '2023-04-11 20:04:19.291160+00:00', this could lead to authentication issues
2023-04-11 22:04:19.885 DEBUG (MainThread) [homeassistant.components.onvif] System date (UTC): 2023-04-11 20:04:19.885852+00:00
2023-04-11 22:04:19.888 DEBUG (MainThread) [homeassistant.components.onvif] SetSystemDateAndTime: {
    'DateTimeType': 'Manual',
    'DaylightSavings': True,
    'TimeZone': 'CEST',
    'UTCDateTime': {
        'Time': {
            'Hour': 20,
            'Minute': 4,
            'Second': 19
        },
        'Date': {
            'Year': 2023,
            'Month': 4,
            'Day': 11
        }
    }
}
2023-04-11 22:04:19.914 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry IPCAM - AE:CA:06:04:XX for onvif
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/onvif/__init__.py", line 30, in async_setup_entry
    if not await device.async_setup():
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 99, in async_setup
    await self.async_check_date_and_time()
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 246, in async_check_date_and_time
    await self.async_manually_set_date_and_time()
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 179, in async_manually_set_date_and_time
    await device_mgmt.SetSystemDateAndTime(dt_param)
  File "/usr/local/lib/python3.10/site-packages/zeep/proxy.py", line 64, in __call__
    return await self._proxy._binding.send_async(
  File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 164, in send_async
    return self.process_reply(client, operation_obj, response)
  File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 181, in process_reply
    raise TransportError(
zeep.exceptions.TransportError: Server returned HTTP status 404 (no content available)

and with correct time:

2023-04-11 22:14:18.733 DEBUG (MainThread) [homeassistant.components.onvif] Starting ONVIF discovery
2023-04-11 22:14:21.746 DEBUG (MainThread) [homeassistant.components.onvif] Discovered ONVIF devices [{'deviceid': None, 'host': '192.168.2.138', 'name': 'IPCAM', 'port': 80}]
2023-04-11 22:14:23.917 DEBUG (MainThread) [homeassistant.components.onvif] Fetching profiles from ONVIF device {'host': '192.168.2.138',
 'name': 'IPCAM',
 'password': '',
 'port': 80,
 'username': ''}
2023-04-11 22:14:27.947 DEBUG (MainThread) [homeassistant.components.onvif] Setting up the ONVIF device management service
2023-04-11 22:14:27.947 DEBUG (MainThread) [homeassistant.components.onvif] Retrieving current device date/time
2023-04-11 22:14:27.984 DEBUG (MainThread) [homeassistant.components.onvif] Device time: {
    'DateTimeType': 'Manual',
    'DaylightSavings': False,
    'TimeZone': {
        'TZ': 'UTC-0'
    },
    'UTCDateTime': {
        'Time': {
            'Hour': 20,
            'Minute': 14,
            'Second': 27
        },
        'Date': {
            'Year': 2023,
            'Month': 4,
            'Day': 11
        }
    },
    'LocalDateTime': {
        'Time': {
            'Hour': 20,
            'Minute': 14,
            'Second': 27
        },
        'Date': {
            'Year': 2023,
            'Month': 4,
            'Day': 11
        }
    },
    'Extension': None,
    '_attr_1': None
}
2023-04-11 22:14:27.986 DEBUG (MainThread) [homeassistant.components.onvif] Device date/time: 2023-04-11 20:14:27+00:00 | System date/time: 2023-04-11 20:14:27.948092+00:00
2023-04-11 22:14:28.239 DEBUG (MainThread) [homeassistant.components.onvif] Camera IPCAM info = DeviceInfo(manufacturer='IPCAM', model='IPC', fw_version='v5.3.1.1811211102', serial_number='gm8135_v2', mac='AE:CA:06:04:XX')
2023-04-11 22:14:29.229 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry IPCAM - AE:CA:06:04:XX for onvif
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/onvif/__init__.py", line 30, in async_setup_entry
    if not await device.async_setup():
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 110, in async_setup
    self.capabilities = await self.async_get_capabilities()
  File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 287, in async_get_capabilities
    media_capabilities = await media_service.GetServiceCapabilities()
  File "/usr/local/lib/python3.10/site-packages/zeep/proxy.py", line 64, in __call__
    return await self._proxy._binding.send_async(
  File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 164, in send_async
    return self.process_reply(client, operation_obj, response)
  File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 181, in process_reply
    raise TransportError(
zeep.exceptions.TransportError: Server returned HTTP status 404 (no content available)
TechHummel commented 1 year ago

I tried to investigate the issue further, and I think it is an issue with the library used by the integration (https://github.com/hunterjm/python-onvif-zeep-async) and not the integration itself. Sadly, it seems that it is not possible to open issues for the library.

I wrote a small python script to reproduce the issue without Homeassistant

Python Script ```python3 import onvif import asyncio import os import logging.config logging.config.dictConfig({ 'version': 1, 'formatters': { 'verbose': { 'format': '%(name)s: %(message)s' } }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose', }, }, 'loggers': { 'zeep.transports': { 'level': 'DEBUG', 'propagate': True, 'handlers': ['console'], }, } }) async def main(): mycam = onvif.ONVIFCamera("192.168.2.138", 80, "", "", f"{os.path.dirname(onvif.__file__)}/wsdl/") await mycam.update_xaddrs() # Get Hostname media_service = mycam.create_media_service() media_capabilities = await media_service.GetServiceCapabilities() snapshot = media_capabilities and media_capabilities.SnapshotUri print(snapshot) if __name__ == "__main__": asyncio.run(main()) ```

which produced the same error: zeep.exceptions.TransportError: Server returned HTTP status 404 (no content available)

but also allowed me to enable a higher log level:

Script Logs ```xml zeep.transports: HTTP Post to http://192.168.2.138:80/onvif/device_service: b' \n http://www.onvif.org/ver10/device/wsdl/GetCapabilities urn:uuid:68fe55d1-de18-4a7c-8833-2920b1bd6d8f http://192.168.2.138:80/onvif/device_service r66fzWKAj9dttm5byO/sEXnBDkQ= 1eQKLf4CeKbgM5XMEEDLtw== 2023-04-11T20:34:33+00:00 All ' DEBUG:zeep.transports:HTTP Post to http://192.168.2.138:80/onvif/device_service: b' \n http://www.onvif.org/ver10/device/wsdl/GetCapabilities urn:uuid:68fe55d1-de18-4a7c-8833-2920b1bd6d8f http://192.168.2.138:80/onvif/device_service r66fzWKAj9dttm5byO/sEXnBDkQ= 1eQKLf4CeKbgM5XMEEDLtw== 2023-04-11T20:34:33+00:00 All ' zeep.transports: HTTP Response from http://192.168.2.138:80/onvif/device_service (status: 200): b' http://192.168.2.138:80/onvif/devices false false false false false false false false false false false 2 4 false false false false 0 0 false false false false false false false false http://192.168.2.138:80/onvif/media false true true http://192.168.2.138:80/onvif/ptz ' DEBUG:zeep.transports:HTTP Response from http://192.168.2.138:80/onvif/device_service (status: 200): b' http://192.168.2.138:80/onvif/devices false false false false false false false false false false false 2 4 false false false false 0 0 false false false false false false false false http://192.168.2.138:80/onvif/media false true true http://192.168.2.138:80/onvif/ptz ' zeep.transports: HTTP Post to http://192.168.2.138:80/onvif/media: b'\n http://www.onvif.org/ver10/media/wsdl/GetServiceCapabilities urn:uuid:8a04d82c-4416-4c93-862c-1039fcd4004e http://192.168.2.138:80/onvif/media HF7t+9gWkMI1HjBkgRa4MuD9SR4= Uk/gBe0iIDZ3lMxARQkBag== 2023-04-11T20:34:34+00:00 ' DEBUG:zeep.transports:HTTP Post to http://192.168.2.138:80/onvif/media: b'\n http://www.onvif.org/ver10/media/wsdl/GetServiceCapabilities urn:uuid:8a04d82c-4416-4c93-862c-1039fcd4004e http://192.168.2.138:80/onvif/media HF7t+9gWkMI1HjBkgRa4MuD9SR4= Uk/gBe0iIDZ3lMxARQkBag== 2023-04-11T20:34:34+00:00 ' zeep.transports: HTTP Response from http://192.168.2.138:80/onvif/media (status: 404): b'' DEBUG:zeep.transports:HTTP Response from http://192.168.2.138:80/onvif/media (status: 404): b'' ```

Further, I downloaded an Android app for ONVIF which is working with my IP camera and saved the following debugging log:

Adnroid App Logs ```xml 366 2023-04-11T22:53:34.309+02:00 Logging queue: 0/100 Setup has started. Configuration name: IPCAM, ONVIF device IP address: 192.168.2.138:80 734 2023-04-11T22:53:34.309+02:00 Logging queue: 0/100 doInBackground of RetrieveIPSecurityDeviceInfoAsync() has started. 734 2023-04-11T22:53:34.310+02:00 Logging queue: 0/100 Preparing ONVIF web service query... 734 2023-04-11T22:53:34.310+02:00 Logging queue: 0/100 Retrieving device system date and time. Waiting for response and processing... 1470 2023-04-11T22:53:34.310+02:00 Logging queue: 0/100 Request GetDeviceInformation has been sent. Waiting for response and processing... 1470 2023-04-11T22:53:34.310+02:00 Logging queue: 0/100 Sending command: GetSystemDateAndTime Authentication time:null http://192.168.2.138:80/onvif/device_service 1470 2023-04-11T22:53:34.311+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 1470 2023-04-11T22:53:34.438+02:00 Logging queue: 0/100 SOAP call succeeded. 1470 2023-04-11T22:53:34.438+02:00 Logging queue: 0/100 Processed response: Manual false UTC-0 20 53 33 2023 4 11 20 53 33 2023 4 11 9884 2023-04-11T22:53:34.452+02:00 Logging queue: 0/100 Sending command: GetDeviceInformation Authentication time:Tue Apr 11 22:53:33 GMT+02:00 2023 http://192.168.2.138:80/onvif/device_service 9884 2023-04-11T22:53:34.454+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 9884 2023-04-11T22:53:34.486+02:00 Logging queue: 0/100 SOAP call succeeded. 9884 2023-04-11T22:53:34.486+02:00 Logging queue: 0/100 Processed response: IPCAM IPC v5.3.1.1811211102 gm8135_v2 v4.8.1.1708141702 9884 2023-04-11T22:53:34.490+02:00 Logging queue: 0/100 GetDeviceInformation response has been received and processed 9884 2023-04-11T22:53:34.491+02:00 Logging queue: 0/100 Sending command: GetEndpointReference Authentication time:Tue Apr 11 22:53:33 GMT+02:00 2023 http://192.168.2.138:80/onvif/device_service 9884 2023-04-11T22:53:34.492+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 9884 2023-04-11T22:53:34.516+02:00 Logging queue: 0/100 Exception: HTTP request failed, HTTP status: 404 t6.a: HTTP request failed, HTTP status: 404 at t6.b.d(SourceFile:261) at t6.b.c(Unknown Source:1) at net.biyee.android.onvif.q3.S0(SourceFile:5) at net.biyee.android.onvif.q3.t(Unknown Source:0) at net.biyee.android.onvif.i3.run(Unknown Source:16) at java.lang.Thread.run(Thread.java:1012) 9884 2023-04-11T22:53:34.516+02:00 Logging queue: 0/100 NVT returns an empty response for command: GetEndpointReference 9884 2023-04-11T22:53:34.516+02:00 Logging queue: 0/100 Request GetCapabilities has been sent. Waiting for response and processing... 9884 2023-04-11T22:53:34.516+02:00 Logging queue: 0/100 Sending command: GetCapabilities Authentication time:Tue Apr 11 22:53:33 GMT+02:00 2023 http://192.168.2.138:80/onvif/device_service 19770 2023-04-11T22:53:34.518+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 19770 2023-04-11T22:53:34.553+02:00 Logging queue: 0/100 SOAP call succeeded. 19770 2023-04-11T22:53:34.554+02:00 Logging queue: 0/100 Processed response: http://192.168.2.138:80/onvif/devices false false false false false false false false false false false 2 4 false false false false 0 0 false false false false false false false false http://192.168.2.138:80/onvif/media false true true http://192.168.2.138:80/onvif/ptz 19770 2023-04-11T22:53:34.578+02:00 Logging queue: 0/100 GetCapabilities response has been received and processed 19770 2023-04-11T22:53:34.578+02:00 Logging queue: 0/100 Request GetServices has been sent. Waiting for response and processing... 19770 2023-04-11T22:53:34.578+02:00 Logging queue: 0/100 Sending command: GetServices Authentication time:Tue Apr 11 22:53:33 GMT+02:00 2023 http://192.168.2.138:80/onvif/device_service 19770 2023-04-11T22:53:34.580+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 19770 2023-04-11T22:53:34.703+02:00 Logging queue: 0/100 SOAP call succeeded. 19770 2023-04-11T22:53:34.703+02:00 Logging queue: 0/100 Processed response: http://www.onvif.org/ver10/device/wsdl http://192.168.2.138:80/onvif/devices 2 4 http://www.onvif.org/ver10/media/wsdl http://192.168.2.138:80/onvif/media 2 4 http://www.onvif.org/ver10/events/wsdl http://192.168.2.138:80/onvif/events 2 4 http://www.onvif.org/ver20/analytics/wsdl http://192.168.2.138:80/onvif/analytics 2 0 39542 2023-04-11T22:53:34.708+02:00 Logging queue: 0/100 GetServices response has been received and processed 39542 2023-04-11T22:53:34.708+02:00 Logging queue: 0/100 Updating media profiles... 39542 2023-04-11T22:53:34.708+02:00 Logging queue: 0/100 Sending command: GetProfiles Authentication time:Tue Apr 11 22:53:33 GMT+02:00 2023 http://192.168.2.138:80/onvif/media 39542 2023-04-11T22:53:34.709+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 39542 2023-04-11T22:53:34.862+02:00 Logging queue: 0/100 SOAP call succeeded. 39542 2023-04-11T22:53:34.863+02:00 Logging queue: 0/100 Processed response: MainProfile video_source_cfg 2 video_source_token audio_source_cfg 2 audio_source_token main_video_encoder_cfg 1 H264 1920 1080 30 15 50 2048 60 Baseline IPv4 0.0.0.0 0 3 false PT0H0M0.010S AAC_audio_encoder_cfg 2 AAC 128 16 IPv4 0.0.0.0 0 120 false PT0H12M0S analytics_cfg 2 ptzcfg 0 ptzNodeToken http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace PT0H1M0S http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace -1 1 -1 1 SubProfile video_source_cfg 2 video_source_token audio_source_cfg 2 audio_source_token sub_video_encoder_cfg 1 H264 640 360 30 25 50 1024 200 Baseline IPv4 0.0.0.0 0 3 false PT0H0M0.010S AAC_audio_encoder_cfg 2 AAC 128 16 IPv4 0.0.0.0 0 120 false PT0H12M0S analytics_cfg 2 ptzcfg 0 ptzNodeToken http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace PT0H1M0S http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace -1 1 -1 1 http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace -1 1 79086 2023-04-11T22:53:34.901+02:00 Logging queue: 0/100 Retrieval of media profiles succeeded. 79086 2023-04-11T22:53:34.901+02:00 Logging queue: 0/100 Request GetConfigurations for PTZ has been sent. Waiting for response and processing... 79086 2023-04-11T22:53:34.901+02:00 Logging queue: 0/100 Sending command: GetConfigurations Authentication time:Tue Apr 11 22:53:33 GMT+02:00 2023 http://192.168.2.138:80/onvif/ptz 79086 2023-04-11T22:53:34.902+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 79086 2023-04-11T22:53:34.922+02:00 Logging queue: 0/100 Exception: HTTP request failed, HTTP status: 404 t6.a: HTTP request failed, HTTP status: 404 at t6.b.d(SourceFile:261) at t6.b.c(Unknown Source:1) at net.biyee.android.onvif.q3.S0(SourceFile:5) at net.biyee.android.onvif.q3.t(Unknown Source:0) at net.biyee.android.onvif.i3.run(Unknown Source:16) at java.lang.Thread.run(Thread.java:1012) 79086 2023-04-11T22:53:34.922+02:00 Logging queue: 0/100 NVT returns an empty response for command: GetConfigurations 79086 2023-04-11T22:53:34.922+02:00 Logging queue: 0/100 All information has been retrieved. 79086 2023-04-11T22:53:34.951+02:00 Logging queue: 0/100 Looking for the H.265 streaming profile token for Android hiher than Lollipop. 79086 2023-04-11T22:53:34.952+02:00 Logging queue: 0/100 The streaming profile token is null. Trying to look for the H.264 streaming profile token (This may be redundant for Lollipop and lower). 79086 2023-04-11T22:53:34.959+02:00 Logging queue: 0/100 Sending command: GetSystemDateAndTime Authentication time:null http://192.168.2.138:80/onvif/device_service 79086 2023-04-11T22:53:34.960+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 79086 2023-04-11T22:53:35.082+02:00 Logging queue: 0/100 SOAP call succeeded. 79086 2023-04-11T22:53:35.082+02:00 Logging queue: 0/100 Processed response: Manual false UTC-0 20 53 33 2023 4 11 20 53 33 2023 4 11 79086 2023-04-11T22:53:35.088+02:00 Logging queue: 0/100 Sending command: GetAudioOutputConfigurations Authentication time:Tue Apr 11 22:53:32 GMT+02:00 2023 http://192.168.2.138:80/onvif/media 79086 2023-04-11T22:53:35.089+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 79086 2023-04-11T22:53:35.221+02:00 Logging queue: 0/100 Exception: HTTP request failed, HTTP status: 404 t6.a: HTTP request failed, HTTP status: 404 at t6.b.d(SourceFile:261) at t6.b.c(Unknown Source:1) at net.biyee.android.onvif.q3.S0(SourceFile:5) at net.biyee.android.onvif.q3.t(Unknown Source:0) at net.biyee.android.onvif.i3.run(Unknown Source:16) at java.lang.Thread.run(Thread.java:1012) 79086 2023-04-11T22:53:35.221+02:00 Logging queue: 0/100 NVT returns an empty response for command: GetAudioOutputConfigurations 79086 2023-04-11T22:53:35.221+02:00 Logging queue: 0/100 Backchannel is not available because GetAudioOutputConfigurations is null. 79086 2023-04-11T22:53:35.221+02:00 Logging queue: 0/100 Starting testVideo(). 79086 2023-04-11T22:53:35.222+02:00 Logging queue: 0/100 addressTest returned successfully. 79086 2023-04-11T22:53:35.223+02:00 Logging queue: 0/100 Starting configureDeviceInfo(). 79086 2023-04-11T22:53:35.224+02:00 Logging queue: 0/100 Sending command: GetSystemDateAndTime Authentication time:null http://192.168.2.138:80/onvif/device_service 79086 2023-04-11T22:53:35.225+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 79086 2023-04-11T22:53:35.265+02:00 Logging queue: 0/100 SOAP call succeeded. 79086 2023-04-11T22:53:35.265+02:00 Logging queue: 0/100 Processed response: Manual false UTC-0 20 53 33 2023 4 11 20 53 33 2023 4 11 79086 2023-04-11T22:53:35.273+02:00 Logging queue: 0/100 Sending command: GetStreamUri Authentication time:Tue Apr 11 22:53:33 GMT+02:00 2023 http://192.168.2.138:80/onvif/media 79086 2023-04-11T22:53:35.281+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 79086 2023-04-11T22:53:35.929+02:00 Logging queue: 0/100 SOAP call succeeded. 79086 2023-04-11T22:53:35.931+02:00 Logging queue: 0/100 Processed response: rtsp://192.168.2.138:554/live/1jfiXXX_p0_XXX false false PT0H0M0.200S 79086 2023-04-11T22:53:35.937+02:00 Logging queue: 0/100 Original streaming URL: rtsp://192.168.2.138:554/live/1jfiXXX_p0_XXX 79086 2023-04-11T22:53:35.938+02:00 Logging queue: 0/100 For Streaming URL correction: ONVIF media service address URL host: 192.168.2.138, streaming address URI host: 192.168.2.138 Original streaming URL: rtsp://192.168.2.138:554/live/1jfiXXX_p0_XXX Corrected streaming URL: rtsp://192.168.2.138:554/live/1jfiXXX_p0_XXX 79086 2023-04-11T22:53:35.938+02:00 Logging queue: 0/100 Corrected streaming URL: rtsp://192.168.2.138:554/live/1jfiXXX_p0_XXX 79086 2023-04-11T22:53:36.223+02:00 Logging queue: 0/100 Sending command: GetSystemDateAndTime Authentication time:null http://192.168.2.138:80/onvif/device_service 79086 2023-04-11T22:53:36.224+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 79086 2023-04-11T22:53:36.372+02:00 Logging queue: 0/100 SOAP call succeeded. 79086 2023-04-11T22:53:36.373+02:00 Logging queue: 0/100 Processed response: Manual false UTC-0 20 53 34 2023 4 11 20 53 35 2023 4 11 79086 2023-04-11T22:53:36.377+02:00 Logging queue: 0/100 Sending command: GetSnapshotUri Authentication time:Tue Apr 11 22:53:34 GMT+02:00 2023 http://192.168.2.138:80/onvif/media 79086 2023-04-11T22:53:36.378+02:00 Logging queue: 0/100 Entering SOAP call loop. HTTPS: false 79086 2023-04-11T22:53:36.624+02:00 Logging queue: 0/100 SOAP call succeeded. 79086 2023-04-11T22:53:36.625+02:00 Logging queue: 0/100 Processed response: (null) false false PT0H12M0S ```
bdraco commented 1 year ago

I think its this camera https://www.amazon.com/dp/B0BLRKY4BR?th=1

bdraco commented 1 year ago

camera showed up. going to see if I can fix it now

bdraco commented 1 year ago

The camera doesn't support the media service at all. It doesn't reject it, it just returns a 404 👎

bdraco commented 1 year ago

This camera has very limited onvif support.

Events don't work but I can get snapshots by handling the 404s and letting setup proceed

TechHummel commented 1 year ago

Thanks for looking into this 👍

My camera is this one: https://www.amazon.de/d/B08XVWHHX7 I can gather more information (like soc or a more generic model name) if this would be helpful.

I can also test your pull request in the next couple of days and give you feedback.

bdraco commented 1 year ago

Thanks for the link. I ordered that one. It will take a few days to get here. I’ll give it a spin when it arrives and open another pr if there is anything else I can find a fix for

bdraco commented 1 year ago

Also you’ll likely need to integrate all my open onvif PRs into a branch to get it to work

TechHummel commented 1 year ago

I just upgraded to today's dev docker image, which seems to include all your onvif changes. I can now add the camera to homeassistant via the onvif integration. However, I am still receiving a 404 when the time of my camera and homeassistant is different.

zeep.exceptions.TransportError ``` 2023-04-26 23:43:49.704 INFO (SyncWorker_1) [homeassistant.loader] Loaded onvif from homeassistant.components.onvif 2023-04-26 23:44:00.380 DEBUG (MainThread) [homeassistant.components.onvif] Starting ONVIF discovery 2023-04-26 23:44:03.394 DEBUG (MainThread) [homeassistant.components.onvif] Discovered ONVIF devices [{'deviceid': None, 'host': '192.168.2.138', 'name': 'IPCAM', 'port': 80}] 2023-04-26 23:44:07.622 DEBUG (MainThread) [homeassistant.components.onvif] Fetching profiles from ONVIF device {'host': '192.168.2.138', 'name': 'IPCAM', 'password': '', 'port': 80, 'username': ''} 2023-04-26 23:44:16.475 INFO (MainThread) [homeassistant.setup] Setting up onvif 2023-04-26 23:44:16.476 INFO (MainThread) [homeassistant.setup] Setup of domain onvif took 0.0 seconds 2023-04-26 23:44:16.631 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Setting up the ONVIF device management service 2023-04-26 23:44:16.631 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Retrieving current device date/time 2023-04-26 23:44:17.070 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Device time: { 'DateTimeType': 'Manual', 'DaylightSavings': False, 'TimeZone': { 'TZ': 'CET-1CEST,M3.5.0,M10.5.0/3' }, 'UTCDateTime': { 'Time': { 'Hour': 23, 'Minute': 44, 'Second': 20 }, 'Date': { 'Year': 2023, 'Month': 4, 'Day': 26 } }, 'LocalDateTime': { 'Time': { 'Hour': 21, 'Minute': 44, 'Second': 20 }, 'Date': { 'Year': 2023, 'Month': 4, 'Day': 26 } }, 'Extension': None, '_attr_1': None } 2023-04-26 23:44:17.072 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Device date/time: 2023-04-26 23:44:20+00:00 | System date/time: 2023-04-26 21:44:16.631987+00:00 2023-04-26 23:44:17.072 WARNING (MainThread) [homeassistant.components.onvif] The date/time on IPCAM (UTC) is '2023-04-26 23:44:20+00:00', which is different from the system '2023-04-26 21:44:16.631987+00:00', this could lead to authentication issues 2023-04-26 23:44:17.211 DEBUG (MainThread) [homeassistant.components.onvif] System date (UTC): 2023-04-26 21:44:17.211387+00:00 2023-04-26 23:44:17.214 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: SetSystemDateAndTime: timezone_names:['CEST', 'CET-1CEST,M3.5.0,M10.5.0/3', None] 2023-04-26 23:44:17.215 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: SetSystemDateAndTime: { 'DateTimeType': 'Manual', 'DaylightSavings': True, 'TimeZone': 'CEST', 'UTCDateTime': { 'Time': { 'Hour': 21, 'Minute': 44, 'Second': 17 }, 'Date': { 'Year': 2023, 'Month': 4, 'Day': 26 } } } 2023-04-26 23:44:17.338 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry IPCAM - AE:CA:06:04:79:3D for onvif Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 385, in async_setup result = await component.async_setup_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/onvif/__init__.py", line 38, in async_setup_entry await device.async_setup() File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 101, in async_setup await self.async_check_date_and_time() File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 246, in async_check_date_and_time await self.async_manually_set_date_and_time() File "/usr/src/homeassistant/homeassistant/components/onvif/device.py", line 170, in async_manually_set_date_and_time await device_mgmt.SetSystemDateAndTime(dt_param) File "/usr/local/lib/python3.10/site-packages/zeep/proxy.py", line 64, in __call__ return await self._proxy._binding.send_async( File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 164, in send_async return self.process_reply(client, operation_obj, response) File "/usr/local/lib/python3.10/site-packages/zeep/wsdl/bindings/soap.py", line 181, in process_reply raise TransportError( zeep.exceptions.TransportError: Server returned HTTP status 404 (no content available) ```

Once my camera is added successfully, I am receiving the following error:

BrokenPipeError ``` 2023-04-27 00:02:10.390 DEBUG (MainThread) [homeassistant.components.onvif] Starting ONVIF discovery 2023-04-27 00:02:10.599 WARNING (Thread-9) [daemon] could not find handler for: _handle_probe 2023-04-27 00:02:10.602 WARNING (Thread-7) [daemon] could not find handler for: _handle_probe 2023-04-27 00:02:11.026 WARNING (Thread-9) [daemon] could not find handler for: _handle_resolve 2023-04-27 00:02:11.031 WARNING (Thread-7) [daemon] could not find handler for: _handle_resolve 2023-04-27 00:02:12.292 WARNING (Thread-7) [daemon] could not find handler for: _handle_resolve 2023-04-27 00:02:12.296 WARNING (Thread-9) [daemon] could not find handler for: _handle_resolve 2023-04-27 00:02:13.405 DEBUG (MainThread) [homeassistant.components.onvif] Discovered ONVIF devices [{'deviceid': None, 'host': '192.168.2.138', 'name': 'IPCAM', 'port': 80}] 2023-04-27 00:02:14.376 WARNING (Thread-7) [daemon] could not find handler for: _handle_resolve 2023-04-27 00:02:14.380 WARNING (Thread-9) [daemon] could not find handler for: _handle_resolve 2023-04-27 00:02:16.445 WARNING (Thread-9) [daemon] could not find handler for: _handle_resolve 2023-04-27 00:02:16.448 WARNING (Thread-7) [daemon] could not find handler for: _handle_resolve 2023-04-27 00:02:16.487 DEBUG (MainThread) [homeassistant.components.onvif] Fetching profiles from ONVIF device {'host': '192.168.2.138', 'name': 'IPCAM', 'password': '', 'port': 80, 'username': ''} 2023-04-27 00:02:17.460 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Setting up the ONVIF device management service 2023-04-27 00:02:17.460 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Retrieving current device date/time 2023-04-27 00:02:17.581 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Device time: { 'DateTimeType': 'Manual', 'DaylightSavings': False, 'TimeZone': { 'TZ': 'UTC-0' }, 'UTCDateTime': { 'Time': { 'Hour': 22, 'Minute': 2, 'Second': 19 }, 'Date': { 'Year': 2023, 'Month': 4, 'Day': 26 } }, 'LocalDateTime': { 'Time': { 'Hour': 22, 'Minute': 2, 'Second': 19 }, 'Date': { 'Year': 2023, 'Month': 4, 'Day': 26 } }, 'Extension': None, '_attr_1': None } 2023-04-27 00:02:17.582 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Device date/time: 2023-04-26 22:02:19+00:00 | System date/time: 2023-04-26 22:02:17.461067+00:00 2023-04-27 00:02:17.723 DEBUG (MainThread) [homeassistant.components.onvif] Camera IPCAM info = DeviceInfo(manufacturer='IPCAM', model='IPC', fw_version='v5.3.1.1811211102', serial_number='gm8135_v2', mac='AE:CA:06:04:79:3D') 2023-04-27 00:02:17.769 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Starting PullPoint manager 2023-04-27 00:02:17.769 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Device does not support PullPoint service or has too many subscriptions: Unknown error: Device doesn`t support service: events 2023-04-27 00:02:17.769 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Starting webhook manager 2023-04-27 00:02:17.769 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Registering webhook: onvif_9b62a227caca52bb829674326bea1653 2023-04-27 00:02:17.770 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Registered webhook: onvif_9b62a227caca52bb829674326bea1653 2023-04-27 00:02:17.770 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Creating webhook subscription 2023-04-27 00:02:17.770 DEBUG (MainThread) [homeassistant.components.onvif] IPCAM: Device does not support notification service or too many subscriptions: Unknown error: Device doesn`t support service: notification 2023-04-27 00:02:17.770 DEBUG (MainThread) [homeassistant.components.onvif] Camera IPCAM capabilities = Capabilities(snapshot=False, events=False, ptz=True, imaging=False) 2023-04-27 00:03:41.577 DEBUG (MainThread) [homeassistant.components.onvif] Camera IPCAM profiles = [Profile(index=0, token='MainProfileToken', name='MainProfile', video=Video(encoding='H264', resolution=Resolution(width=1920, height=1080)), ptz=PTZ(continuous=True, relative=True, absolute=False, presets=[]), video_source_token=None), Profile(index=1, token='SubProfileToken', name='SubProfile', video=Video(encoding='H264', resolution=Resolution(width=640, height=360)), ptz=PTZ(continuous=True, relative=True, absolute=True, presets=[]), video_source_token=None)] 2023-04-27 00:03:41.581 INFO (MainThread) [homeassistant.components.button] Setting up button.onvif 2023-04-27 00:03:42.595 INFO (MainThread) [homeassistant.components.camera] Setting up camera.onvif 2023-04-27 00:03:42.635 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new button.onvif entity: button.ipcam_reboot 2023-04-27 00:03:42.638 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new button.onvif entity: button.ipcam_set_system_date_and_time 2023-04-27 00:03:42.652 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new camera.onvif entity: camera.ipcam_mainprofile 2023-04-27 00:03:42.662 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new camera.onvif entity: camera.ipcam_subprofile 2023-04-27 00:05:33.583 DEBUG (MainThread) [homeassistant.components.onvif] Handling mjpeg stream from camera 'IPCAM' 2023-04-27 00:05:33.819 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle result = await result File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 735, in get return await self.handle(request, camera) File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 775, in handle stream = await camera.handle_async_mjpeg_stream(request) File "/usr/src/homeassistant/homeassistant/components/onvif/camera.py", line 195, in handle_async_mjpeg_stream await stream.close() File "/usr/local/lib/python3.10/site-packages/haffmpeg/core.py", line 159, in close await self._loop.run_in_executor(None, _close) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.10/site-packages/haffmpeg/core.py", line 154, in _close self._proc.stdin.write(b"q") BrokenPipeError: [Errno 32] Broken pipe ```

Adding the camera took quite long - the capabilities and the profiles step are more than one minute apart.

I haven't had any chance to research the BrokenPipeError yet, but this would be a separte issue anyway.

bdraco commented 1 year ago

The test camera showed up. I'm going to see if I can replicate the issue now

bdraco commented 1 year ago

So the original one I bought from https://www.amazon.com/dp/B0BLRKY4BR?th=1 is a very similar model but doesn't behave the same.

I can get the setup failure with the one I ordered from amazon.de