core icon indicating copy to clipboard operation
core copied to clipboard

Camera Snapshot Service not working anymore

Open thecobra666 opened this issue 1 year ago • 26 comments

The problem

Before the latest update, this was working. After it's failing.

What version of Home Assistant Core has the issue?

2023.10.2

What was the last working version of Home Assistant Core?

2023.9.x

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Generic Camera

Link to integration documentation on our website

No response

Diagnostics information


Logger: homeassistant.helpers.script.websocket_api_script
Source: helpers/script.py:468
First occurred: 17:13:12 (1 occurrences)
Last logged: 17:13:12

websocket_api script: Error executing script. Unexpected error for call_service at pos 1:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 963, in async_handle_snapshot_service
    else await camera.async_camera_image()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/generic/camera.py", line 197, in async_camera_image
    response = await async_client.get(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1757, in get
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1530, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1617, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
    response = await self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
    response = await self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1719, in _send_single_request
    response = await transport.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 366, in handle_async_request
    resp = await self._pool.handle_async_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 262, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request
    response = await connection.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
    return await self._connection.handle_async_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 133, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 111, in handle_async_request
    ) = await self._receive_response_headers(**kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 176, in _receive_response_headers
    event = await self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 212, in _receive_event
    data = await self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 34, in read
    return await self._stream.receive(max_bytes=max_bytes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1103, in receive
    await self._protocol.read_event.wait()
  File "/usr/local/lib/python3.11/asyncio/locks.py", line 213, 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 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 959, in async_handle_snapshot_service
    async with asyncio.timeout(CAMERA_IMAGE_TIMEOUT):
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

-----------

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/connection.py:268
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 17:13:12 (1 occurrences)
Last logged: 17:13:12

[140062799866304] Error handling message: Timeout (timeout) Shane from 192.168.1.149 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36)

---------------

Logger: aiohttp.server
Source: /usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py:403
First occurred: 17:12:46 (1 occurrences)
Last logged: 17:12:46

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 150, in handle
    result = handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/emulated_hue/hue_api.py", line 238, in get
    return self.json(create_list_of_entities(self.config, request))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/emulated_hue/hue_api.py", line 876, in create_list_of_entities
    json_response[config.entity_id_to_number(entity_id)] = state_to_json(
                                                           ^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/emulated_hue/hue_api.py", line 761, in state_to_json
    state_dict = get_entity_state_dict(config, state)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/emulated_hue/hue_api.py", line 655, in get_entity_state_dict
    return _build_entity_state_dict(entity)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/emulated_hue/hue_api.py", line 687, in _build_entity_state_dict
    data[STATE_BRIGHTNESS] = hass_to_hue_brightness(
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/emulated_hue/hue_api.py", line 890, in hass_to_hue_brightness
    return max(1, round((value / 255) * HUE_API_STATE_BRI_MAX))
                         ~~~~~~^~~~~
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

Example YAML snippet

alias: 3.1.N. Brievenbus geopend cam ellie uit
description: ""
trigger:
  - type: opened
    platform: device
    device_id: b31c006d213403e7c78f5e189abc5912
    entity_id: binary_sensor.brievenbus_window_door_is_open
    domain: binary_sensor
condition:
  - condition: device
    type: is_off
    device_id: 56c4684283425a1d40cee71b8c6a370e
    entity_id: switch.camera_ellie_3
    domain: switch
action:
  - service: camera.snapshot
    data:
      filename: /config/www/cam/brievenbus.jpg
    target:
      entity_id: camera.192_168_1_50
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: notify.all
    data:
      message: BRIEVENBUS WERD GEOPEND
      data:
        image: /local/cam/brievenbus.jpg
        clickAction: https://thecobra666.synology.me/local/cam/brievenbus.jpg
      title: BRIEVENBUS
  - service: media_player.volume_set
    data:
      volume_level: 0.3
    target:
      entity_id: media_player.google_speakers
  - service: script.google_home_resume
    data:
      action:
        - service: tts.google_translate_say
          data:
            entity_id: media_player.google_speakers
            message: DE BRIEVENBUS WERD GEOPEND
            cache: true
            language: nl
      target:
        entity_id:
          - media_player.nest_hub
          - media_player.google_opslagkamer
          - media_player.grote_slaapkamer_hub
mode: single

Anything in the logs that might be useful for us?

No response

Additional information

No response

thecobra666 avatar Nov 15 '23 16:11 thecobra666

Hey there @davet2001, mind taking a look at this issue as it has been labeled with an integration (generic) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of generic can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign generic Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


generic documentation generic source (message by IssueLinks)

home-assistant[bot] avatar Nov 15 '23 16:11 home-assistant[bot]

Hi @thecobra666, thanks for reporting this issue.

I am not aware of others reporting this.

The YAML and log output seems to include a lot of unrelated info, but it looks like there is a timeout occurring while an image is loading.

Please could you download the diagnostic data for the problem camera and paste it into the description?

Please could you also try loading a camera image directly from the camera's IP address using a web browser to confirm that the camera is working correctly?

davet2001 avatar Nov 15 '23 22:11 davet2001

Hi @thecobra666, thanks for reporting this issue.

I am not aware of others reporting this.

The YAML and log output seems to include a lot of unrelated info, but it looks like there is a timeout occurring while an image is loading.

Please could you download the diagnostic data for the problem camera and paste it into the description?

Please could you also try loading a camera image directly from the camera's IP address using a web browser to confirm that the camera is working correctly?

Hi, I have no option for diagnostics. I can only enable the debug option. It times out. Also, my browser tab (google chrome) is very slow when the issue come's up. I then have to close it and open it again for everything to be performant again.

The strange thing is if I do this in develop service help, I have the same issue BUT, if I remove the camera, change it to another one it works. Then change it back, and it works for the other one also... so something is going wrong after a while and is stuck. It mentions it's still "running".

Error message:

Logger: homeassistant.helpers.script.websocket_api_script
Source: helpers/script.py:468
First occurred: 15 november 2023 om 17:13:12 (5 occurrences)
Last logged: 09:22:57

websocket_api script: Error executing script. Unexpected error for call_service at pos 1:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 963, in async_handle_snapshot_service
    else await camera.async_camera_image()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/generic/camera.py", line 197, in async_camera_image
    response = await async_client.get(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1757, in get
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1530, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1617, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
    response = await self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
    response = await self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1719, in _send_single_request
    response = await transport.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 366, in handle_async_request
    resp = await self._pool.handle_async_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 262, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request
    response = await connection.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
    return await self._connection.handle_async_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 133, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 111, in handle_async_request
    ) = await self._receive_response_headers(**kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 176, in _receive_response_headers
    event = await self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 212, in _receive_event
    data = await self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 34, in read
    return await self._stream.receive(max_bytes=max_bytes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1103, in receive
    await self._protocol.read_event.wait()
  File "/usr/local/lib/python3.11/asyncio/locks.py", line 213, 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 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 959, in async_handle_snapshot_service
    async with asyncio.timeout(CAMERA_IMAGE_TIMEOUT):
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

thecobra666 avatar Nov 16 '23 08:11 thecobra666

Stopped working again.


Source: components/automation/__init__.py:655
Integration: Automatisering ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 16 november 2023 om 16:54:47 (2 occurrences)
Last logged: 11:51:33

While executing automation automation.brievenbus_geopend
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 963, in async_handle_snapshot_service
    else await camera.async_camera_image()
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/generic/camera.py", line 197, in async_camera_image
    response = await async_client.get(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1757, in get
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1530, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1617, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1645, in _send_handling_auth
    response = await self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects
    response = await self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1719, in _send_single_request
    response = await transport.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 366, in handle_async_request
    resp = await self._pool.handle_async_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 262, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request
    response = await connection.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
    return await self._connection.handle_async_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 133, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 111, in handle_async_request
    ) = await self._receive_response_headers(**kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 176, in _receive_response_headers
    event = await self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 212, in _receive_event
    data = await self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 34, in read
    return await self._stream.receive(max_bytes=max_bytes)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1103, in receive
    await self._protocol.read_event.wait()
  File "/usr/local/lib/python3.11/asyncio/locks.py", line 213, 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/components/automation/__init__.py", line 655, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1578, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 959, in async_handle_snapshot_service
    async with asyncio.timeout(CAMERA_IMAGE_TIMEOUT):
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

thecobra666 avatar Nov 21 '23 15:11 thecobra666

After updating home assistant (and a restart of it) it's working again. I'm going to test this troughout the day but, the issue always appears after a little while.

thecobra666 avatar Nov 23 '23 07:11 thecobra666

Hi,

I have discovered same problem after an alarm detection. Any of my cameras get access to the snapshot service. Seems to be a random problem because last week worked ok during another detection. My HAOS is 2023.11.3.

Any news on this topic???

Thanks a lot

Logger: homeassistant.components.automation.alarma_deteccion_garaje_casa Source: helpers/script.py:468 Integration: Automatización (documentation, issues) First occurred: 03:11:24 (1 occurrences) Last logged: 03:11:24

ALARMA - Detección garaje: Error executing script. Unexpected error for call_service at pos 2: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/camera/init.py", line 961, 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 222, in _async_get_stream_image return await camera.stream.async_get_image( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/stream/init.py", line 548, in async_get_image return await self._keyframe_converter.async_get_image( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/stream/core.py", line 538, in async_get_image await self._event.wait() File "/usr/local/lib/python3.11/asyncio/locks.py", line 213, 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 468, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 605, in _service_handler response = await self._async_start_run( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 563, in _async_start_run script_result = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 594, in _async_run return await self.script.async_run(script_vars, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1578, in async_run return await asyncio.shield(run.async_run()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call response_data = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/camera/init.py", line 959, in async_handle_snapshot_service async with asyncio.timeout(CAMERA_IMAGE_TIMEOUT): File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in aexit raise TimeoutError from exc_val TimeoutError

franlmc avatar Nov 30 '23 03:11 franlmc

I don't have any more info on why this might be occurring, but it definitely looks like a timeout while trying to get an image. It is possible that this could be the camera becoming unresponsive. Please can you paste the diagnostic information for the integration, and also the camera make/model?

davet2001 avatar Nov 30 '23 12:11 davet2001

I don't have any more info on why this might be occurring, but it definitely looks like a timeout while trying to get an image. It is possible that this could be the camera becoming unresponsive. Please can you paste the diagnostic information for the integration, and also the camera make/model?

The generic camera integration does not have diagnostics. It happens totally at random. Nothing has changed on the camera's side.

Camera's are Dahua's and have been working for years. This started with the upgrade tot 2023.11. So something must be off, but unfortunatly I don't have anymore information then what the logs are giving.

thecobra666 avatar Nov 30 '23 13:11 thecobra666

I don't have any more info on why this might be occurring, but it definitely looks like a timeout while trying to get an image. It is possible that this could be the camera becoming unresponsive. Please can you paste the diagnostic information for the integration, and also the camera make/model?

Hi,

My camera is Laxihub/ Arenti brand model, M1 model. Snapshots and record services went ok until lastest updates.

This is all diagnostic info from camera (not to much):

{ "home_assistant": { "installation_type": "Home Assistant OS", "version": "2023.11.3", "dev": false, "hassio": true, "virtualenv": false, "python_version": "3.11.6", "docker": true, "arch": "x86_64", "timezone": "Europe/Madrid", "os_name": "Linux", "os_version": "6.1.59", "supervisor": "2023.11.6", "host_os": "Home Assistant OS 11.1", "docker_version": "24.0.6", "chassis": "embedded", "run_as_root": true }, "custom_components": { "floureon": { "version": "1.0.0", "requirements": [ "pythoncrc", "broadlink>=0.15.0" ] }, "browser_mod": { "version": "2.3.0", "requirements": [] }, "webrtc": { "version": "v3.5.0", "requirements": [] }, "imou_life": { "version": "1.0.13", "requirements": [ "imouapi==1.0.13" ] }, "dahua": { "version": "0.5.0", "requirements": [] }, "localtuya": { "version": "5.2.1", "requirements": [] }, "smartir": { "version": "1.17.8", "requirements": [ "aiofiles>=0.6.0" ] }, "hacs": { "version": "1.33.0", "requirements": [ "aiogithubapi>=22.10.1" ] }, "sonoff": { "version": "3.5.3", "requirements": [ "pycryptodome>=3.6.6" ] } }, "integration_manifest": { "domain": "generic", "name": "Generic Camera", "codeowners": [ "@davet2001" ], "config_flow": true, "dependencies": [ "http" ], "documentation": "https://www.home-assistant.io/integrations/generic", "iot_class": "local_push", "requirements": [ "ha-av==10.1.1", "Pillow==10.1.0" ], "is_built_in": true }, "data": { "title": "Cam. garajeRTSP", "data": {}, "options": { "authentication": "digest", "framerate": 2, "verify_ssl": false, "stream_source": "rtsp://:@ip:port/****", "content_type": "live", "limit_refetch_to_url_change": false } } }

franlmc avatar Nov 30 '23 14:11 franlmc

@thecobra666 are you using RTSP also?

The diagnostics can be found as per attached screenshot. image

davet2001 avatar Nov 30 '23 18:11 davet2001

How do you find that option? I only have the one behind the pop-up.

Nvm, will attach tomorrow

thecobra666 avatar Nov 30 '23 18:11 thecobra666

config_entry-generic-849ce8ddbbf10ed2444018dace6abff6.json.txt

See attached file. RTSP for stream (the stream keeps working) it's the snapshot that isn't working (http://...).

thecobra666 avatar Dec 01 '23 09:12 thecobra666

config_entry-generic-849ce8ddbbf10ed2444018dace6abff6.json.txt

See attached file. RTSP for stream (the stream keeps working) it's the snapshot that isn't working (http://...).

Hi,

As I mentioned the other day, I have had the same problem randomly with my cameras.

I am currently trying to activate the preload camera stream and at the moment it seems that problem has been solved with the snapshot service but on the contrary I have noticed a high consumption of my NUC's resources.

Do you have this option activated in your cameras?

franlmc avatar Dec 01 '23 09:12 franlmc

config_entry-generic-849ce8ddbbf10ed2444018dace6abff6.json.txt See attached file. RTSP for stream (the stream keeps working) it's the snapshot that isn't working (http://...).

Hi,

As I mentioned the other day, I have had the same problem randomly with my cameras.

I am currently trying to activate the preload camera stream and at the moment it seems that problem has been solved with the snapshot service but on the contrary I have noticed a high consumption of my NUC's resources.

Do you have this option activated in your cameras?

I quote myself. Despite having the preload camera stream option active, I have had the same problem again.....

franlmc avatar Dec 01 '23 18:12 franlmc

Sorry I don't have anything specific to help narrow this down, but for info: if a still URL is provided, the snapshots are sourced from that URL. If you only provide an RTSP url, then the integration has to create images from the stream.

davet2001 avatar Dec 01 '23 21:12 davet2001

Sorry I don't have anything specific to help narrow this down, but for info: if a still URL is provided, the snapshots are sourced from that URL. If you only provide an RTSP url, then the integration has to create images from the stream.

I could be wrong but, I don't think it's possible to add a camera without a snapshot url.

thecobra666 avatar Dec 01 '23 21:12 thecobra666

As long as as we are both talking about the still image URL (the first field in the config flow), it is definitely possible to skip this.

davet2001 avatar Dec 02 '23 06:12 davet2001

Could this be due to having my cameras displayed 24/7? Since I transferred over my camera monitor again I’m not having this issue with my camera snapshots not showing, only started happening when I set that up, too many cameras / resources to keep all my snapshots displayed 24/7?

Rehold avatar Dec 09 '23 18:12 Rehold

Logger: homeassistant.components.generic.camera Source: components/generic/camera.py:212 Integration: Generic Camera (documentation, issues) First occurred: 9:15:45 PM (4 occurrences) Last logged: 9:15:45 PM

Error getting new camera image from Front Door: Server error '500 Internal Server Error' for url 'http://homeassistant:8123/api/camera_proxy/camera.front_door_snapshot?token=e0c95bca3111aef239095697f274f040506e3e5b0d54a3af274cf148da16f449' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 Error getting new camera image from Back Yard: Server error '500 Internal Server Error' for url 'http://homeassistant:8123/api/camera_proxy/camera.back_yard_snapshot?token=2ddf687513a3d1fc7ce8399d72cc9f7dfc8314b0273a0fd59216825235e6e2aa' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 Error getting new camera image from Upstairs: Server error '500 Internal Server Error' for url 'http://homeassistant:8123/api/camera_proxy/camera.upstairs_snapshot?token=d45c9894854f9cc89ad5c78fa2e6ee62a4fc13bcff7e3612e512ba776bef2a23' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 Error getting new camera image from Side Driveway: Server error '500 Internal Server Error' for url 'http://homeassistant:8123/api/camera_proxy/camera.side_driveway_snapshot?token=7dc1e07f9dcc080ff40620258816e389765b2198581c119618a2677d750d8761' For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500

still have this issue every time I have the page displayed 24/7

Rehold avatar Dec 15 '23 03:12 Rehold

@Rehold yes, it could be due to camera overload. There is a PR #105821 open to cache the images, so that if multiple images are being requested between each frame interval, only one request is made to the camera.

But if you have the view open 24/7 I highly recommend getting the stream to work.

davet2001 avatar Dec 18 '23 11:12 davet2001

What do you mean by getting the stream to work sorry

Rehold avatar Dec 19 '23 23:12 Rehold

Hi @Rehold I mean configuring the stream URL in the HA generic camera settings and perhaps leaving the still image URL blank.

A stream connection uses RTSP or similar protocol. A still image connection is just downloading lots of jpegs in quick succession, at a certain rate the camera won't cope with this.

davet2001 avatar Dec 20 '23 23:12 davet2001

Oh alright, will this still display snapshots tho? Since that’s the whole purpose of what I need Sent from my iPhone

Rehold avatar Dec 21 '23 22:12 Rehold

Yes, the snapshots should be generated from the stream. Although some have experienced this not being reliable recently. Best of both is to have both URLs entered, that way you can get still images or a stream.

davet2001 avatar Dec 21 '23 23:12 davet2001

I kinda need it to be reliable and snapshots up to date as much as possible so idk if it will work ill try it

Rehold avatar Dec 23 '23 19:12 Rehold

Yes, the snapshots should be generated from the stream. Although some have experienced this not being reliable recently. Best of both is to have both URLs entered, that way you can get still images or a stream.

Tried this and snapshots don’t even show up doing this so not sure what else I can do

Rehold avatar Dec 25 '23 22:12 Rehold

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

I have 2024.4.0 now and had a same problem at previous versions, I'm trying to make a screenshot and send it to telegram, from 10 attempts 2-3 are successful, I wrote with more details here

There no any problemsfor me and working faster with same scenario with ONVIF camera integration. But I would like to know why it's not working with RTSP

glemag avatar Apr 04 '24 16:04 glemag