domoticz-ipcc - Connect your Dahua/Hikvision IPC to your Home Automation System.

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,324
Location
Denver, CO
domoticz-ipcc - Dahua/Hikvision Events via MQTT/Domoticz

Goal: Easily Integrate your IP Security Cameras into your Home Automation project as Motion Detectors, with Alarm IO.

Source: https://github.com/nayrnet/domoticz-ipcc
Issue Reporting: https://github.com/nayrnet/domoticz-ipcc/issues
WiKi: https://github.com/nayrnet/domoticz-ipcc/wiki

ok I hinted at this in my automation roll out thread, and I released a raw dahua API module yesterday, but I just wrapped up the first beta release of my IP Camera Controller. Only Dahua support right now, Hikvision support coming VERY soon, and I can help add support for any vendor that implements a similar http alarm stream.. I started off with multiple vendor support in mind so this project should extend very well.. If your interesting in helping with development/testing/hardware/documentation contact me through here or Github

This will probably work just fine on all Unixes without modification, windows users might have luck also but you may have trouble detecting a camera dropping off the network and reconnecting.. as I dont believe the module I used for modifying TCP sockets timeout works on windows, I tried to make it cross platform but that was required to quickly detect a camera suddenly disconnecting. if someone is willing to come up with a cross platform solution I'll be happy to take pull requests.. until then consider windows untested and unsupported.

Ok so what does this do? It connects to all your supported cameras's and monitors an alarm stream, when an alarm event is triggered on the camera the software INSTANTLY publishes the change via MQTT for your Automation Software to then read..

Whats MQTT? Well Basically its a Publish/Subscribe messaging system for IoT devices... in the simplest example:
You connect to the same MQTT Broker as IPCC (localhost usually), subscribe to ipcc/CameraName/VideoMotion, and now any time there is motion detected you will be pushed a value of true, and when motion subsides you will be pushed a value of false.. Many home automation controllers, sensors and devices are capable of communicating via MQTT and if yours is not its very easy to use external apps and scripts to retrieve the data you need.

standard MQTT Flow:


This is a very popular protocol for interfacing Arduino's and other little IoT (Internet of Things) devices so everything is using the same interfaces without constantly polling for updates and getting slow responses.. for example if you setup a bunch of wired motion sensors to an arduino on your network it would be a piece of cake to use existing MQTT libraries to publish PTZ presets to react to those changes, while also allowing your arduino to react to motion/inputs events from the camera for more advanced logic and control.. (like make sure its not looking at something more important before telling it to move)

And now about Domoticz, so you dont want to figure out MQTT and handling the raw data? Well its already setup to talk to Domoticz out of the box, and that is the development priority.. it is also Free Open Source software and supports ZWave/RfLink/Insteon/X10/Hue and many more, plus it has a ton of notification options like email/pushover/kodi/growl/nma/etc.. at the very least you can simply use Domoticz as the scripting and logic engine for your IPC's and nothing else. Domoticz comes with three very easy to use scripting languages, Python (Advanced), Lua (Simple) and Blocky (Graphical), provides easy to access SunRise/Set calculations, timers, etc.. You can download precooked images for the Raspberry Pi, that will get you going with full GPIO support right out of the gate.. I couldn't make this any easier for you guys if I tried, and I really am.. but be prepared for a ride if you not already versed in Linux... If this was windows oriented you'd be paying for it, so your welcome.

This is my NVR Philosophy, use my Home Automation system for all Notifications/Logic/Control and simply record 24/7/365 to a network share.. If you need to review any footage use standard viewers and inspect logs contained within the Home Automation software to locate the times of events... I've found blowing away the old idea of NVR software and going for the Automation Device strategy far more feature rich and extendable solution.. especially for us using linux, ZoneMinder is a total joke by modern standards.. IMHO Cameras make better TCP connected Motion Sensors for Home Automation than they do for triggering recordings.. Video Motion detection seems to work so much better at telling an automation system something is going on so real logic can be put around its reactions.. compared to stupidly firing off binary tasks with no other thought about how many times its been happening, or whats most important if it gets conflicting events.. and if you have a PTZ you'll definitely feel these pains.

Future Support:
  • Switching Day/Night Mode via Domoticz & MQTT, because your Home Automation system knows best
  • Sending Basic PTZ Commands in via Domoticz & MQTT (AutoTracking with limitless Sensors!)
  • Controlling Camera IO Outputs, you can never have too many outputs in Home Automation.

Cheers,
-R

PS: A bit of Eyecandy
Domoticz Logs, the graph is dynamically zoomable, exportable as image or raw data, it was a very windy day and I had these set to go off with the slightest motion.. great for development :p


Domoticz Devices:
 
Last edited by a moderator:

pfer10

n3wb
Joined
Dec 30, 2015
Messages
12
Reaction score
1
Been using Domoticz for a couple years after trying a couple other HA software but they were never flexible enough. Domoticz has been very nice to deal with but I haven't gone as hardcore as you have! Just done some basic stuff like controlling my heat with some custom scripts and using the blower to help heat the house as the great south room has huge sun exposure. I have saved some energy this winter by just using the blower to help distribute the solar heat throughout the house. Looks like it is time to dust off my extra BBB to integrate some stuff from the barn. I have seen the Domoticz slave feature but never really thought about using it. Been wanting to try out MQTT anyway.
Just been getting into some better cameras as I have had some old X10 Airstream junkers for years but slowing getting into some better stuff. Looks like I should stick with Dahau as I have two of those so far and they seems nice. I also bought the mini PTZ Huisun last year. Can't believe how good that thing is at night. Seems like people have said their motion detection in the camera isn't that hot though. Now it looks like I have an excuse to start trying the built in motion detection in these cameras. Thanks for all your work! I got some studying to do.
 

Abbell

Getting the hang of it
Joined
Mar 9, 2016
Messages
114
Reaction score
17
Can Domoticz be setup to send Json calls to a Blue Iris server? I have started hacking things and I will probably use an arduino to control some inputs and send those out. I just bought a $11 wireless doorbell and de-soldered the board in it to become a reed switch alarm for my mailbox etc...
What I want to do is use logic controls to send commands to Blue Iris and it looks like the Json commands will work more effectively than the BIcommand instructions.
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,324
Location
Denver, CO
should be doable with an external script at least, I dont know how BI communicates sorry.. but posting JSON is easy to script.
 

Abbell

Getting the hang of it
Joined
Mar 9, 2016
Messages
114
Reaction score
17
From what I understand you can sent Http-POST and Http-Get commands directly to the Blue Iris web server. I have not written web pages since... well, let's just say 1Mbs was considered fast. Can an Arduino send such commands? I just built a ClearOS firewall and I think I can add Domoticz to the box once I figure out how to add it.
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,324
Location
Denver, CO
http-get commands are supported right out of the box in Domoticz, you can have any switch/button/task/script do a http-get request even easier than a post.
 

smoothie

Pulling my weight
Joined
Dec 19, 2015
Messages
223
Reaction score
178
This looks like a fascinating project nayr. I am in the market to start replacing my old analog cam system with high res IP cams, specifically Dahua brand, and the home automation aspects are very appealing. I am happy to help with this project in any way I can. Once I have installed Cat5E cables around my house I am going to start ordering cameras. I am planning to order the cabling this weekend and start installing it next weekend. Once I actually have the foundation of the new system I imagine I could actually be useful to you and the project. Basic plan at this point is i7 dell workstation from 2012 as the NVR, OS and NVR software undecided, considering Windows or Linux and Blue Iris, Milestone Xprotect, and the Dahua software whos name escapes me at the moment.
 

ESFnl

n3wb
Joined
Oct 30, 2016
Messages
4
Reaction score
0
Nayr, l'd like to help you with testing other hardware. I'm running Domoticz on a RPi for a while and have a NVR with PoE IP cameras. The brand and model are called Longse LIZM40. What passages within your code do I have to change to make these cameras work?
View attachment Longse IPC-LIZM40 - LIZM40S200.pdf
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,324
Location
Denver, CO
Its never going to work with Longse or any other manufacturers without a well documented api..
 

ESFnl

n3wb
Joined
Oct 30, 2016
Messages
4
Reaction score
0
Past weeks I made some progress with my Longse camera's. I would very much appreciate any directions for further progress.

Steps I took:
- Googling for documentation on Longse LIZM40 -> no success
- contact my Dutch reseller for the API -> no success
- contact different persons at Chinese supplier Longse -> no success
- found a website about 'reserve engineering' and led me to Binwalk. For me this was a total new field. As a noob I am proud that I successfully unpacked the firmware! In the folder I discovered different html pages and many JavaScript files! Via GoogleTranslate I translated some //comments from Chinese to English. Now I narrowed down the 1030 files back to some more promising 4 files with respect to motion.

Unfortunately I don't understand Java. Is it possible to use these scripts to connect to MQTT? Hopefully we can use the output because modifying the firmware and replacing it is more difficult and risky I think.

Thank you in advance.
 

Attachments

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,324
Location
Denver, CO
If you want these capabilities, the answer is pretty clear; dont use Longse or any other fly by night junk builders; make your purchasing decisions based on if they have a documented API you can program against..
 

randytsuch

Pulling my weight
Joined
Oct 1, 2016
Messages
495
Reaction score
176
So instead of using motion sensor lights outside, I use a dahua camera as a motion detector, and then domoticz with a zwave lamp or switch module will turn on the lights? I was going to add a motion sensor light for my front door, but I think I'll give this a try first.
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,324
Location
Denver, CO
yeah pretty much, your cameras become motion sensors within domoticz.. you can also hookup real motion sensor to an alarm input on the camera and use this to tie that signal in.. and both combined result in no false alarms really.

this program is why I favor cameras with alarm inputs; because I get to use those IO's within domoticz as hardwired sensors and it works fantastic, with both the NVR and my home automation system able to react to events.. I even turn my external strobe on/off.

I have a script on my github page that switches cameras to day/night profiles at sunrise/sunset via domoticz lua; thats really nice too.
 

ESFnl

n3wb
Joined
Oct 30, 2016
Messages
4
Reaction score
0
I understand you aren't positive about Chinese crap. Me neither. The story here is that I'm very disappointed myself too. I thought I bought a proper brand at a decent store. Both appeared different and I'm involved in unpleasant letters now.

Meanwhile I have to deal with this as it is. The camera's are working and linked into my Domoticz. I'd love to see them as motion sensors.

Would you please give me some suggestions in what area I have to study? I think I came close with revealing all script within the firmware.
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,324
Location
Denver, CO
those are just javascript files for the webui, dealing with configuring motion, etc.. they have nothing to do with the software running the camera and reveal nothing but configuration options.. you coulda seen those files with your browser in developer mode.

As it is, you cant use em as motion sensors in domoticz.. so yeah, deal with it.. your wasting time trying to implement that camera. I doubt there is even an API to reverse engineer.
 

randytsuch

Pulling my weight
Joined
Oct 1, 2016
Messages
495
Reaction score
176
Is there a Dahua turret with alarm input?
I tried looking, but search for alarm didn't help on their website.
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,329
Reaction score
5,324
Location
Denver, CO
nope, not a single turret/eyeball they offer has alarm IO
 
Top