Hikvision Cameras with motion sensor enabled

Sure, glad to.

Be sure to specify JUST the IP address of the NVR in the IP address of the camera (this would be the fourth camera, for instance): /ISAPI/Streaming/channels/401/picture

And then the Streams variable like so: rtsp,rtsp,:8554/Streaming/channels/402

This adds a new ‘alertURL’ variable to the camera, which allows you to exactly specify the URL to get the alertStream. If you’re using the Virtual Host option, you should specify the port # of your camera in the first part of the URL like so : :65004/ISAPI/Event/notification/alertStream

Few things you’ll need to ensure:

[ol][li]You have the Virtual Host option turned on for your NVR[/li]
[li]Your username/password is the same on the NVR as your cameras (the admin user may not work well, you may need to add a new user with appropriate permissions)[/li]
[li]You probably will need to change your substream for each camera to MPEG to make the streaming work properly in the mobile app (H.264 which is the default, and does not seem to work for Vera). This is why I specified ‘402’ above, vs ‘401’ which is the main stream.[/li]
[li]This code is specifically written to expect the Line Detection capability to be pre-configured on the camera. You’ll want to do this through the NVR itself for each camera you plan to connect to[/li][/ol]

What’s going on here is we’re actually leveraging the NVR to get the images and video, but then directly accessing the cameras to get access to the alertStream linedetection notifications.

Be careful using this, if you don’t know what you’re up to, you could get into a Luup-reboot-loop and have a tough time getting out of it. (No warranties provided obviously). I’m actually doing this on my LaView NVR/camera setup, which is rebranded Hikvision. Other than the annoying alert-delay things seem to be mostly working.

Hope that helps.

[quote=“bwillette, post:21, topic:197072”]Sure, glad to.

Be sure to specify JUST the IP address of the NVR in the IP address of the camera, and use the port number in the URL like so (this would be the fourth camera, for instance): /ISAPI/Streaming/channels/401/picture

And then the Streams variable like so: rtsp,rtsp,:8554/Streaming/channels/402

This adds a new ‘alertURL’ variable to the camera, which allows you to exactly specify the URL to get the alertStream. If you’re using the Virtual Host option, you should specify the port # of your camera in the first part of the URL like so : :65004/ISAPI/Event/notification/alertStream

Few things you’ll need to ensure:

[ol][li]You have the Virtual Host option turned on for your NVR[/li]
[li]Your username/password is the same on the NVR as your cameras (the admin user may not work well, you may need to add a new user with appropriate permissions)[/li]
[li]You probably will need to change your substream for each camera to MPEG to make the streaming work properly in the mobile app (H.264 which is the default does not seem to work for Vera). This is why I specified ‘402’ above, vs ‘401’ which is the main stream.[/li]
[li]This code is specifically written to expect the Line Detection capability to be pre-configured on the camera. You’ll want to do this through the NVR itself for each camera you plan to connect to[/li][/ol]

What’s going on here is we’re actually leveraging the NVR to get the images and video, but then directly accessing the cameras to get access to the alertStream linedetection notifications.

Be careful using this, if you don’t know what you’re up to, you could get into a Luup-reboot-loop and have a tough time getting out of it. (No warranties provided obviously). I’m actually doing this on my LaView NVR/camera setup, which is rebranded Hikvision. Other than the annoying alert-delay things seem to be mostly working.

Hope that helps.[/quote]

Digging up an old thread.

I just bought my first Hikvision IP camera a
DS-2CD2045FWD-I

I’ve installed the Hikvision IP Camera(ALPHA) plugin and I have uploaded @Sorin I_HikvisionIPCamera.xml file to Vera.

I have managed to add the camera OK in to Vera, following these instructions here and using the I_HikvisionIPCamera.xml file instead.

image

I have enabled basic on the WEB Authentication in the cameras settings.

I can run this command in curl in a CMD prompt and it lists the alertstream information OK.

curl -s http://user:password@192.168.0.15/ISAPI/Event/notification/alertStream

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.0.15</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>xx:xx:xx:xx:xx:xx</macAddress>
<channelID>1</channelID>
<dateTime>2020-05-18T14:10:03+00:00</dateTime>
<activePostCount>19</activePostCount>
<eventType>VMD</eventType>
<eventState>active</eventState>
<eventDescription>Motion alarm</eventDescription>
<channelName></channelName>
<Extensions version="1.0" xmlns="urn:psialliance-org">
<serialNumber xmlns="urn:selfextension:psiaext-ver10-xsd">DS-2CD2045FWD-xxxxxxxxxxxxxxxxxxxxxxxx</serialNumber>
<eventPush xmlns="urn:selfextension:psiaext-ver10-xsd">IO&amp;&amp;DS-2CD2045FWD-xxxxxxxxxxxxxxxxxxxxxxxx,2020-05-18T14:10:03+00:00,1.0</eventPush>

Following @loukt advise here, I had edited the I_HikvisionIPCamera.xml file and changed:

Change from the function getStreamEvents()
the line

      if newEvent:find("&lt;eventDescription>PIR alarm&lt;/eventDescription>")
   to
      if newEvent:find("&lt;eventType>VMD&lt;/eventType>")

However in Vera no new motion sensor device is being created.

If I look in the Vera log I can see this:

“not a Hikvision camera, nothing to do” and “Unsupported camera model nothing to do”

The file “/tmp/HilkvisionOutput_Devno.txt” in not being created on the Vera in the /tmp folder.

Anyone know how to fix it ?

Its a genuine EU camera purchased from an authorised dealer not off eBay or Amazon.

Many thanks

1 Like

OK I think I have it working now :grinning:

In the I_HikvisionIPCamera.xml file there is a section for the user name and password:

On Line #58 I put in my password for my camera.

Then on Line #751 I added my camera model number: DS%-2CD2045FWD%-I
I put the percent signs in like on the existing model numbers:

After Vera reloaded the engine a couple of times, I then had a new motion sensor device.

When I wave my hand in front of the camera the new motion sensor device trips and then shortly afterwards un-trips.

I can now see a file called HilkvisionOutput_445.txt in the /tmp folder on Vera.

445 being the device ID number of my camera device in Vera.

The other thing I did on the IP Camera’s settings in Network → Advanced Settings → Integration Protocol. Was enable “Enable Hikvision-CGI” with “digest/basic”.

However I am not 100% sure if that was required. I guess it would be if you have a PTZ camera as the implementation file has references to CGI commands.

This is excellent news.

I don’t currently have a Hikvision NVR but I plan to buy one and I was looking at purchasing a much more expensive model with Alarm Output ports and using a Fibaro Universal Binary sensor to create virtual motion sensor devices in Vera. That thread is here.

Looks like I might not need to do that now as this plug-in is working, so can probably buy a cheaper Hikvision NVR. That’s assuming Ezlo add support for Hikvision cameras and this plug-ins functionality on their new platform.

I’ve turned off Auto Archiving for the camera in Vera, ideally I don’t want the cameras video stream in Vera at all, its just the motion sensor device I wanted.

But I guess for this to work, the camera needs to be added in Vera.

image

This was the output in the Vera log when it actually created the new motion sensor device.

(Hikvision)::(Startup) : plugin rev 5, device #445-Back Garden CAM <0x77312520>
(Hikvision)::(CheckBasicCameraVariables) : Checking… <0x77312520>
(Hikvision)::(CheckBasicCameraVariables) : Debug mode disabled. <0x77312520>
(Hikvision)::(Reconfigure) : camera is activated <0x77312520>
(Hikvision)::(SetWifiValues) : WiFi disabled or not an Access Point <0x77312520>
(Hikvision)::(ConfigureStream) : start configuring stream <0x77312520>
(Hikvision)::(ConfigureStream) : not a Hikvision camera, nothing to do <0x77312520>
(Hikvision)::(ConfigureMotionSensor) : MSConfStage= <0x77312520>
Device_Variable::m_szValue_set device: 445 service: urn:micasaverde-com:serviceId:Camera1 variable: FirstRun was: EMPTY now: 0 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x77312520>
(Hikvision)::(ConfigureMotionSensor) : First run, creating motion sensor <0x77312520>
(Hikvision)::(GetMotionSensorID) : [1] Motion sensor doesn’t exist <0x77312520>
Device_Variable::m_szValue_set device: 445 service: urn:micasaverde-com:serviceId:Camera1 variable: MSConfStage was: EMPTY now: 3 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x77312520>
(Hikvision)::(ConfigureMotionSensor) : [1] Create the motion sensor <0x77312520>
Device_Variable::m_szValue_set device: 446 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: Armed was: EMPTY now: 1 #hooks: 0 upnp: 0 skip: 0 v:0x159d550/NONE duplicate:0 <0x77312520>
Device_Variable::m_szValue_set device: 446 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: IgnoreTripTime was: EMPTY now: 0 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x77312520>
UserData::CommitToDatabase data size 943324 943324 <0x77312520>
JobHandler_LuaUPnP::Reload: luup.reload Critical 0 m_bCriticalOnly 0 dirty data 0 running 1 <0x77312520>
JobHandler_LuaUPnP::Reload: luup.reload Critical 0 pending write, try again later <0x77312520>
(Hikvision)::(Startup) : Startup OK! <0x77312520>

Interestingly it still stated:

(ConfigureStream) : not a Hikvision camera, nothing to do <0x77312520>

OK there is one problem, in the UI7 web GUI I cannot click on the button to Arm/Disarm the sensor. It doesn’t work when pressing the button.

image

However if I go in to the devices Advanced → Variables

And manually edit the “Armed” variable from 0 to 1 then it does work and the sensor then becomes armed OK.

image

Looking in the cameras motion sensor device, under Advanced → Params

The “impl_file” field was blank and had nothing in it. So I entered in I_MotionSensor1.xml and reloaded the LUUP engine.

image

However its still not working, I cannot arm/disarm the motion sensor device by clicking on the buttons in the GUI.

I then looked at some real Z-Wave motion sensor devices in Vera and they didn’t have anything in the “impl_file” field either so maybe that’s normal.

So not sure how to fix this currently.

UPDATE:

I think this is a bug with the Hikvision plug-in ? Not being able to change the motion sensor Armed/Disarmed state using the buttons in the GUI.

Messing around and testing lots of different things, on the motion sensor device if I remove its altid value (camera_445_motion_sensor) and remove its id_parent value (445) and ensure in the impl_file field I have I_MotionSensor1.xml

And then reload the engine, then the button starts working to turn on Armed/Disarmed OK, but obviously the link to the camera is lost.

So if I then add back in the altid and id_parent values the button stops working again.

Specifically it seems to be when I add back in the id_parent number that the button stops working again.

I’ve managed to get the button working and motion sensor tripping, with no id_parent value defined at all (field either empty or with 0), but with the altid field value defined, that seems to be enough to link it up to the camera again.

So now the motion sensor tripped / un-tripped is working and now I can also arm/disarm the sensor using the button in the GUI.

I_MotionSensor1.zip (352 Bytes)


UPDATE - More than one Hikvision Camera

Had a hell of job getting two Hikvision cameras working on my Vera Plus.

In the end I’ve had to use the stripped down I_HikvisionIPCamera.xml file by @bwillette however his line for just filtering the eventType only rather than the whole alertstream was not working, nothing was being populated in the txt file in the Vera tmp folder. I had to comment his line out on line 184 and put the original line back in on line 183.

Also he was looking for eventType “line crossing” on line 228

if newEvent:find("&lt;eventType>linedetection&lt;/eventType>") then

I’ve changed that line back to VMD for motion detection.

if newEvent:find("&lt;eventType>VMD&lt;/eventType>") then

These xml files were on the old forum and they have not be carried over to this new forum. So I am uploading bwillette’s file with my changes mentioned above. Stripped-I_HikvisionIPCamera.zip (5.5 KB)