Hikvision Cameras with motion sensor enabled

Attaching my personal implementation file for Hikvison cameras.

Features: Motion sensor, high-quality 6mbps stream.
Instructions: Install the Hikvision plugin from the store, overwrite with the attached file in Apps->Develop apps → Luup files.
Create camera devices as instructed in this thread but use the attached file instead.

NOTE that I’m not a developer and I did not create this from zero. It’s based on a beta internal file with a few personal touches. Please don’t ask me to debug this.
Feel free to edit this per your personal needs.

Unzip the XML file and upload to Vera Luup Files.
I_HikvisionIPCamera.zip (14.9 KB)

Hmmm. Up until now, didn’t believe in having cameras on Vera, but motion detection is tempting. Although I have the same areas covered by outdoor PIR detectors. But still…

You can use Blue Iris and have it signal motion to Vera. I have a scene that arms Blue Iris to record on motion and that motion allows Vera to send me notifications.

It worked in ui5 !
In ui7 nothing with motion sensed cameras seems to work.
And the way pictures are shown in ui7 is bad compared with ui5.

Thanks been waiting for this! i’m installing it over the weekend. Im using a hikvision cctv system - DS-7208HQHI-SH and DS-2CD2F22FWD. I will update how it goes…

Got it working even without the app. I used the link below to configure new cameras (using other IP cameras).
http://username:password@192.168.0.xxx/ISAPI/Streaming/channels/101/picture?videoResolutionWidth=1920&videoResolutionHeight=1080

Thanks

Is there a certain firmware or model line of Hikvision needed for the motion detection to work?
I thought I had been over all the Hikvision settings, and never found a way to have the camera call an HTTP to queue the motion detection…

[quote=“wilme2, post:7, topic:197072”]Is there a certain firmware or model line of Hikvision needed for the motion detection to work?
I thought I had been over all the Hikvision settings, and never found a way to have the camera call an HTTP to queue the motion detection…[/quote]

As far as I know Hikvisions don’t send an http on motion. They do update a running log of motion detected but you need program/app to snif this and act accordingly. Blue iris will do this along with the Hikvision NVR and probley others. The http link posted above seems right for a camera stream but has nothing to do with using the built in motion detection on the camera as far as I know.

I don’t see any mention of this being a DVR function, but I just pulled up the plug-in and it looks specific to a couple of cameras. Cameras with built-in PIR detectors. So this post is real confusing unless you know that…

Description: Plugin for Hikvision IP cameras. For UI7 only. Supported camera models : - DS-2CD2Q10FD-IW - Hikvision Mini PT - DS-2CD1410F-IW - Hikvision IR Cube NOTE: This is an ALPHA version!

I don’t see any mention of this being a DVR function, but I just pulled up the plug-in and it looks specific to a couple of cameras. Cameras with built-in PIR detectors. So this post is real confusing unless you know that…

Description: Plugin for Hikvision IP cameras. For UI7 only. Supported camera models : - DS-2CD2Q10FD-IW - Hikvision Mini PT - DS-2CD1410F-IW - Hikvision IR Cube NOTE: This is an ALPHA version!

So this plugin will read the stream and look for that PIR trigger. I do use once of these cameras on the front porch for two way audio, but I do not use the PIR due to false triggers. But it is a good way to double up PIR and Motion to maybe make less falses. A single PIR is just not made to be very accurate outdoors.

Worked for me…in ui5.

You had this plugin before it was out?

Hi. Very happy with my current Vera Plus + Hikvision + GoControl door/window sensor. The DVR software triggers line crossing alarms in my perimeter to my Vera Plus via the gocontrol sensor. The VeraPlus is able to blink my lights or enable strobe alarms depending on room location and time of day. Then I use my DVR to send me pictures via email so i know when the kids arrive from school using the same line crossing trigger.

Initially, I was able to link my cctv dvr thru the http link in reply #5. Had alot of dropped/skipped frames so i was better live viewing it through the hikvision mobile app. Still trying to figure out a good use for this. If I use this to save pictures, i’m not sure if i will overfill my veraplus memory or if it is saved in the cloud.

I was able to recently connect, by wire, my spare GoControl door/window sensor to the analog alarm output of the dvr. The magnetic door sensor has provisions to connect a wire. I enabled and configured my DVR’s line crossing feature to send an email and enable alarm output when triggered. Then I created a scene in Vera that when the window sensor closes it triggers certain activities. The line crossing feature is alot better than the motion detection as i rarely (almost none) false alarms.

I think the dvr is also capable of sending an http alarm (instead of connecting a door/window sensor by wire) but i do not know how to configure it in the hikvision dvr and in the vera plus

The I_HikvisonIPCamera.xml contains the data to let work a Hikvision IP camera except the Motion Detect function,
which was not working.
But…

Looking at Function startStreaming() ; (from I_HikvisionIPCamera.xml)
The part ‘/ISAPI/Event/notification/alertStream’ filters the data stream from the Hik Camera and puts
the results in the file “/tmp/HilkvisionOutput_devno.txt”

This file contains series of

x.x.x.64 80 HTTP x:x:x:x:74:fc 1 2017-10-16T13:18:39+01:00 0 videoloss inactive videoloss alarm --boundary Content-Type: application/xml; charset="UTF-8" Content-Length: 480 x.x.x.64 80 HTTP x:x:x:x:74:fc 1 2017-10-16T13:21:25+01:00 39 VMD active Motion alarm --boundary Content-Type: application/xml; charset="UTF-8" Content-Length: 517

(about three blocks per second.)

The eventType VMD occurs always when the camera detects Motion.
EventType VDM can come together with eventType fielddetection, linedetection or shelteralarm
EventType videoloss is given when there is no Motion
Each eventType is counted exept videoloss which counts always 0

File “/tmp/HilkvisionOutput_Devno.txt” is processed in the function getStreamEvents()

Change from the function getStreamEvents()
the line

	if newEvent:find("<eventDescription>PIR alarm</eventDescription>")
in
	if newEvent:find("<eventType>VMD</eventType>") 

then the Motion detection works fine.

It is now possible to programm when a eventType VDM expands with eventType linedetection (closer approach from the intuder)
Log those events with a timelabel or use them in MultiString or MultiSwitch app and you you are well documented.

You can see the eventTypes and counts using a Putty session and executing the command:

curl -s http://username:passw@camip/ISAPI/Event/notification/alertStream |
awk -F ‘[<|>]’ ‘//{if ($3 != “videoloss”){print $3}} //{if ($3 != 0){print $3}};’

Regards

loukt
Vera Plus
Firmware 1.7.3232

[quote=“loukt, post:14, topic:197072”]The I_HikvisonIPCamera.xml contains the data to let work a Hikvision IP camera except the Motion Detect function,
which was not working.
But…[/quote]

Just wanted to say thanks for putting this together, and to the original contributors. Using the troubleshooting curl command line you specified with my LaView LV-PB932F4 (rebranded Hikvision bullet cams), I was able to discern that my ‘eventType’ was ‘linedetection’ and get the motion sensing working.

For anyone else trying to use this plugin, it absolutely does NOT work well with UI5, the APIs for device creation are all wrong (though it has some code commented out you can hack through). I also found this code does not work well for hard-wired POE cameras like I have, even ignoring the hard-coded model #s in the source code.

I’ve stripped the code down to ignore the model, and only focused on getting the linedetection search working for my cameras (no wifi setup, no audio sensor, no PTZ, etc), so this may not work for anyone else, but after days of getting this working properly I figured the least I could do was contribute back in case it helps anyone else. The polling getStreamEvents() function was brutal to get working with multiple cameras (it kept crashing my VeraPlus Lua loop), which is where I spent most of my time debugging and modifying the code to streamline it (I’m filtering down to just get the eventType fields, not the whole alertStream).

I’d recommend adding the cameras via the ‘Add Device’->Generic IP Cam->Manual process, and then simply add change the Impl File (to the attachment below after uploading it to the Vera) manually after the camera device is created. I struggled trying to get things working using the original thread directions (via the Create Device in Apps) and it would cause my VeraPlus UI7 to constantly crash (I think it was related to the Streaming functions wreaking havoc for some reason).

Also, I cannot get video streaming to work through my LaView NVR. It defaults to video emulation mode, leveraging the ‘/ISAPI/Streaming/channels/101/picture’ URL for each camera, and because I’m using an NVR with the ‘Virtual Host’ option, there doesn’t appear to be a way to give it an RTSP stream that it would be happy with. Oh well, at least I can see the images, and leverage the linedetection logic!

I have a Laview NVR. To get full streaming (will only work with the mobile app) you need to change the streaming option to
rtsp,rtsp,:8554/PSIA/streaming/channels/101
the next camera would be 102 etc
hope that helps

[quote=“jimmyz, post:16, topic:197072”]I have a Laview NVR. To get full streaming (will only work with the mobile app) you need to change the streaming option to
rtsp,rtsp,:8554/PSIA/streaming/channels/101
the next camera would be 102 etc
hope that helps[/quote]

Thanks Jimmyz. I assume this means you haven’t put the port in the ‘IP’ field already? Since I’m using the Virtual Host option on my DVR, everything I’ve read suggesting using the IP as x.x.x.x:65001 for the first camera, x.x.x.x:65002 for the second camera, etc for the IP address. So I don’t think this would allow me to specify the Streams option using the :8554 in the URL as you’ve done? At least it doesn’t seem to work for me.

Maybe you simply specify the x.x.x.x in the IP address, and then for all the URLs for access, you put the :6500X in the URL field as well?

Here are my settings- I added the nvr per the first post using this:
rtsp://user:pass@IPADDRESSOFNVR:8554/PSIA/streaming/channels/101
you do not have to use the virtual host option this way- just change cameras, camera 1=101; camera 2=201 etc

[quote=“jimmyz, post:18, topic:197072”]Here are my settings- I added the nvr per the first post using this:
rtsp://user:pass@192.168.2.30:8554/PSIA/streaming/channels/101
you do not have to use the virtual host option this way[/quote]
Makes sense. Sadly that will not work with the motion/line-detection stuff, as you need to leverage direct access to the camera to access the alertStream (which is why I’m using the Virtual Host option).

Your post did get me to thinking however, so I went back and reworked the code to not expect the port # in the IP address, which lets me use the 8554 port for the streaming interface like you did, AND I added a new variable to hold the alertStream URL in it (with the appropriate 6500X port # for the Virtual Host of the camera). Works like a champ.

I also discovered my curl | grep pattern was sadly delaying the notification cycle, since it’s buffering between the two commands, so I reverted back to the original method of dumping the complete (and verbose) output of the curl command. There’s still a bit of a delay between when the Hikvision reports the linedetection event in the alertStream, and everything triggers (via Scenes or whatnot), but I guess it’s liveable.

Now if only the ‘Record Video’ trigger would work with the rtsp stream on these cameras (at least we can capture images with them via Scenes).

great- can you post your new code- I would love to try it out thanks in advance