Dahua IP camera component

@DeadEnd @JLeandroFreitas

Regarding the channel parameter of the snapshot command, it does indeed select the video channel number. It is supposed to start from 1, but it seems in some (maybe older???) firmware versions channel 0 seems to be equivalent to 1. It does not select between the main and extra streams. And, yes, the comments in snapshot.py are misleading. I have it on my list of changes to make to fix that.

But more important than the comments are what the code currently does, both in the amcrest package and in the HA amcrest component. Currently the resolution setting is used to send a 0 or a 1 as the channel number. But what I believe it should do is to not send the channel parameter at all (so that the camera firmware can default to the correct channel number.) Therefore, what I plan to do is to change the snapshot command in the amcrest package, and the async_camera_image method in the HA amcrest component, so that the snapshot command is sent without the ?channel=N parameter. Could you check for me, if you use http://IP:PORT/cgi-bin/snapshot.cgi in a browser, does it work? It works for me with my Amcrest cameras.

From the Amcrest HTTP Protocol API Specifications:

Yes, this does get a snapshot (after entering credentials) on my Dahua camera.

1 Like

@DeadEnd or anyone with a dahua.

I have a Dahua z12e model and am brand new to home assistant but learning fast. I was on the ipcamtalk forum and follow it closely. In fact have you seen this topic? Dahua Starlight Varifocal Bullet Z5 7-35mm (IPC-HFW5231E-Z5) | Page 12 | IP Cam Talk

Specifically post #228 and #231.
Video from post #228

Are you trying to do something like that using HA? That is what I want to do. Use IVS to trigger event in HA and use on board speaker through camera to play an mp3 after each tripwire event. Still investigating how this can be accomplished. Go3team does it with openhab which I looked into but its support for my devices was limited at best, where HA has everything up and running in a day except for my dahua camera and my onvif cameras. I see that you have been trying to find support for the dahua integration, and have tried a number of them (amazing there are so many to pick from). But which have you found supports the most features for your ZE model? I’m assuming you have the z5e or the z12e, or is there a plain ze model? In either case I think whatever you settled on should work the same for me, so i would be glad to hear your take.

I have been trying to get my still images to show on the lovalace interface but its not working like it does through the a browser. Any idea what i’m missing there?

I’ve just been using the Amcrest component. It captures the tripwire easy enough, then I do automation in Node-Red. There is a Dahua pallet in Node-Red but when I tested it my automation stopped working after a short time - seems like it stopped communicating with the camera.

HA does have a bit of delay compared to the Node-Red pallet, but it has been much more reliable.

As far as sending sound files back, I don’t think the integration has anything for it (but would have to check to be sure). If you look up the docs for it though, you might be able to find a URL to post to that could do it.

Quick google uncovered this:

Post #3 has a link to Dahua HTTP API.
Reading down through it I found this on page 94:

So it appears if you post to that address you might be able to play audio… but just a guess… never tried it :slight_smile:.

Good Luck!
DeadEnd

Hi @DeadEnd - I too am using the Amcrest component for Dahua cameras. Regarding your comment that “HA has a bit of a delay” - is that is in reference to motion detection events? If so, you should see an improvement in the latest 108.x version. @pnbruckner has updated the Amcrest integration to subscribe to events versus the previous polling method. This is indeed more responsive!

Now as far as playing audio via Amcrest component or any camera via HA streaming, that is not supported by the stream component, as verified in this post.

At the bottom of this post there was a nicely detailed solution using the ffmpeg_noise binary sensor platform.

1 Like

@DeadEnd

ARe you trying to accomplish this:

This was done in openhab but I am trying to get it working with HA. It seems everything is there to do it. The guy that did this is go3team over on ipcam talk and hes also on reddit. Anyway he uses a z series dahua camera, I have the z12e and I think you said in another topic you have the ze model. Anyway is this your goal using tripwire to trigger a sound played over a speaker?

Love to work with you on this as I have the same goal.

1 Like

No, my goal does not include playing any sounds.
I did respond to your almost exact question 3 posts up… did you not see my response?
It has some details that might help you accomplish this.

Ohh Man sorry. I did not see that, weird I did not get the notification. Anyway I’m new to HA so its probably going to take me a long time to get this working. I tried openhab at first but its so much more complicated and at least HA is a lil more straightforward. I still cant figure out how to get custom components added to my HA mostly because Samba wont start. SO I gotta get the sorted and then I’m onto this.

Are you using Core or not? AKA do you have an “add-on” store?
If you do, I don’t know anything about how all that works… because I am on the “Core” version that doesn’t have the add-on store.

Since you’re talking about Samba and custom component, I expect that you are using the add-on store.
Otherwise, I would suggest HACS for custom components… it is crazy easy to manage them that way (for non-add-ons).

Cheers!
DeadEnd

THanks. I am on HassOS/HASS.IO VM image under synology virtual machine manager. So yes I have addon store and was trying to install HACS ironically that is why I am trying to get samba so I can dump the hacs install into the samba share but I cant get samba to work so I am stuck.

Samba lets me login with the credentials but then fails to show the shares. Its as if its rejected but I get no error in the log. It says login successful. I found this but i cant apt-get to install this. see: https://www.youtube.com/watch?v=afHieDHizjc

Hi @GaryOkie could you share your amcrest setup? I have 3 dahua and an onvif camera on dahua nvr and would like to use tripwire. (Or is amcrest still limited to motion only?)

Thanks, Roger

Hi @roumen - the amcrest component currently doesn’t support the NVR as it can’t specify channel #'s. So you need to be sure each camera is directly accessible by it’s IP address.

The config is straightforward:

stream:

amcrest:
#   Dahua IPC HDW5231
  - host: 192.168.x.xxx
    name: "Driveway"
    username: !secret cam_id
    password: !secret cam_pw
    resolution: high
    stream_source: rtsp
    port: 80
    binary_sensors: motion_detected

The amcrest component provides a binary sensor for automations, for example: binary_sensor.driveway_camera_motion_detected

But in order to actually enable motion detection, it has to first be enabled in the camera itself, then by using the HA camera service:

service: camera.enable_motion_detection
data:
  entity_id: camera.driveway

The latest Amcrest component has improved responsiveness for motion detection now that it is subscribing to motion events as they happen rather than polling for them which had a bit of a delay. The component won’t tell you what specific event occurred (tripwire, motion, etc.) so events you don’t want need to be disabled in the camera.

Amcrest cameras don’t have tripwire functionality to my knowledge but I’m pretty sure the python-amcrest code will still raise a motion event when they occur on Dahua’s that have it enabled.

1 Like

Thanks for quick reply, I will give it a try. Too bad nvr is not supported yet but I think I can access the camera’s directly (different subnet)

hi guy!

I have just integrated Dahua camera into hass via ovif.

however the camera warnings do not work.

Has anyone ever used or had any idea!

thanks!

Previously issues with Timezone reporting from Dahua firmware was causing me issues trying to use Onvif integration. I stepped back to using Amcrest component until I heard it was working.

I don’t have any Dahua IP cameras, but I’m told from people who do that the amcrest integration works just as well with them as they do with Amcrest cameras. There are some issues with recent Amcrest camera models & firmware versions since Amcrest changed the interface without documenting those changes, but that’s a separate issue.

If you’re still around, would you consider marking this topic as solved, since pretty much Dahua cameras are now supported via the amcrest integration? If so, find an appropriate reply and click on image

Thanks!

Hi @pnbruckner - regarding:

I’ve been using the Amcrest integration for my Dahua cameras a long time, but it does not provide me with HA alerts for tripwire motion detection (among other advanced IVS options). That is why I think this feature request should stay open. Ideally, the goal I think is the Amcrest integration and Dahua could be one in the same and named as such in the docs with few significant caveats. (I do recognize recent Amcrest undocumented changes from the API may make this goal unattainable).

It should be a relatively straightforward update to subscribe to CrossLineDetection (tripwire) in addition to VideoMotion events.

It could be hardcoded to check for any motion/IVS event and return as an attribute what type it was. Or there could be a new configuration option (following how Skybell works) to be able to specify:

binary_sensor:
  - platform: amcrest
    monitored_conditions:
      - button
      - motion
      - tripwire
      - etc...

I snuck “Button” events in there which relates to the Amcrest (or Dahua) doorbells. I have just today figured out how to listen for button events and have a working python script! So this update could solve another highly requested feature as well in python-amcrest.

Following are the Dahua event codes as returned by an app you wrote, slightly modified…


2020-08-18 10:29:05 '\r\nCode=VideoMotionInfo;action=State;index'                                                                                                                             
2020-08-18 10:29:05 '\r\nCode=VideoMotion;action=Start;index=0;data={\n   "RegionName" : [ "Driveway" ]\n'                                                                                    
2020-08-18 10:29:05 '\r\nCode=VideoMotionInfo;action=State;index'                                                                                                                             
2020-08-18 10:29:05 '\r\nCode=VideoMotion;action=Stop;index=0;data={\n   "RegionName" : [ "Driveway" ]\n'                                                                                     
2020-08-18 10:29:08 '\r\nCode=CrossLineDetection;action=Start;index=0;data={\n   "Class" : "Normal",\n   "DetectLine" : [\n      [ 4605, 1823 ],\n      [ 7317, 5639 ],\n      [ 5388, 8045 ],
\n      [ 1329, 6684 ],\n      [ 3240, 2066 ],\n      [ 4660, 1872 ]\n   ],\n   "Direction" : "RightToLeft",\n   "EventSeq" : 2,\n   "FrameSequence" : 5947404,\n   "GroupID" : 2,\n   "Mark" 
: 0,\n   "Name" : "Rule1",\n   "Object" : {\n      "Action" : "Appear",\n      "BoundingBox" : [ 4480, 1280, 5072, 2704 ],\n      "Center" : [ 4776, 1992 ],\n      "Confidence" : 0,\n      "
FrameSequence" : 0,\n      "LowerBodyColor" : [ 0, 0, 0, 0 ],\n      "MainColor" : [ 0, 0, 0, 0 ],\n      "ObjectID" : 171,\n      "ObjectType" : "Human",\n      "RelativeID" : 0,\n      "So
urce" : 0.0,\n      "Speed" : 0,\n      "SpeedTypeInternal" : 0\n   },\n   "PTS" : 43147700720.0,\n   "RuleId" : 0,\n   "Source" : 36139320.0,\n   "Track" : null,\n   "UTC" : 1597746548,\n  
 "UTCMS" : 531\n'                                                                                                                                                                             
2020-08-18 10:29:08 '\r\nCode=IntelliFrame;action=Pulse;index=0;data={\n   "Action" : "Start"\n'                                                                                              
2020-08-18 10:29:11 '\r\nCode=CrossLineDetection;action=Stop;index=0;data={\n   "Class" : "Normal",\n   "DetectLine" : [\n      [ 4605, 1823 ],\n      [ 7317, 5639 ],\n      [ 5388, 8045 ],\
n      [ 1329, 6684 ],\n      [ 3240, 2066 ],\n      [ 4660, 1872 ]\n   ],\n   "Direction" : "RightToLeft",\n   "EventSeq" : 2,\n   "FrameSequence" : 5947404,\n   "GroupID" : 2,\n   "Mark" :
 0,\n   "Name" : "Rule1",\n   "Object" : {\n      "Action" : "Appear",\n      "BoundingBox" : [ 4480, 1280, 5072, 2704 ],\n      "Center" : [ 4776, 1992 ],\n      "Confidence" : 0,\n      "F
rameSequence" : 0,\n      "LowerBodyColor" : [ 0, 0, 0, 0 ],\n      "MainColor" : [ 0, 0, 0, 0 ],\n      "ObjectID" : 171,\n      "ObjectType" : "Human",\n      "RelativeID" : 0,\n      "Sou
rce" : 0.0,\n      "Speed" : 0,\n      "SpeedTypeInternal" : 0\n   },\n   "PTS" : 43147700720.0,\n   "RuleId" : 0,\n   "Source" : 36139320.0,\n   "Track" : null,\n   "UTC" : 1597746548,\n   
"UTCMS" : 531\n'                                                                                                                                                                              
2020-08-18 10:29:11 '\r\nCode=IntelliFrame;action=Pulse;index=0;data={\n   "Action" : "Stop"\n'

I have no idea what the “IntellifFrame” event refers to, but it always occurs in conjunction with tripwire. Just included for completeness, and can surely be ignored.

1 Like

Not sure if its working yet, but did you try the ONVIF integration?
I think its suppose to work with events…

No, I have not tried the latest ONVIF integration, but will when I get a chance.

There is a new version on ipcamtalk from the dahua API.
https://ipcamtalk.com/attachments/dahua_http_api_v2-76-for-ipcamtalk-_com-pdf.61808/
Current version from dahua that needs a NDA is DAHUA_HTTP_API_V2.84.