home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.82k stars 28.94k forks source link

Generic Camera integration's RTSP camera streams (from Dahua XVR) doesn't work #121197

Open maretodoric opened 3 days ago

maretodoric commented 3 days ago

The problem

Attempting to add RTSP stream from Dahua XVR works but only icon of a broken image appears after adding the camera.

image

Using the same URL: rtsp://user:pass@192.168.0.250:554/cam/realmonitor?channel=2&subtype=0 works fine when i open it via VLC, proving that stream is indeed accessible.

What version of Home Assistant Core has the issue?

core-2024.6.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Generic Camera

Link to integration documentation on our website

https://www.home-assistant.io/integrations/generic/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-07-04 13:51:03.025 WARNING (MainThread) [homeassistant.helpers.entity] Entity None (<class 'homeassistant.components.generic.camera.GenericCamera'>) does not have a platform, this may be caused by adding it manually instead of with an EntityComponent helper, please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue
2024-07-04 13:51:03.026 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback Stream._async_update_state(True) (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 378, in _async_update_state
    self._update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 997, in async_write_ha_state
    self._async_verify_state_writable()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 984, in _async_verify_state_writable
    raise NoEntitySpecifiedError(
homeassistant.exceptions.NoEntitySpecifiedError: No entity id specified for entity preview
2024-07-04 13:51:03.026 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/generic/config_flow.py", line 502, in get
    image = await _async_get_image(
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 205, in _async_get_image
    raise HomeAssistantError("Unable to get image")
homeassistant.exceptions.HomeAssistantError: Unable to get image

Additional information

This is an Analog camera but RTSP stream is served by XVR itself. As mentioned in The Problem section, it works when opened in VLC for example.

home-assistant[bot] commented 3 days ago

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. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


generic documentation generic source (message by IssueLinks)

davet2001 commented 3 days ago

Hi @maretodoric,

The first thing to say is that the image preview is a preview of whatever you have entered into the Still image URL box.

Currently only still images can be previewed. The stream has no preview, so the broken icon means nothing in relation to the stream.

What did you enter into the still image box? And does that display anything meaningful if you paste the URL into a browser?

A feature addition is in progress to show a preview of the stream:

https://github.com/home-assistant/core/pull/120970

maretodoric commented 2 days ago

Aaahhh, that makes sense... I just thought it should be a preview of the stream that is broken and I've never really opened it myself.

I did not enter anything into the 'still image box' as I'm honestly not aware of still image URL from Dahua. But if i just check the box that "This image looks good" and Submit - then open the camera entity - i can see my camera stream.

Thanks! That was not clear to me.

davet2001 commented 2 days ago

See also #118599 which you should find fixes the broken icon in your scenario from 2024.7.x+