rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
369 stars 71 forks source link

Add support for Lorex W452ASD Floodlight Camera #331

Open vittorio88 opened 5 months ago

vittorio88 commented 5 months ago

Using up-to-date Home Assistant, and latest trunk 7b038ee9b98be6756af5f827623eeb988113b114. I am unable to connect to a Lorex W452ASD Floodlight Camera. I am able to sucessfully connect to separate Lorex NVR N845A62 in the same network using the dahua custom component.

While adding the device, the connection times-out. I attempted bumping the timeout from 20 sec to 40 sec in https://github.com/rroller/dahua/blob/main/custom_components/dahua/client.py#L13, but this did not stop the Timeout from occuring. I believe the issue is that the Floodlight never responds to the requests from python, however it does respond when I access it locally using the Desktop application LorexCloud provided by Lorex on port 35000. Port 35000 and 554 TCP are the only ports found open on the device from a port scan.

Here is the Traceback that when it timesout. Any help appreciated!

2024-01-24 17:36:31.510 WARNING (MainThread) [custom_components.dahua] TimeoutError fetching information from http://192.168.33.32:35000/cgi-bin/magicBox.cgi?action=getMachineName
2024-01-24 17:36:31.511 ERROR (MainThread) [custom_components.dahua] Could not connect to Dahua device. For iMou devices see https://github.com/rroller/dahua/issues/6
Traceback (most recent call last):
  File "/config/custom_components/dahua/client.py", line 774, 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 601, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 965, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 622, in read
    await self._waiter
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
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 786, in get
    raise exception
  File "/config/custom_components/dahua/client.py", line 770, in get
    async with async_timeout.timeout(TIMEOUT_SECONDS):
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError
davidew98 commented 1 month ago

go to a browser, goto this address:

http://**camera-ip**/cgi-bin/magicBox.cgi?action=getDeviceType

REPLACE camera-ip with your camera's IP

If that doesn't work change it from HTTP to HTTPS

Submit the response here!

davidew98 commented 1 month ago

FYI the W452ASD mainboard looks the same as the Dahua IPC-L46N mainboard when looking at pics from FCC website. If this is in fact a rebadged IPC-L46N then it's firmware might work on this cam!! try at your own risk.