Open garry0garry opened 2 months ago
Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (camera
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
camera documentation camera source (message by IssueLinks)
Still present in 2024.7.2. continue_on_error
does not work for TimeoutError
.
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 1009, in async_handle_snapshot_service
else await camera.async_camera_image()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/reolink/camera.py", line 151, in async_camera_image
return await self._host.api.get_snapshot(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 2337, in get_snapshot
response = await self.send(body, param, expected_response_type="image/jpeg")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 4417, in send
return await self.send_chunk(body, param, expected_response_type, retry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 4500, in send_chunk
response = await self._aiohttp_session.get(url=self._url, params=param, allow_redirects=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 608, in _request
await resp.start(conn)
File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
message, payload = await protocol.read() # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
await self._waiter
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2731, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 1005, in async_handle_snapshot_service
async with asyncio.timeout(CAMERA_IMAGE_TIMEOUT):
File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
raise TimeoutError from exc_val
TimeoutError
@starkillerOG, is it possible to inform the author of the integration about the problem? The problem is related to polling of Reolink cameras.
Hey there @starkillerog, mind taking a look at this issue as it has been labeled with an integration (reolink
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
reolink documentation reolink source (message by IssueLinks)
@garry0garry I am the author of the Reolink integration, will have a look soon.
Just in case. Home Assistant 2024.7.3.
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 1009, in async_handle_snapshot_service
else await camera.async_camera_image()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/reolink/camera.py", line 151, in async_camera_image
return await self._host.api.get_snapshot(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 2337, in get_snapshot
response = await self.send(body, param, expected_response_type="image/jpeg")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 4417, in send
return await self.send_chunk(body, param, expected_response_type, retry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 4500, in send_chunk
response = await self._aiohttp_session.get(url=self._url, params=param, allow_redirects=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 608, in _request
await resp.start(conn)
File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
message, payload = await protocol.read() # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
await self._waiter
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2731, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 1005, in async_handle_snapshot_service
async with asyncio.timeout(CAMERA_IMAGE_TIMEOUT):
File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
raise TimeoutError from exc_val
TimeoutError
Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (camera
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
camera documentation camera source (message by IssueLinks)
Looks like we don't handle the timeout error here: https://github.com/home-assistant/core/blob/108dc3795eaffbeafed255c14b0c00001b21ca2d/homeassistant/components/camera/__init__.py#L1005
We should raise HomeAssistantError
when catching the timeout.
Side note:
This should also raise HomeAssistantError
instead of logging an error:
https://github.com/home-assistant/core/blob/108dc3795eaffbeafed255c14b0c00001b21ca2d/homeassistant/components/camera/__init__.py#L1024
Right, so the problem is in the camera integration not Reolink specifically.
We have the same problem here, in the create stream camera method: https://github.com/home-assistant/core/blob/108dc3795eaffbeafed255c14b0c00001b21ca2d/homeassistant/components/camera/__init__.py#L602
Right, so the problem is in the camera integration not Reolink specifically.
There's still something that causes the timeout to happen. I don't know if that is benign or not.
There's still something that causes the timeout to happen. I don't know if that is benign or not.
True, but most likely the timeout is just because of a bad wifi/network connection to the camera. Not much I can do about that.
In my case, this is a camera recording of active movement at the time a screenshot is requested. Ethernet without traffic overload and errors.
Reolink RLC-520A, hw IPC_523128M5MP_V2, sw v3.1.0.2368_23062701
We should raise
HomeAssistantError
when catching the timeout.
@MartinHjelmare, is there a plan to fix this issue?
A PR is welcome. I've described what to do above.
The error also occurs on my Nest camera in 2024.7.4:
Logger: homeassistant.components.automation.camera_timelapse
Source: helpers/script.py:527
integration: Automation (documentation, issues)
First occurred: 7:00:10 AM (6 occurrences)
Last logged: 11:30:10 AM
Camera Timelapse: Error executing script. Unexpected error for call_service at pos 3:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 1007, in async_handle_snapshot_service
await _async_get_stream_image(camera, wait_for_next_keyframe=True)
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 231, in _async_get_stream_image
return await camera.stream.async_get_image(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 565, in async_get_image
return await self._keyframe_converter.async_get_image(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/stream/core.py", line 539, in async_get_image
await self._event.wait()
File "/usr/local/lib/python3.12/asyncio/locks.py", line 212, in wait
await fut
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2731, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 663, in _service_handler
response = await self._async_start_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 621, in _async_start_run
script_result = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 652, in _async_run
return await self.script.async_run(script_vars, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1770, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 465, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 529, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 559, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2731, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2774, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 1005, in async_handle_snapshot_service
async with asyncio.timeout(CAMERA_IMAGE_TIMEOUT):
File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
raise TimeoutError from exc_val
TimeoutError
Home Assistant v2024.8.2
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 1009, in async_handle_snapshot_service
else await camera.async_camera_image()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/reolink/camera.py", line 151, in async_camera_image
return await self._host.api.get_snapshot(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 2430, in get_snapshot
response = await self.send(body, param, expected_response_type="image/jpeg")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 4573, in send
return await self.send_chunk(body, param, expected_response_type, retry)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/reolink_aio/api.py", line 4656, in send_chunk
response = await self._aiohttp_session.get(url=self._url, params=param, allow_redirects=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 684, in _request
await resp.start(conn)
File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 999, in start
message, payload = await protocol.read() # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
await self._waiter
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 1005, in async_handle_snapshot_service
async with asyncio.timeout(CAMERA_IMAGE_TIMEOUT):
File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in __aexit__
raise TimeoutError from exc_val
TimeoutError
The problem
There are several cameras with the names cam1 - cam19. I request snapshots from cameras in a loop. Automation:
Script:
If any camera does not respond (
TimeoutError
), the request cycle stops with a timeout error.continue_on_error: true
is specified. I think this is a bug.What version of Home Assistant Core has the issue?
2024.7.0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
Camera
Link to integration documentation on our website
https://www.home-assistant.io/integrations/camera/
Diagnostics information
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response