rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
398 stars 80 forks source link

AD410 integration setup succeeds, but events do not fire and logs show 401 error #201

Closed coooooooooosh closed 2 years ago

coooooooooosh commented 2 years ago

Edit: Quick edit to also say that this integration looks awesome and thank you for all of your hard work in getting it up and running!

Dahua integration installed via HACS

I'm able to add my Amcrest username, password, and address during setup, select ports and events (left these w/ default values), name the device, and setup "succeeds". The dialogue box closed, and I am able to view the device and its entities (image attachment 1) and add them to dashboards (image attachment 2).

However, none of the entities update when they should (ie I go outside and ring the doorbell/move around, which trigger events in the Amcrest app but not in HA).

After adding the debugger, I get the following error:

This error originated from a custom integration.

Logger: aiohttp.server
Source: custom_components/dahua/client.py:722
Integration: Dahua (documentation, issues)
First occurred: 1:42:32 PM (32 occurrences)
Last logged: 2:06:33 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/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 60, 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 79, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 220, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 741, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 759, in handle
    image = await _async_get_image(
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 179, in _async_get_image
    if image_bytes := await camera.async_camera_image(
  File "/config/custom_components/dahua/camera.py", line 233, in async_camera_image
    return await self._coordinator.client.async_get_snapshot(self._channel_number)
  File "/config/custom_components/dahua/client.py", line 74, in async_get_snapshot
    return await self.get_bytes(url)
  File "/config/custom_components/dahua/client.py", line 722, in get_bytes
    response.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 401, message='Unauthorized', url=URL('http://192.168.100.2:80/cgi-bin/snapshot.cgi?channel=1')

Screen Shot 2022-07-07 at 2 13 05 PM Screen Shot 2022-07-07 at 2 18 50 PM

coooooooooosh commented 2 years ago

Fixed - for this camera, it allowed me to sign in with the username admin as opposed to my actual amcrest username