rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
383 stars 74 forks source link

Error while adding DVR DH-XVR5116HE-4KL-I2 #248

Open cdeharo opened 1 year ago

cdeharo commented 1 year ago

Is your feature request related to a problem? Please describe. I can't configure the integration to use the DVR DH-XVR5116HE-4KL-I2. I keep receiving the error Username, Password or Address is wrong Tried with the local IP address and HTTP and HTTPS ports.

Describe the solution you'd like Be able to use the DH-XVR5116HE-4KL-I2 with this integration.

Describe alternatives you've considered n/a

Additional context

DVR:

cdeharo commented 1 year ago

Hi, I think that my problem could be related with the TLS certificate I'm using in the DVR. It is generated by the out of the box CA that the DVR includes:

This error originated from a custom integration.

Logger: custom_components.dahua
Source: custom_components/dahua/digest.py:46
Integration: Dahua (documentation, issues)
First occurred: 20:16:11 (3 occurrences)
Last logged: 20:19:47

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.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 628, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 668, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.xxx.xxx', 82)

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 188, 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 764, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 746, 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.11/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1209, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.xxx.xxx:82 ssl:default [Connect call failed ('192.168.xxx.xxx', 82)]

Given that this is a local network connection, is there a way to disable the TLS verification?

Thanks.