rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
382 stars 73 forks source link

Snapshots have become unreliable #290

Open tomlut opened 1 year ago

tomlut commented 1 year ago

After years of reliable service from this integration the snapshot service is now intermittently failing:

This error originated from a custom integration.

Logger: homeassistant.core
Source: custom_components/dahua/client.py:731 
Integration: Dahua 
First occurred: 2 July 2023 at 09:27:18 (2 occurrences) 
Last logged: 14:18:19

Error executing service: <ServiceCall camera.snapshot (c:01H4A6SJ8F7EWHZ8VX8SBQS8KS): entity_id=['camera.front_camera_sub_2'], filename=Template<template=(/config/www/snapshots/front_door.jpg) renders=1>>
Error executing service: <ServiceCall camera.snapshot (c:01H4D9V3Y2Z0YANPH4F6VBYFB4): entity_id=['camera.front_camera_sub_2'], filename=Template<template=(/config/www/snapshots/front_door.jpg) renders=1>>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1928, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1950, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 226, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 811, in entity_service_call
    future.result()  # pop exception if have
    ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1034, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 851, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 930, in async_handle_snapshot_service
    image = await camera.async_camera_image()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/dahua/camera.py", line 243, 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 731, in get_bytes
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 500, message='Internal Server Error', url=URL('http://10.1.1.240:80/cgi-bin/snapshot.cgi?channel=1')

Home Assistant 2023.6.3 Supervisor 2023.06.4 Operating System 10.3 Frontend 20230608.0 - latest Dahua Integration 0.9.47