rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
383 stars 74 forks source link

Human and Motion Alerts are not working #258

Open elnorte13524 opened 1 year ago

elnorte13524 commented 1 year ago

I am using an Amcredt AD410 with the Dahua integration.

Home Assistant 2023.1.7 Supervisor 2023.01.1 OS 9.5 Running as a VM on esxi, if that matters.

Starting on feb 1, i am no longer getting motion events from my camera. My human detection broke before that, but i cant confirm the date in my HA logs. I went back to January 15th and have no Human Detected events since then. Everything works fine in the Amcrest app. I even turned on notifications again to make sure and ive gotten multiple human and motion notifications from the Amcrest app today. The camera works in HA, though. I see live video and that works fine.

I tried to delete the integration and reinstall it, but that didnt fix any of the detection issues and actually broke the camera feed. I restored from a backup i took overnight and the camera came back, but no detection events.

Edited to add - i also tried listening for dahua_event_received events, but as i saw activity and received notifications in the Amcrest app, i saw no events come across on the HA side.

pspeirs commented 1 year ago

Try checking whether the IP address has changed, do you have it static via mac address? Each time mine has failed, I've deleted and re-added it back in. I don't know if there is a way to get the IP address of the unit via the dahua plugin or out of config but it would be helpful to be able to change it on the fly.

elnorte13524 commented 1 year ago

IP has not changed. It has a dhcp reservation in my firewall. Motion alerts still come through to home assistant and I can still stream video in home assistant, its just the person detection that isn't working in HA, but they still work in the amcrest app.

Tunatron commented 1 year ago

I've noticed the same issue with my doorbell events. Literally every other part of the integration continues to work fine, just human detection has stopped triggering.

Infeconex commented 1 year ago

Same issue here. Human alerts is particularly key for me. The integration is working fine, including basic motion detection. Just not the binary sensors for human and vehicle detection.

Home Assistant 2023.3.1 Supervisor 2023.03.1 Operating System 9.5 Frontend 20230302.0 - latest

Running from ODroid N2

GaryOkie commented 1 year ago

For anyone reporting AD410 Human/Motion/Button detection not working and not seeing any "dahua_event_received" events - did you update your firmware recently?

The newest version (20221201) that is only available from the Amcrest download site has broken event handling. If you installed this, go back to that site and install the previous version (20210220).

drjjr2 commented 1 year ago

Door Bell Motion Alarm and Cross Region Detection seem to fire properly. Smart Motion Human never fires but I can set up a trigger on dahua_event_received with

Action: Start
Code: CrossRegionDetection
Data:
  Action: Appear
  Object:
    ObjectType: Human

And get a trigger for a person. I am on firmware 20230221. Is there something I don't have configured properly?

Bubbgump209 commented 1 year ago

I think this is a duplicate of my issue #276. Something must not be parsed correctly as the camera is certainly sending the event.

Code=SmartMotionHuman;action=Start;index=0;data={
   "RegionName" : [ "Region1" ],
   "WindowId" : [ 0 ],
   "object" : [
      {
         "HumamID" : 52599,
         "Rect" : [ 2304, 736, 2752, 2944 ]
      }
   ]
}

Code=SmartMotionHuman;action=Stop;index=0;data={
   "RegionName" : [ "Region1" ],
   "WindowId" : [ 0 ],
   "object" : [
      {
         "HumamID" : 52599,
         "Rect" : [ 2400, 64, 2848, 1792 ]
      }
   ]
}

CrossLine is making to HA just fine though:


Code=CrossLineDetection;action=Start;index=0;data={
   "Class" : "Normal",
   "CountInGroup" : 1,
   "DetectLine" : [
      [ 1238, 3506 ],
      [ 3968, 3248 ]
   ],
   "Direction" : "LeftToRight",
   "EventID" : 10001,
   "GroupID" : 0,
   "Name" : "IVS-1",
   "Object" : {
      "Action" : "Appear",
      "BelongID" : 0,
      "BoundingBox" : [ 2456, 2464, 3176, 5408 ],
      "Center" : [ 2816, 3936 ],
      "Confidence" : 0,
      "LowerBodyColor" : [ 0, 0, 0, 0 ],
      "MainColor" : [ 0, 0, 0, 0 ],
      "ObjectID" : 52636,
      "ObjectType" : "Human",
      "RelativeID" : 0,
      "Speed" : 0
   },
   "PTS" : 44847664150.0,
   "RuleID" : 1,
   "Track" : [],
   "UTC" : 1683633895,
   "UTCMS" : 644
}

I'm on Dahua 2.80xxxx something.

Looking in https://github.com/rroller/dahua/blob/main/custom_components/dahua/__init__.py on lines ~485 I suspect something is getting clobbered.

stefanoferrario commented 1 year ago

@rroller any solution for this?

rroller commented 1 year ago

Sorry. Short on time. I'll try looking soon.

muzzbuzz commented 1 year ago

So, I may have found a workaround for some people out there. My issue was that I was only receiving 'VideoMotion' events and not 'SmartMotionHuman' or 'SmartMotionVehicle'.

I presume that the 'attachcode' for 'SmartMotionHuman' may not actually be called this when attempting to subscribe to it. Instead of specifying individual names for the events to subscribe to, I changed this to 'All' and now I seem to be receiving the events correctly.

Code location to change: https://github.com/rroller/dahua/blob/321a576e5fee81de122c440ad28d806b519e35cc/custom_components/dahua/client.py#L685

See the change below:

Original: url = "{0}/cgi-bin/eventManager.cgi?action=attach&codes=[{1}]&heartbeat=5".format(self._base, codes) Modified: url = "{0}/cgi-bin/eventManager.cgi?action=attach&codes=[All]&heartbeat=5".format(self._base, codes)

A full restart of HA was required as well, otherwise the .py files weren't reloaded correctly. Hopefully this helps some others and could potentially be added as an 'All' option in the UI when configuring a device.