Hikvision NVR - line crossing

I’ve set up a new ST integration with my Hikvision NVR. I have some IP cameras that have a feature that detects an object crossing a virtual line. I’ve created a driveway entry line and configured the NVR to close one of its dry contact closures when something crosses this line. This gives me a virtual driveway entrance event. I connected an ecolink contact sensor (which has dry contact inputs) to the NVR closure output, and linked the sensor to ST. I’m now using notify me when to send a push notification when someone enters the driveway, and Smart Lighting to turn on some floodlights when someone enters the driveway at night after I’ve gone to sleep.

Hope this gets the wheels turning for anyone else with these NVRs!


How did you integrate the NVR?

As stated above, the integration is done with a z-wave dry contact module. No software integration.


How reliable is the virtual line crossing on the NVR?

I set it up directly on two Hikvision cameras and get a lot of false alarms.

So, I think the actual line crossing detection is performed in the camera, not the NVR. It only works for my IP cameras, not the TVI cameras attached to the NVR. That said, it’s been very reliable over the past few days for the above pictured camera. However I have it set up on another camera and was getting a lot of false alarms due to trees making shadows on the ground while blowing in the wind. I’ve switched to intrusion detection for that camera and will see if that helps.

I’d suggest using NVMS7000 to watch the live view from the camera. It will show the objects that the line detection algorithm is recognizing, which could help you fine tune the placement. The algorithm draws a box around objects that it sees, so the recognized area might be much bigger than expected if you have an object positioned diagonally with respect to the camera view.

Just curious which model you have? I see they have a hybrid that can mix analog and IP cameras (I think)…

It’s an LTS (rebranded Hikvision in USA) LTD8508T-ST, which is a hybrid DVR with 8 channels of 3MP TVI and 2 IP channels. I went with that since I was upgrading from an analog system and had a fair amount of coax run through walls, etc. already.

Very clever/inventive! I like the idea and definitely following.

It would be cool if the NVR itself could be integrated much the same way as the Ubiquiti NVR has been.


Done. :slight_smile: I’ve integrated mine last night via node.js running on a raspberry PI 3, using the email configuration in the NVR. The node.js app exposes a very limited SMTP server that accepts all the alert emails from the NVR, parses them, then forwards them to the intended destination, basically a middle-man. It then sends notifications to a web service smart app that automatically generates a motion device for each camera and intrusion event (i.e. Front Door Intrusion Sensor, Front Door Line Crossing Sensor, Front Door Face Detection Sensor etc.) - you just need to trigger each event once to get the device to show up in ST. I’ll publish the code if anyone wants it, it’s pretty simple.

Find the very first release here https://github.com/ady624/hikvision-nvr

My apologies if the instructions are not very clear, haven’t had time to review them.


I tried following your instructions to setup the hikvision-nvr smartapp but could not find the accesstoken or appid in the IDE under the “HIKvision Motion Sensors” application state. Is there another way to find this information if it isn’t listed there?

It is under the SmartApp, go to Locations > smartapps and then go find the smart apo and click on it

When I go to Locations > smartapps > Hikvision Motion Sensors I don’t see anything that looks like an access token (see screenshot below). All I see is a string of characters at the bottom of the image that looks like it could be the app ID (blacked out in screenshot). Am I missing something? Where should I see the access token?


Did you enable Oauth for the app? If not, do it and please reopen the app and go through the config.

After enabling oauth and removing/re-adding the smart app I was able to find the app token and finish configuring the NodeJS server. I have also verified that the mail server running on my raspberry pi 3 is successfully receiving the NVR event emails since they also get forwarded to a different email address. However, I’m not seeing any new motion devices for the events that I have triggered after setting up this server (i.e. event type “Motion Detection”). I assume that the new motion devices will show up when I go to “Add a thing” in smartthings (rather than magically showing up in my list of things). Any ideas what I’m doing wrong?

Thanks for your help.

You need to make sure you installed the DTH and no, the devices will happen as you get alerts from your cameras. Go in front of each camera and devices should be created for you automatically. Just make sure you installed and published the DTH

Apparently my HIKVISION camera formats the email events differently so I had to modify the app.js script to identify my camera name and number correctly since they were not being parsed in your script. My camera email events include the following text:

EVENT TYPE: Motion Detection
EVENT TIME: 2018-01-29,17:42:27
IPC S/N: DS-2CD2342WD-I2017xxxxxxxxxxxxxxxxxx

I just added the following lines to the switch statement:

case 'IPC NAME': cameraName = data; break;
case 'CHANNEL NAME': channelName = data; break;

With these changes I also noticed that the script was making multiple web requests and I was ending up with duplicate smartthings devices, so I moved the web request part of the script outside the for loop and now I only see one web request per event and don’t have any duplicate devices.

Thanks for the help and the cool script.

1 Like

Yeah, mine is a LaView NVR which is technically a rebranded Hikvision. Glad you got it working!

Oh, I like where this went. I’ve got a Lorex rebranded Hikvision. Intercepting SMTP enough to feed ST seems like a nice way to bring in just about any alert\notification that you want.

I’ll work my way through when I have a few hours. Thanks!


Where do I find the NVR folder to download onto the Raspberry?

I did the 3 sudo install commands:

sudo npm install smtp-server
sudo npm install mailparser
sudo npm install nodemailer

But when I go to run the test command after, nothing happens. When I list the contents in /node there is nothing. I’m sure I am missing something simple - help?

throw err;

Error: Cannot find module '/var/node/nvr/app.js’
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Function.Module.runMain (module.js:701:10)
at startup (bootstrap_node.js:190:16)
at bootstrap_node.js:662:3

(Trying to Oauth and ST IDE is just sitting there…might be down)

After searching for a solution to integrating my Hikvision NVR with Smartthings I decided to put together my own integration. Thanks to ady624 and his code, it inspired me to write my own python script to connect events and alarms that are triggered by the NVR to my ST hub.

ady624’s code sets up a mail server to receive and redirect emails. I didn’t want to go this way, and since I am already running python code to integrate ST with my DSC alarm system, I decided to expand on this.

I posted it on github and this is the first release after a few weeks of testing it out. You can find it at https://github.com/rtorchia/Smartthings-Hikvision-Events

Again, thanks ady624 for the SmartApp, which made things easier to code for.