dahua icon indicating copy to clipboard operation
dahua copied to clipboard

Core 2022.7 breaks intgration. Cannot log in after update.

Open Mikefila opened this issue 2 years ago • 16 comments

Version of the custom_component

0.9.40

Configuration

configured through UI

Describe the bug

All cameras on integration page show "Retrying setup: Dahua device at 192.168.0.108 isn't fully initialized yet"

All cameras worked prior to update to 2022.7 and works if I roll back to core 2022.6.7

Dahua XVR A72A3A

Debug log

This error originated from a custom integration.

Logger: custom_components.dahua
Source: custom_components/dahua/__init__.py:270
Integration: Dahua (documentation, issues)
First occurred: 2:51:55 PM (40 occurrences)
Last logged: 2:53:19 PM

Unexpected error fetching dahua data: Dahua device at 192.168.0.108 isn't fully initialized yet
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport
    await waiter
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 534, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata
    self._sslobj.do_handshake()
  File "/usr/local/lib/python3.10/ssl.py", line 975, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)

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

Traceback (most recent call last):
  File "/config/custom_components/dahua/__init__.py", line 182, 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 755, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 737, 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.10/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 990, in _wrap_create_connection
    raise ClientConnectorSSLError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host 192.168.0.108:443 ssl:default [[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/dahua/__init__.py", line 270, in _async_update_data
    raise PlatformNotReady("Dahua device at " + self._address + " isn't fully initialized yet")
homeassistant.exceptions.PlatformNotReady: Dahua device at 192.168.0.108 isn't fully initialized yet

This error originated from a custom integration.

Logger: custom_components.dahua
Source: custom_components/dahua/digest.py:46
Integration: Dahua (documentation, issues)
First occurred: 2:51:55 PM (40 occurrences)
Last logged: 2:53:19 PM

Failed to initialize device at 192.168.0.108
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport
    await waiter
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 534, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata
    self._sslobj.do_handshake()
  File "/usr/local/lib/python3.10/ssl.py", line 975, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)

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

Traceback (most recent call last):
  File "/config/custom_components/dahua/__init__.py", line 182, 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 755, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 737, 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.10/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 990, in _wrap_create_connection
    raise ClientConnectorSSLError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host 192.168.0.108:443 ssl:default [[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)]

Mikefila avatar Jul 07 '22 19:07 Mikefila

Same error for me.

lino-silva avatar Jul 11 '22 21:07 lino-silva

Same for me as well

dracon80 avatar Jul 12 '22 04:07 dracon80

Sorry guys been very busy. I'll try to look at this asap.

rroller avatar Jul 12 '22 04:07 rroller

Great - Thanks! :-)

JimGermany avatar Jul 14 '22 08:07 JimGermany

If it helps, this seems to be a similar fix on sonof integration https://github.com/AlexxIT/SonoffLAN/commit/381fd0dd02fc10a02f5344c989e6197411e11169

jjscarafia avatar Jul 19 '22 16:07 jjscarafia

I haven't installed version 2022.7.x yet. Now I have installed the version 2022.7.6 on my test system (Oracle VM) and I don't get any errors? No isn't fully initialized yet error.

All of my four Dahua cameras seem to be working fine. Now I'm confused. :-)

JimGermany avatar Jul 22 '22 15:07 JimGermany

Is it maybe because 2022.7 ships with Python 3.10 which behaves differently?

HolmHomeAssistant avatar Jul 29 '22 05:07 HolmHomeAssistant

Hi guys, any word from rroller about the fix of the Dahua integration? i reset my NVR, redrew all new Intrusion and tripwire lines and still cant get it to communicate with HA. i uninstalled the previous Dahua integration, reincluded the cameras again and now they wont even show a feed or any activity. just shows that the cam became unavailable for some time. But no motion detection or the Crossline or cross region detection is available :( any ideas where the bug can be??? help pleaseeee.

Home Assistant 2022.8.0 Supervisor 2022.07.0 Operating System 8.4 Frontend 20220802.0 - latest

jdvorecky avatar Aug 04 '22 13:08 jdvorecky

@rroller any update?

MosheTzvi avatar Aug 04 '22 14:08 MosheTzvi

I should have time to work on this next week

rroller avatar Aug 04 '22 14:08 rroller

Created pull request #213 to patch the issue.

idekker avatar Aug 14 '22 11:08 idekker

@idekker thanks! Merged and released in https://github.com/rroller/dahua/releases/tag/0.9.41

rroller avatar Aug 14 '22 16:08 rroller

thanks @rroller and @idekker working now!

jjscarafia avatar Aug 14 '22 23:08 jjscarafia

Hi, is this solved? I have still problem login to my Dahua VTO 2211G. Debug:

Logger: custom_components.dahua
Source: custom_components/dahua/digest.py:46
Integration: Dahua (documentation, issues)
First occurred: 18:19:52 (1 occurrences)
Last logged: 18:19:52

Could not connect to Dahua device. For iMou devices see https://github.com/rroller/dahua/issues/6
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport
    await waiter
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 534, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata
    self._sslobj.do_handshake()
  File "/usr/local/lib/python3.10/ssl.py", line 975, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)

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

Traceback (most recent call last):
  File "/config/custom_components/dahua/config_flow.py", line 179, in _test_credentials
    data = await client.get_machine_name()
  File "/config/custom_components/dahua/client.py", line 121, in get_machine_name
    return await self.get("/cgi-bin/magicBox.cgi?action=getMachineName")
  File "/config/custom_components/dahua/client.py", line 755, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 737, 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.10/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/connector.py", line 990, in _wrap_create_connection
    raise ClientConnectorSSLError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host 172.23.23.40:443 ssl:default [[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:997)]
Home Assistant 2022.8.7
Supervisor 2022.08.5
Operating System 8.5
Version of the custom_component
0.9.43

Nortonko avatar Aug 30 '22 16:08 Nortonko

@Nortonko It seems I only fixed it for 1 of the 2 locations. Created another pull request #218 to patch the 2nd location

idekker avatar Aug 30 '22 18:08 idekker

@idekker I manually edited the file "config_flow.py" according to your PR. It works fine now. Thanks.

Nortonko avatar Sep 01 '22 13:09 Nortonko