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
73.22k stars 30.58k forks source link

Amcrest cameras not working after upgrading to 2021.9.1 #55661

Closed andornaut closed 3 years ago

andornaut commented 3 years ago

The problem

After upgrading to 2021.9.1 all my Amcrest cameras no longer stream in Lovelace, and produce this log message: "Error requesting stream: Camera is off"

Cameras continue to work directly or through eg. ZoneMinder or VLC.

The same cameras worked in a recent previous version, which I believe was 2021.7.

This may be related to #55550

What is version of Home Assistant Core has the issue?

core-2021.9.1

What was the last working version of Home Assistant Core?

core-2021.7

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Amcrest

Link to integration documentation on our website

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

Example YAML snippet

ffmpeg:
stream:
amcrest:
  # IP4M-1025E
  - host: SNIP
    username: SNIP
    password: SNIP
    name: SNIP
    stream_source: rtsp

Anything in the logs that might be useful for us?

Logger: homeassistant.components.camera
Source: components/camera/__init__.py:692
Integration: Camera (documentation, issues)
First occurred: 9:37:21 AM (8 occurrences)
Last logged: 9:37:27 AM
Error requesting stream: Camera is off


### Additional information

_No response_
probot-home-assistant[bot] commented 3 years ago

amcrest documentation amcrest source (message by IssueLinks)

probot-home-assistant[bot] commented 3 years ago

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

flacjacket commented 3 years ago

I'm guessing you've tried restarting? The only change here that I could see making any difference is that the camera entity now has a unique id. I'm not sure how that plays a role through an upgrade to go to no unique id to having a unique id. This does seem very similar to the issue you linked, and it looks like that was taken care of with a restart (in addition to rolling the version back and forth, but I'm not sure if that helped in clearing the issue).

andornaut commented 3 years ago

Hey @flacjacket , thanks for your response!

I'm guessing you've tried restarting?

Yep.

I also removed the :latest Docker container and started a new one based on homeassistant/home-assistant:2021.17. When I did so, some new camera entities were created with a similar entity name but with "_2" appended. Once I configured the Lovelace interface to reference the "..._2" entities, all cameras resumed working as before.

I've since removed that container and started a new one based on homeassistant/home-assistant:latest and the "..._2" entities no longer exist, and the previous ones continue to not work.

Happy to help debug this if there's anything I can add.

cameras

andornaut commented 3 years ago

Note also that I have a Foscam camera integration, which had continued to work through the upgrade->downgrade->upgrade.

I also tried removing the Docker container and its volumes including the .config/.storage directory. When starting a new container and accessing the web interface, it brought up the Home Assistant initial setup wizard and auto-configured the Lovelace interface with the Amcrest cameras as described in the configuration.yml. The cameras still do not work, though.

flacjacket commented 3 years ago

Do you have a more complete log? That might help us to understand what is going wrong with the integration.

andornaut commented 3 years ago

Do you have a more complete log? That might help us to understand what is going wrong with the integration.

I've attached the complete Docker logs output. I configured the logger log level to INFO.

log.txt

ijustlikeit commented 3 years ago

I think I know how to re-create this error. I've proved it by doing it. Login to the Amcrest camera setup web page for the camera that is NOT working, Under the setup, camera, video setting make sure the Sub Stream is ENABLED. Save this setting. Restart home assistant. Check your camera should be working.

To prove this, on mine anyways, I DISABLED the sub stream saved restarted home assistant and got "camera off" message, Re ENABLED the substream, saved, restarted Home assistant and the camera was working again.

amcrest

flacjacket commented 3 years ago

Interesting! Looking at your debug log in the other ticket, I see the rtsp url has channel=1&subtype=0 which should be the correct rtsp url for the main stream, and even the event that the amcrest package is getting back from the camera is noting "StreamType" : "Main". When you try to load the rtsp stream with VLC, what is the address that you use?

flacjacket commented 3 years ago

Also what would be interesting to see, if you roll back to <2021.9, what is the rtsp url that is printed out in the debug log?

ijustlikeit commented 3 years ago

"rtsp://admin:xxxx@192.168.x.x/cam/realmonitor?channel=1&subtype=00&authbasic=xxxxxxxxxxxxxx"

This is what I used for the camera in question (this is the one I used in VLC and it worked).

andornaut commented 3 years ago

@ijustlikeit Thanks for looking into it! I was able to work around this issue by enabling substream.

I wonder if we can avoid requiring this workaround, though?

redwngsrul commented 3 years ago

I'm also having the same issue with all of my Amcrest cameras since upgrading to 2021.9.4 this morning. The only difference is that I use the snapshot stream source mode for my cameras instead of the rtsp.

I can confirm @andornaut 's temporary workaround solution worked for me too. Enabling the substream does fix the problem.

For now, though, I have downgraded back to 2021.8 until this is fixed.

flacjacket commented 3 years ago

Thank you all to reporting on this problem, and extra thanks to @ijustlikeit for figuring out a reproducible way to trigger this problem. I found a fix for this upstream (linked in the ticket above if anyone else is able to patch that into their running instance and confirm that it works), and can work on getting that into a new release, and bumping the version in home assistant.

andornaut commented 3 years ago

anyone else is able to patch that into their running instance and confirm that it works)

I tested the fix. Works! Thanks @flacjacket

flacjacket commented 3 years ago

This fix should be available in 2021.9.6!