rroller / dahua

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

Snapshots slow or unreliable #127

Closed bagobones closed 2 years ago

bagobones commented 2 years ago

Version of the custom_component

0.9.30

Configuration


N/A

Describe the bug

Amcrest AD110, I have it setup to generate a homekit Doorbell object AND I have tried it setup with a snapshot service call to a file and then a push notification in HA.

VS using the camera via the synology surveillance station integration the "snapshot" functionality seems to be fine but using this component slower or unreliable.

I have the video stream set to preload and it loads MUCH faster and more reliably than it did in surveillance station.

It looks like when doing a direct snapshot request on the Mainstream it is also erroring sometimes, example provided below.

Debug log


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 98, 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 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, 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 629, in get
    return await self.handle(request, camera)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 647, in handle
    image = await _async_get_image(
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 166, in _async_get_image
    image_bytes = await camera.async_camera_image(
  File "/config/custom_components/dahua/camera.py", line 219, in async_camera_image
    return await self._coordinator.client.async_get_snapshot(self._channel_number)
  File "/config/custom_components/dahua/client.py", line 66, in async_get_snapshot
    return await self.get_bytes(url)
  File "/config/custom_components/dahua/client.py", line 633, 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: 400, message='Bad Request', url=URL('http://192.168.103.8:80/cgi-bin/snapshot.cgi?channel=1')
rroller commented 2 years ago

Which camera model is this?

bagobones commented 2 years ago

Which camera model is this?

Amcrest AD110 doorbell

bagobones commented 2 years ago

Might be related to this https://github.com/home-assistant/core/issues/59378

bagobones commented 2 years ago

After more testing and removing everything from my config it appears that Surveillance station was bogging the camera down. I change it from having its "Native Amcrest" connection to just RTSP the camera now runs at normal speed in HA and Surveillance station and snapshots seem to be working regularly..

This camera seems to be VERY underpowered and sensitive to requests.