core: Dahua binary_sensor motion_detected doesn't work anymore

The problem

After upgrading to 2022.2 I reported issue #65647. The reason I checked the log was because the motion_detected remained on. The issue was successfully fixed, but the sensor is still false positive. It might have something to do with change #61268, but I don’t know.

For as far as I could debug, the sensor states on when the connection to the camera restored after it was gone. Once it’s on, it remains on even when there is no motion detected at the camera, even when motion detect is turned off.

What version of Home Assistant Core has the issue?

core-2022.2.7

What was the last working version of Home Assistant Core?

core-2021.12.x

What type of installation are you running?

Home Assistant OS

Integration causing the issue

amcrest

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Could not find any logging, other than that the connection to the camera is restored.
Because of the update to 2022.2.7, there is no logging of that available. I can add it if it's useful.

Log generated when rebooted the cam after upgrading to 2022.2.8

Logger: amcrest.http
Source: /usr/local/lib/python3.9/site-packages/amcrest/http.py:365
First occurred: 07:51:26 (7 occurrences)
Last logged: 07:51:28

<xxxxxxxx:xxxxxxxx> Trying again due to error: ConnectTimeout('')
__________
Logger: homeassistant.components.binary_sensor
Source: helpers/entity_platform.py:719
Integration: Binary sensor (documentation, issues)
First occurred: 07:51:25 (2 occurrences)
Last logged: 07:51:30

Updating amcrest binary_sensor took longer than the scheduled update interval 0:00:05
__________
Logger: homeassistant.helpers.entity
Source: helpers/entity.py:728
First occurred: 07:51:30 (2 occurrences)
Last logged: 07:51:32

Update of binary_sensor.voordeur_online is taking over 10 seconds
Update of camera.voordeur is taking over 10 seconds
__________
Logger: homeassistant.components.amcrest
Source: components/amcrest/__init__.py:217
Integration: Amcrest (documentation, issues)
First occurred: 07:51:34 (1 occurrences)
Last logged: 07:51:34

Voordeur camera offline: Too many errors
__________
Logger: homeassistant.components.amcrest.camera
Source: components/amcrest/helpers.py:23
Integration: Amcrest (documentation, issues)
First occurred: 07:51:34 (1 occurrences)
Last logged: 07:51:34

Could not get Voordeur camera attributes due to error: CommError
__________
Logger: homeassistant.components.stream.stream.camera.voordeur
Source: components/stream/__init__.py:340
Integration: Stream (documentation, issues)
First occurred: 07:51:27 (3 occurrences)
Last logged: 07:51:58

Error from stream worker: Stream ended; no additional packets
Error from stream worker: Error opening stream (ERRORTYPE_111, Connection refused) rtsp://****:****@<path>
__________
Logger: homeassistant.components.amcrest
Source: components/amcrest/__init__.py:228
Integration: Amcrest (documentation, issues)
First occurred: 07:52:36 (1 occurrences)
Last logged: 07:52:36

Voordeur camera back online


### Additional information

Steps to reproduce:
1. Reboot the camera 

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 22 (5 by maintainers)

Most upvoted comments

@deviantintegral I did see that behavior as well when I was testing this, where if I’d jostle the camera while unplugging it, it would flip to motion detected before dropping offline, and when the camera would come back online, it would be in that detected state until it had another motion start/stop to reset itself. It may be that we want to reset the binary sensors when they come online, but I’m not sure the best way to implement that. It seems like a good thing to open a ticket for. Thanks!

So, today I did a small test-run since the sensor was not detecting.

  1. Validation:

    1. HA Motion detect sensor doesn’t respond
    2. In camera interface, detection is there
  2. Reboot HA

    1. HA Motion detect sensor responds as expected
  3. Restart Camera

    1. HA Motion detect sensor: Detecting (at the beginning of the camera restart)
    2. HA Motion detect sensor: Unavailable
    3. HA Motion detect sensor: Detecting
      1. No current detection at camera
    4. Walk in front of camera
    5. In camera interface, detection is there
    6. HA Motion detect sensor: Still detecting
    7. Actual motion ends 7. HA Motion detect sensor: Detecting
  4. Resets sensor state to: off

    1. Motion detect doesn’t respond
    2. In camera interface, detection is there
  5. Reboot HA

    1. Motion detect works

I think my issue is related to this one as well. I have Amcrest cameras around the house. I have the cameras configured to restart every morning. But after restarting the cameras, motion detection doesn’t work at all, even though motion detection is enabled on camera. I have to restart Home Assistant to get motion detection working on Home Assistant again.

This issue only started when I upgraded from the December 2021 firmware to February 2022 firmware.