[RELEASE] Hikvision Alarm (HTTP Listening/Data Streaming/Alarm Server)

Hi Hubitat Community! This is my first public release of code of any kind. I'm a HW engineer so my coding skills are very limited. I tried to make this extremely flexible to maximize the number of use cases. I hope this is helpful to someone and I welcome any suggestions to improve/fix the code -- I'm new to Hubitat & Groovy development, so I might be making a lot of rookie mistakes or have inefficient code.

https://github.com/ken830/Hubitat/blob/main/drivers/Hikvision%20Alarm%20Driver/hikvision-alarm.driver.groovy

Description
Driver to receive alarms from Hikvision cameras with the "HTTP Listening"/"HTTP Data Transmission"/"Alarm Server" feature. This feature may only be available on cameras with FW newer than ~v5.5.xx

Hikvision Camera Setup

  1. Configuration -> Network -> Advanced Settings -> HTTP Listening (or Alarm Server):
  • DestinationIP = [HubitatHubIP]
  • URL = "/"
  • Port = 39501
  1. Enable "Notify Surveillance Center" under Linkage Method for each event

Device Driver Setup

  1. Install driver on hub
  2. Add Virtual Device and Select this Driver
  3. Enter Camera IP Address and click "Save Preferences"
  4. Optionally, configure the sensors and buttons (see notes below)

Notes

  • Three independent sensor capabilities: Motion, Presence, & Contact
    • Each sensor has the following independent settings:
      • Event Type Filter
      • Inclusive vs Exclusive Filter Setting
      • Sensor State Inversion Setting
      • Alert Reset Time
    • By default, the filters are empty and exclusive, so all event types will trigger all three sensors.
    • To disable a sensor, leave the filter empty and make it inclusive
  • Six independent buttons
    • Each button has the following independent settings:
      • Event Type Filter
      • Reset Time (for preventing multiple triggers in quick succession)
    • By default, the buttons filters are empty, so nothing will trigger any of them

Version History
2021-02-07: v1.0.0 - Initial Release
2021-02-08: v1.0.1 - Updated Instructions to include the renamed "Alarm Server" feature. Moved preferences{} inside metadata{}.
2021-02-15: v1.1.0 - Significant update to add 6 customizable buttons in addition to existing 3 sensors.

Example Use Cases

  • Integrate your camera as a sensor suite to your home automation system:
    • Set the Hikvision Camera to send alarms for the following events:
      • Motion Detection
      • Face Detection
      • Intrusion Detection
      • Line Crossing
      • Unattended Baggage Detection
      • All Network/HDD faults
    • Configure driver to:
      • Trigger the Motion Sensor in response to Motion Detection alarms
        • Select "VMD" in the Event Type Filter
        • Disable Exclusive Filter (to make it inclusive)
      • Trigger the Presence Sensor in response to Face and Intrusion alarms
        • Select "fielddetection" & "facedetection" in the Event Type Filter (Use Ctrl & Shift)
        • Disable Exclusive Filter (to make it inclusive)
        • Set the Presence Alert Reset Time to 30 sec
      • Trigger the Contact Sensor in response to everything else
        • Select "VMD", "fielddetection", & "facedetection" in the Event Type Filter
        • Leave the Exclusive Filter setting enabled (to exclude the events already handled by the motion & presence sensor), but respond to everything else
  • Problems with package theft? Monitor the front porch for packages.
    • Set the Hikvision Camera to send alarms for the following events:
      • Unattended Baggage Detection
      • Object Removal Detection.
    • Configure the driver to:
      • Button 1: Select "unattendedBaggage" in the Event Type Filter
      • Button 2: Select "attendedBaggage" in the Event Type Filter
    • Create a rule in Rule Machine (Example below)
      • Trigger on Button 1, Button 2
      • Check which button was "pushed" and send the appropriate message

image

8 Likes

Works great. Thanks.

Glad to hear! It was something I was looking for when I saw your post, so I figured I can help both of us while having fun learning about device driver development.

1 Like

Looks nice will give it a go :+1:

Interesting - I'll have to give this a try as I use Hikvision. The only thing is my cameras are connected via the NVR so I can't use the http listening directly on the camera (without rerouting and reprogramming the cameras to connect via a LAN connected PoE switch as opposed to the NVR's camera network)

I'd like set up a rule to switch the living room TV HDMI input to the HDMI on which the CCTV system is displayed via Harmony when the line crossing is detected on the front door camera.

Yeah I was wondering this, my cameras are connected to the NVR's built in POE ports with there own subnet.

I'm guessing this wouldn't work if you're not using a separate POE switch.

I'm a CCTV installer so use Hikvision regularly. There's no such setting in the NVR network interface for http listening unfortunately. Surprisingly I've just found that the camera I wanted to use it on doesn't have it featured, though I'm sure I've seen it on that model previously (DS-2CD2346ISU/SL-G2 AcuSense) It may have been removed in the latest firmware. I'll have to check the other cameras to see which have that feature in the latest firmware)

It's relatively easy to fit a PoE switch at the NVR, adding the cameras to the LAN and reconfiguring the channels from Plug and Play to Manual. I may just do that.

EDIT: Http listening has been renamed "Alarm Server" on the newer firmware.

Unfortunately, I don't have any experience with NVRs. I never got around to buying one since the cameras can show live image, playback, trigger alarms & recordings, support edge storage on SD card, and can record over the network to my NAS. And IVMS works well enough on my desktop directly from the cameras.

I did spend a little bit of time researching and it appears Hikvision NVRs have a "Virtual Host" feature that allows direct access to the cameras from the LAN side to the camera side. I think you can also plug in the LAN to the camera side of the NVR.

@johnwill1: Thanks for that... I'll edit the instructions. Hikvision isn't exactly great with documentation... "Alarm Server" appears to show up in 2020. Strange that my brand new ColorVu turret with x5.6.xx FW still says "HTTP Listening." So does your 2CD2346xxxG2 have "Alarm Server" afterall?

And that's a great idea with switching the TV's input with a line-crossing trigger.. You'd have to have pretty reliable triggering. I'm planning to do something similar with a tablet-based alarm panel

I think for older FW cameras, we can fall back on an ISAPI-based driver to listen to connect to the the alert stream. Not sure if a constant stream of data will slow down the hub or not.

Yes virtual host allows you to access cameras that are connected on the PoE ports of the NVR by appending the NVR IP address with a port number, for instance if the NVR is at 192.168.0.100 camera 1 becomes accessible at http://192.168.0.100:65001, camera 2 at :65002 and so on. Otherwise you'd need to connect up to a spare PoE port and reach them at 192.168.254.xxx

If depends whether you have the original ColorVu released in 2019. Those use the G1 platform firmware and show "http listening" - those ColorVu turrets are models DS-2CD23x7G1. They're actually the "old" model now as Hikvision have recently released the DS-2CD23x7G2. These combine the ColorVu and AcuSense technologies into one camera. They use the same firmware (confusingly it's the G3 firmware that goes on a G2 camera) as my AcuSense 2346G2 that has "alarm server". As can be seen in the image, the path hasn't moved. It's just the name that's changed and also there can now be three destination paths as opposed to one.

Firmware updates are quite regular on Hikvision models that are current, so it's worth checking regularly. In the UK and EU ColorVu G1 cameras are at version 5.6.5, AcuSense G2 and ColorVu G2 (G3 firmware) are at 5.5.150. I'm not sure what the address of the download portal is in the US or other regions but for the EU it's hikvisioneurope.com/portal and for the UK it's hikvisioneurope.com/uk/portal

1 Like

I'm assuming the 650xx port is port-forwarded to the web GUI (port 80?). Can the cameras reach the LAN with Virtual Host enabled? I'm guessing not.... so the HTTP Data Transmission (<- that terminology remains) feature probably won't work through the NVR in this manner..

Here in the US, we also use the European portal.. at least I do.. http://www.hikvisioneurope.com/portal/?dir=portal. I had to "downgrade" to v5.6.2 on my DS-2CD2347G1-LU to be able to play with triggering the "supplement light" from events. Still testing on my desk and not sure how I feel about the behavior yet. I think eventually, I can get Hubitat to control the supplemental light, I would do more advanced triggering and control of the cameras that way.

image

I see reviews of the ColorVu G2 turret on forums, but we don't have them yet (maybe greymarket only). I do see the ColorVu G2 in bullet form, but I don't really want that form factor for my home. What's your impressions of the new generation? Is it much of an upgrade? I think the sensor is the same, but the processing power upgrade seems significant.

If you don't mind... maybe I can reach out to you for your opinion/advice on Hikvision equipment in the future.

That's correct - it just simplifies accessing the NVR connected cameras while on the LAN and allows us to port forward 65001 - 65016 in the router if we want to access the cameras webpage menu from the WAN (this is handy for me as an installer as the NVR's webpage doesn't expose all of the camera settings). There is a way of doing it but I couldn't find the details and have never set it up myself. From memory it may involve connecting one of the NVR's spare PoE ports to the router and setting up static routes. For me it'll be easier just to move the cameras onto the LAN using a PoE switch and add them back in to the NVR after re addressing them.

Yes I read on ipcamtalk forum last year that there were some issues around triggering the supplemental light. I prefer to not use the supplemental light at all and have some dusk to dawn low power LED lanterns installed. With a small amount of light I can still increase the cameras shutter speed to 1/200 sec without too much noise (the cameras standard 1/12 sec is a bit hopeless due to motion blur)

With regard to the portal that you use. If you use the EU one you would be far better using the UK one. For the last 18 months or so the UK tends to have more up to date firmware as it's updated first (it used to be the other way around)

I agree regarding the bullet - I won't use them and prefer the turret. In the UK we have the new G2 but they haven't yet released the ISU/SL variant. That one has alarm input/output and most importantly 2 way audio as I use one by my door as an intercom. Annoyingly the G2 ColorVu with AcuSense is now available in 8MP but only as the bullet. Hikvision update their model range so frequently you can never know what's around the corner.

No problem. I'm also an active user on the forum at IP CCTV Forum for IP Video, network cameras & CCTV software (username JB1970 - just 10 posts away from being the most active user!) and ipcamtalk (username John Williamson). Both are great forums use-ip has most information but I think ipcamtalk beats it hands down for more technical aspects of setup (integration with other systems, more advanced setup)

Thanks! Your link to the UK portal didn't work, but it turns out there's a link at the top of the EU portal to the UK portal. looks like it needs the "www." in the URL: http://www.hikvisioneurope.com/uk/portal/

I'm a lurker on IPCamTalk for many years, but not IP-CCTV forums... It's been about 8 years and I still haven't finished selecting/installing my cameras! With the pace that Hikvision releases them, I'm not sure if I ever will... Seems like always some new camera or feature I'm waiting for just around the corner. Similar on the home automation and home security front as well... I guess that's why they call it a hobby.

The link for the other forum hasn't displayed correctly but it's www.use-ip.co.uk. I find it's a much more active forum than ipcamtalk. ipcamtalk however has a few users that have far more knowledge than I do with regard to code etc as it's something I never got involved with (though I wish I had)

Agreed with camera selection. I've been using Hikvision around 7 years now and I estimate that although my current system consists of 9 cameras, over the years they've been swapped and changed so many times I'll have had around 50! I wait for a specific model, buy it then a month later something far better is on the horizon. CCTV has been both a job and a hobby for around 30 years. Home Automation - I'm brand new to, and it is proving to be a steep and expensive learning curve.

1 Like

I'm getting this error when I try to input the NVR address.

This is the input: http://192.168.1.10:65007/

This is the error:

I've tried removing the http:// and/or the slash after the port number. Any thoughts?

Edit: I am able to access the various cameras via the NVR:port/ on my browser.

As detailed a couple of posts up you won't get this working if your cameras are connected to an NVR (without modifications). Your NVR address is on your LAN at 192.168.1.10, while your camera address if connected to the NVR PoE ports directly will have been automatically assigned an address in the 192.168.254.xxx range. As such, although you can communicate with your camera (7) using the virtual host feature to open its menu page, the camera cannot send anything to your Hubitat Hub directly - it's on a different network segment.

2 Likes

Just type in the IPv4 address of the camera -- No need for the port number. However, based on my conversation with @johnwill1 in the above posts, I suspect your camera is behind an NVR. In that case, I don't think the camera can reach your Hubitat hub from behind the NVR. You'd probably need to connect your LAN to one of the camera ports on your NVR (or connect your camera directly to the LAN) and use the camera's IP directly.

image

1 Like

Made a significant update (v1.1.0) to add six push-able "buttons". This enables more flexibility by giving more granular configurations with up to 9 configurable sensors and buttons.

I made it for my own needs, but I hope others find it useful too.

Enjoy!

1 Like

Nice driver, I almost got it working. The camera is talking to Hubitat and I can see some logs when I trigger motion on the camera. Im using "Basic" expert motion detection on the camera event type.
On hubitat dash I have the tile set up as Attribute "Motion". Issue is it never changes to motion is Active. It stays Inactive.
I have the following driver settings:
Motion Sensor = VMD
Motions Sensor exclusive = not checked
Button 1 = VMD
Both resets at 30sec, I assume this is seconds not minutes
image

Hi @kampto. From the logs, it looks like the "VMD" event is received properly and all three sensors (Motion, Presence, & Contact) are triggered.

Have you tried to use the Motion "sensor" in a Rule Machine rule or just put it up on a tile in a Dashboard? Seems like it should be working.

Yes, reset times are in seconds.

I got it to work once. Changed the dash tile to a motion template instead of attribute-motion. The logs don't have anything that says "Alert Active".
Do I need to apply "VMD" to the Button 1 filter selections or is that not necessary for basic motion detection? Will keep playing with it.