rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
404 stars 82 forks source link

0.9.66 Failed to Sync Device State #414

Closed robertvorthman closed 2 weeks ago

robertvorthman commented 3 weeks ago

One of my cameras stopped working after upgrading to 0.9.66. It's possible the camera stopped working on an earlier version and I did not notice. I'm getting a 403 forbidden error. My other 3 cameras work fine.

Camera model: IPC-T54IR-ZE

Logs

2024-11-04 14:41:23.572 DEBUG (MainThread) [custom_components.dahua] ClientError fetching information from http://192.168.1.62:80/cgi-bin/configManager.cgi?action=getConfig&name=DisableEventNotify
2024-11-04 14:41:23.574 WARNING (MainThread) [custom_components.dahua] Failed to sync device state for 192.168.1.62. See README to enable debug logs to get full exception
2024-11-04 14:41:23.574 DEBUG (MainThread) [custom_components.dahua] Failed to sync device state for 192.168.1.62
aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url='http://192.168.1.62/cgi-bin/configManager.cgi?action=getConfig&name=DisableEventNotify'
2024-11-04 14:41:56.984 DEBUG (MainThread) [custom_components.dahua] ClientError fetching information from http://192.168.1.62:80/cgi-bin/configManager.cgi?action=getConfig&name=DisableEventNotify

2024-11-04 14:41:23.574 DEBUG (MainThread) [custom_components.dahua] Failed to sync device state for 192.168.1.62
Traceback (most recent call last):
  File "/config/custom_components/dahua/__init__.py", line 334, in _async_update_data
    results = await asyncio.gather(*coros)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dahua/client.py", line 655, in async_get_event_notifications
    return await self.get(url)
           ^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dahua/client.py", line 812, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 795, in get
    response.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1121, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url='http://192.168.1.62/cgi-bin/configManager.cgi?action=getConfig&name=DisableEventNotify'
2024-11-04 14:41:23.576 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 8.573 seconds (success: False)

Debug

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1061, in _wrap_create_connection
    sock = await aiohappyeyeballs.start_connection(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 104, in start_connection
    raise first_exception
  File "/usr/local/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 82, in start_connection
    sock = await _connect_sock(
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 174, in _connect_sock
    await loop.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.62', 80)

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

Traceback (most recent call last):
  File "/config/custom_components/dahua/__init__.py", line 197, in _async_update_data
    self._max_streams = await self.client.get_max_extra_streams() + 1
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dahua/client.py", line 141, in get_max_extra_streams
    result = await self.get("/cgi-bin/magicBox.cgi?action=getProductDefinition&name=MaxExtraStream")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dahua/client.py", line 812, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 794, in get
    response = await auth.request("GET", url)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dahua/digest.py", line 46, in request
    response = await self.session.request(method, url, headers=headers, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 659, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 557, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1002, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1336, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1305, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1076, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.1.62:80 ssl:default [Connect call failed ('192.168.1.62', 80)]
Screenshot 2024-11-04 at 2 56 08 PM
sebastiannowicki commented 3 weeks ago

same issue for my 2 Dahua cams. Other Dahua cams works fine.

lsantoro commented 2 weeks ago

Same issue with my 3 IP cameras DH-IPC-HFW3849T1-AS-PV-S3 with the latest firmware: 2.840.0000000.28.R, build: 2024-08-07. Last working version: 0.9.63.

The S5 version DH-IPC-HFW3849T1-AS-PV works correctly with 0.9.64, 0.9.65 e 0.9.66.

jgverweij commented 2 weeks ago

Also 0.9.66 fails with camera IPC-T5442T-ZEB - Firmware: 2.820.15OG004.0.R,build:2021-07-29 So does 0.9.64 But 0.9.63 is fine

jgverweij commented 2 weeks ago

error.log

brianegge commented 2 weeks ago

Same with my four dahua cameras. My three amcrest and eight lorex ones are fine.

sasukebinbin commented 2 weeks ago

Same with my four Imou cameras connected with dahua NVR.

sasukebinbin commented 2 weeks ago

Just made a test, the last working version is 0.9.60

nasixi commented 2 weeks ago

I also have this issue on one camera, a IPC-HDW5541H-AS-PV with firmware V2.840.0000000.28.R, Build Date: 2024-08-07

I keep seeing disconnections to this camera in Frigate, and looking at the camera's system logs, I'm seeing lots of Abort, errors.

I'm not sure if the camera is at fault or not, but there seems to be some connection issue with the integration.

I've reverted to 0.9.63 and can now connect to that camera, although the integration is showing as 9.60?

LX1974 commented 2 weeks ago

same here, lost connection to nvr cams

cMoi421 commented 2 weeks ago

Même problème avec caméra IPC-HDBW3541E-AS Micrologiciel : 2.800.0000000.14.R,build:2020-06-12 dernière version fonctionnelle 0.9.63.

longzheng commented 2 weeks ago

Same error with DH-IPC-HDW3641TMP-AS-0280B-AUS

2024-11-07 16:14:26.436 DEBUG (MainThread) [custom_components.dahua] Failed to sync device state for 192.168.1.26
Traceback (most recent call last):
  File "/config/custom_components/dahua/__init__.py", line 334, in _async_update_data
    results = await asyncio.gather(*coros)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dahua/client.py", line 655, in async_get_event_notifications
    return await self.get(url)
           ^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dahua/client.py", line 812, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 795, in get
    response.raise_for_status()
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1157, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url='http://192.168.1.26/cgi-bin/configManager.cgi?action=getConfig&name=DisableEventNotify'
awreeoh commented 2 weeks ago

same

2024-11-07 13:19:02.954 DEBUG (MainThread) [custom_components.dahua] Failed to sync device state for 192.168.50.134 Traceback (most recent call last): File "/config/custom_components/dahua/init.py", line 334, in _async_update_data results = await asyncio.gather(*coros) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/dahua/client.py", line 655, in async_get_event_notifications return await self.get(url) ^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/dahua/client.py", line 812, in get raise exception File "/config/custom_components/dahua/client.py", line 795, in get response.raise_for_status() File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1157, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url='http://192.168.50.134/cgi-bin/configManager.cgi?action=getConfig&name=DisableEventNotify'

robertvorthman commented 2 weeks ago

My logs show a "403 Forbidden" response but all the other logs I have seen on related issues show a "400 Bad Request" response, not sure if that matters.

MNOiSY commented 2 weeks ago

Same. Last version to work for all cams was 0.9.62

dt54171 commented 2 weeks ago

Got the same error for Dahua NVR after upgrade up to the latest version.

jrb80 commented 2 weeks ago

Same issue for me on v0.9.66, rolled back to v0.9.62 and now it works fine.

dt54171 commented 2 weeks ago

What is the best way to rollback to v0.9.62 ?

brianegge commented 2 weeks ago

@jakon89 can you take a look. It seems your change last week broke many cameras.

jrb80 commented 2 weeks ago

@jakon89 when I manually call the API GET http://x.x.x.x:80/cgi-bin/configManager.cgi?action=getConfig&name=DisableEventNotify it returns 400 Bad Request

rroller commented 2 weeks ago

Released 0.9.67. Hopefully this works. All thanks to @brianegge in https://github.com/rroller/dahua/pull/419 Can you all try it?

longzheng commented 2 weeks ago

Can confirm 0.9.67 works with DH-IPC-HDW3641TMP-AS-0280B-AUS

robertvorthman commented 2 weeks ago

0.9.67 fixed the issue for me! Thanks, @brianegge!

brianegge commented 2 weeks ago

Glad it worked. I don't know how to test hacs components with my local setup. I used to run homeassistant core, and could just copy my component into the custom components directory. Now I'm running HAOS - I don't know if people typically copy stuff over ssh, or setup a custom repo in HACS. In either case, I'm glad the fix worked.

cMoi421 commented 2 weeks ago

version 9.0.68 functional on IPC-HDBW3541E-AS Firmware: 2.800.0000000.14.R, build:2020-06-12. only human and vehicle detection are not functional.Envoyé à partir de Outlook pour AndroidDe : Brian Egge @.>Envoyé : lundi, novembre 11, 2024 2:14:47 PMÀ : rroller/dahua @.>Cc : cMoi421 @.>; Comment @.>Objet : Re: [rroller/dahua] 0.9.66 Failed to Sync Device State (Issue #414) Glad it worked. I don't know how to test hacs components with my local setup. I used to run homeassistant core, and could just copy my component into the custom components directory. Now I'm running HAOS - I don't know if people typically copy stuff over ssh, or setup a custom repo in HACS. In either case, I'm glad the fix worked.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>