Dahua IP cam IVS event as binary_sensor equals smarter camera motion detection

I would absolutely buy them again.

Thanks.

Had some more questions, to make sure i don’t purchase the wrong stuff. Do you use blue iris or a standalone dahua nvr?

Can the script monitor ivs events from the nvr directly, if the cameras are connected directly to an nvr with built in poe?

If my cameras are directly connected to the nvr via the nvr’s built in poe switch then can h.a. access the cameras directly to check for ivs events?

My current setup is.

Unifi usg router -> Unifi 8 port poe switch -> Unifi wireless AP.

I was hoping to use only 1 port of the switch and run that to the nvr then have the nvr connect to 2-3x cameras.

I’m not sure. I can only tell you my setup. My cameras connect to my unifi 24 port poe switch. My qnap NAS records the video streams. The Python script monitors each camera for IVS events. As long as you have network access to each cameras ip address I don’t see why you couldn’t connect them to an NVR.

1 Like

That’s great. Thank you.

Hey
I tried to add multi cameras and it didnt work .This is my config.
thanks in advance
https://paste.ubuntu.com/p/hzCDSJBVvR/

Is your username and password the same?
Your password !secret is pointing to your !secret username entry!

Hey
Yes iam using same usename and password for all the cameras.

@johnnyletrois i tried your script but couldn’t get it to work (i ran out of time so didn’t spend hours on it). Main question is, where do you leave the script? Do you have it running “stand alone” or have it inside the “python_scripts” folder inside hassio?

Do you have an “guide” on how to use this script?

I would like to use this script instead of the FTP upload / folder watcher combination i used before. In that situation i let the Dahua Camera upload an snapshot when motion was triggered and used the “folder_watcher” component to discover newly uploaded images and trigger automations. It works but i rather use an MQTT solution like you did.

I run it in a standalone python docker container. Sorry, but I don’t have a guide other than configure the script, run it, and enjoy the MQTT binary sensor goodness.

Running HA v0.91.3 in a pyvenv. Was able to copy your code into the custom_component directory structure and get it to run. Looking at the hass.log, I see that the component seems to be setup AND that it is detecting motion events on the one camera I currently have integrated:

2019-04-12 12:05:59 WARNING (MainThread) [homeassistant.loader] You are using a custom component for dahua_event which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-04-12 12:06:00 INFO (MainThread) [homeassistant.setup] Setting up dahua_event
2019-04-12 12:06:00 DEBUG (SyncWorker_8) [custom_components.dahua_event] Added Dahua device at: http://192.168.xxx.xxx:80/cgi-bin/eventManager.cgi?action=attach&channel=1&codes=%5BVideoMotion,CrossLineDetection,AlarmLocal,VideoLoss,VideoBlind%5D
2019-04-12 12:06:02 INFO (MainThread) [homeassistant.setup] Setup of domain dahua_event took 2.3 seconds.
2019-04-12 12:06:04 DEBUG (Thread-3) [custom_components.dahua_event] [frontdoor]: HTTP/1.1 200 OK
2019-04-12 12:06:04 DEBUG (Thread-3) [custom_components.dahua_event] [frontdoor] OnConnect()
2019-04-12 12:07:04 DEBUG (Thread-3) [custom_components.dahua_event] [frontdoor]: -- myboundary
2019-04-12 12:07:04 DEBUG (Thread-3) [custom_components.dahua_event] [frontdoor] OnDisconnect(Failed writing body (0 != 101) (23))
2019-04-12 12:07:09 DEBUG (Thread-3) [custom_components.dahua_event] [frontdoor] OnDisconnect(Success)

However, I cannot find any associated component or event actually occurring in HA. Were you able to have a component created? How do I get these events other than from the hass.log?

Hey
How did you put the file in the structure for 0.91.3?

i tried
/home/homeassistant/.homeassistant/custom_components/dahua_event/dahua_event.py
and also
/home/homeassistant/.homeassistant/custom_components/dahua_event/event.py

i also put a empty file called init.py
Package dahua_event setup failed. Component dahua_event cannot be merged. Expected a dict.

in the custom_components folder, create folder called dahua_event. In the folder, copy the file from git hub, but rename it to init.py (notice double underscore).

I ended up using this https://github.com/psyciknz/CameraEvents (it uses that same code)
But am still having a little trouble getting it to start on boot… but it works. I started trying to make it a component but it’s gonna take me awhile… :roll_eyes:

Tips you can get settings also http://192.168.1.108/cgi-bin/configManager.cgi?action=getConfig&name=VideoAnalyseRule

What are the prerequisites of using this?
I’m a n00b using Python :slight_smile: Using Hass.io on a rPI3b.
Tried some stuff, not working including AppDeamon.

I’m using a Dahua NVR with 5 channels. Already configures intrusion detection.
The API is returning the camera ID, so it’s working. But now I want to do a ‘on’ / ‘off’ just like some other binary sensors for doors/windows in HA.

I’m not using MQTT, don’t really think it’s having advantages in stead of what I’m using right now.

Love to figure somethings out but this is exhaustively haha

Edit: also in Dahua IPC to MQTT App

I added a forked repo that is updated and it support home assistant 0.92 https://github.com/JLFN/home-assistant-dahua-event @SaWey are you running newest version of home assistant?

1 Like

I’ve just tried to add your forked repo as a custom_componet. I’m running HA v0.92 in a pyvenv and did install pycurl v7.43.0.2 inside my venv.

When I run HA, I don’t see any errors in my logs and do see the following message:

2019-05-01 13:57:14 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for dahua_event which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

This seems to indicate it has been successfully loaded.

However, I’ve now add the following to my configuration.yaml:

dahua_event:
  - name: driveway
    protocol: http
    host: 192.168.200.200       #IP of my camera, not my real IP
    port: 80
    user: !secret dahua_username
    password: !secret dahua_password
    events: VideoMotion,CrossLineDetection,CrossRegionDetection

I don’t see any component being added to HA, there is not dahua_event to be found. I’m assuming I should see a component like “dahua_event.driveway”.

I recommend you using MQTT version instead i got it working on docker fast and easy.

im trying the custom component from sawey but i constantly get this error:

'Component error: dahua_event - Integration 'dahua_event' not found.'
What im i doing wrong?

custom component/
create file:
1/ int.py,
2/ dahua_event.py