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
72.67k stars 30.43k forks source link

Reolink not working correctly with picture entity after upgrade to 2023.7.1. #96222

Closed BluThunder2k closed 1 year ago

BluThunder2k commented 1 year ago

The problem

In 2023.6.3, when I would load a lovelace page that had picture entities from Reolink cameras, they would fill in the screen nearly immediately. After the upgrade to 2023.7.1 when going to that same lovelace page, one of which has 5 cameras on it, sometimes only 2-3 cameras will fill in, the others will either take a very long time or never fill in. Also on the 10 second refreshes on those picture entities the updates are not happening every 10 seconds as normal, often they miss refreshes. Rolling back to 2023.6.3 no longer does this, and upgrading again to 2032.7.1 causes it again.

The same cameras not using the reolink plugin, but using WebRTC display immediately, so it seems like it has something to do with Reolink integration and the changes to the picture entity in 7.1.

What version of Home Assistant Core has the issue?

core-2023.7.1

What was the last working version of Home Assistant Core?

core-2023.6.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Reolink

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

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!

Code owner commands Code owners of `reolink` 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 reolink` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


reolink documentation reolink source (message by IssueLinks)

domosgabor commented 1 year ago

I'm experiencing the same with 6 PoE cameras and PoE doorbell.

Error from stream worker: Error demuxing stream: [Errno 110] Operation timed out: 'rtsp://admin:password@123.456.789.10:554/Preview_02_sub' Error from stream worker: Error opening stream (INVALIDDATA, Invalid data found when processing input) rtsp://:@1123.456.789.10:554/Preview_02_sub Error from stream worker: Error demuxing stream while finding first packet: [Errno 110] Operation timed out: 'rtsp://admin:password@123.456.789.10:554/Preview_02_sub' Error from stream worker: Error opening stream (ERRORTYPE_113, Host is unreachable) rtsp://:@123.456.789.10:554/Preview_02_sub

starkillerOG commented 1 year ago

@domosgabor Those errors are related to the stream integration, not the reolink integration. The reolink integration only provides the URLs, and the stream integration does the actual opening and handeling of the streams. You could try a diffrent steaming protocol, you can switch between RTSP, RTMP or FLV in the options of the integration (see documentation).

@BluThunder2k which reolink camera entities are you using? The sub, main, snapshot sub, or snapshot main entity? In HA 2023.7 the snapshots have been changed such that the main stream will also use high resolution snapshots and the sub stream uses low resolution snapshots.

home-assistant[bot] commented 1 year ago

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

Code owner commands Code owners of `stream` 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 stream` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


stream documentation stream source (message by IssueLinks)

BluThunder2k commented 1 year ago

@BluThunder2k which reolink camera entities are you using? The sub, main, snapshot sub, or snapshot main entity? In HA 2023.7 the snapshots have been changed such that the main stream will also use high resolution snapshots and the sub stream uses low resolution snapshots.

@starkillerOG - Any of them have massive delays. If I go to the detail page for a camera for example, under the sensors for main, snaphot, substream etc, it takes 20-30 seconds for the images to pop in. The cameras pop right up in a web browser, and if I use WEB-RTC to view the cameras it's real time instantly. But any of the entities created by the reolink add either don't refresh for 30 seconds or show the broken image icon. Back in 2023.6.x this is not a problem.

Any thoughts on what to debug to see what may be causing the hangup?

Schnabulation commented 1 year ago

I'd just like to add to this issue: It's also appearing on my system. On 2023.6.3 the streams loaded slow, but in the end the pictures are shown. Now on 2023.7.2 they try to load but end up failing:

grafik

line-nz commented 1 year ago

Same issue here as well on 2023.7.x - delayed or failing snapshots showing on the dashboard screen. Have downgraded back to 2023.6.3 to resolve in the mean time.

Schnabulation commented 1 year ago

What are the next steps? I'm still prevented to upgrade by this integration.

starkillerOG commented 1 year ago

Hopefully someone from the stream integration can pick this up. There is nothing I can do from the reolink integration since it only provides the URL for the stream/the snapshot bytes array.

A promising PR is this one https://github.com/home-assistant/core/pull/93374, but it will probaly takes months before that makes it to a release.

uvjustin commented 1 year ago

The stream component had no changes between the 2023.6 and 2023.7 releases, so it does not seem like this issue comes from stream (at least directly): https://github.com/home-assistant/core/commits/dev/homeassistant/components/stream (The stream_worker error messages above are just forwarded from the underlying FFmpeg library and are actually not related to the HA stream code at all.)

BluThunder2k commented 1 year ago

Here's what makes no sence. I can add a Reolink camera as a generic camera, and put the RTSP stream URL in. It works as normal (without the snapshot URL in there even). Same camera with Reolink, freezes on the snapshot. I wonder if Generic camera uses the same FFmpeg library?

starkillerOG commented 1 year ago

Yea I indeed see the last significant change was on 2023.6 with this PR https://github.com/home-assistant/core/pull/93420 that bumped the FFmpeg version but then reverting to 2023.6 schould not have helped (only reverting to 2023.5)....

starkillerOG commented 1 year ago

I checked but both the snapshot and stream URLs did not change in the Reolink integration between 2023.7 and 2023.6.

Most significant change is the new ONVIF long polling connection when ONVIF push is not working.

@BluThunder2k for one of the camera's that is often failing to load the stream, could you enable debug logging under Settings->Devices & Services->Reolink integration overflow menu (three vertical dots)->Enable debug logging? Then try opening the stream and make sure it fails to load. Also make some motion events on that camera. Log for a total of about 6 minutes and stop debug logging and post the .txt log file here. I want to see if your camera is using ONVIF Push, long polling, or fast polling and what the long polling timeout of your camera is.

b4ldrick commented 1 year ago

I'd like to add to this issue: It's the same on my system. On 2023.6.3 the streams load quickly and update every 10 seconds. Now on 2023.7.3 they mostly fail to load, occasionally one or two may show up either right away or after a significant wait they never refresh at 10 seconds. It doesnt matter what stream is being used rtsp, rtmp or flv its all exactly the same. i have reverted back to 2023.6.3 for now

hamshiva commented 1 year ago

Hi, I do have the same issue whatever the mode I use (rtsp, rtmp, flv). From time to time I can see some strange messages like this: ERROR (stream_worker) [homeassistant.components.stream.stream.camera.reo1_main] Error from stream worker: Stream has no video I join my debug log. Be aware that there are 3 cameras and password digests have been redacted. home-assistant_reolink_2023-07-29T15-25-57.484Z.log

Btw the cameras streams are working correctly using the ONVIF integration.

Regards,

starkillerOG commented 1 year ago

I think I figured this one out while working on another issue:

When your network configuration does not allow for ONVIF push, the integration will fall back to ONVIF long polling, see the new docs about this: https://www.home-assistant.io/integrations/reolink/#reducing-latency-of-motion-events. At least @hunterjm is using ONVIF long polling as I can see from his debug log.

When using ONVIF long polling, the long poll request would obtain a shared mutex lock, blocking all communication to the camera from other requests for up to 60 seconds. This includes getting snapshot images from the camera. This really really screws up the snapshot streams, and also normal streams since they first request a single snapshot for fast vieuwing, ironically this "fast" snapshot would hang, blocking the stream from loading.

So it seems like this is indeed a problem in the Reolink integration and not the stream integration. I did not notice this myself since my network config allows ONVIF push and therefore I do not use ONVIF long polling. In my dev enviroment where I test ONVIF long polling, I was focussed on the events comming in and forgot to check the streams (which never really work on my dev enviroment due to linux on windows issues).

Bottom line: I think I fixed the issue in this PR: https://github.com/home-assistant/core/pull/97464 Will let you guys know once it is available for testing in a HA (beta) release.

starkillerOG commented 1 year ago

If you appreciate the reolink integration and want to support its development, please consider sponsering the upstream library or purchase Reolink products through this affiliate link.

Schnabulation commented 1 year ago

Wow you are good! Thank you for the amazing work. Looking forward to the fix.

One question though: what prevents the usage of ONVIF push? I have HA and the cameras in two different subnets but they have full access to each other.

starkillerOG commented 1 year ago

@Schnabulation do you have a global SSL certificate configured? What URL did you specify as local URL in the HA network settings?

If you turn on debug logging of the reolink integration, you can see if there are ONVIF long polling requests every minute or so.

starkillerOG commented 1 year ago

The PR that will hopefully fix these issues has been merged and will be included in HA 2023.8.0 which will be released in 2 days. Please let me know if the snapshots and streams load again as expected once you are on HA 2023.8.0.

If you appreciate the reolink integration and want to support its development, please consider sponsering the upstream library or purchase Reolink products through this affiliate link.

Schnabulation commented 1 year ago

Just wanted to confirm: works in 2023.8.0. Appreciate the work!

domosgabor commented 1 year ago

Thanks, works perfectly in the the latest release.