I have a Hikvision PTZ camera which has a field of vision down my driveway in front of my house. I wanted to setup my camera in such a way that when someone comes up my driveway (either on foot or by car), a motion event is triggered and I am notified by text message. I found that using smart events alone resulted in far too many false alarms in spite of spending a fair amount of time trying many different settings combinations.
I then decided to integrate my z-wave motion activated flood light (also in my driveway) with the PTZ camera whereby in order to initiate an event BOTH the flood light PIR sensor and the camera motion sensor must be triggered by a motion event. In this way, 2 independent sensors are used and the hope was that false alarms would be reduced.
I found that that by doing this, I have virtually eliminated all false alarms and the system to notify me of a person or a car in my driveway works very well.
I am now offering this example to help others.
Equipment:
-
Hikvision camera: Model DS-2DE2A404IW-DE3, PTZ with smart events.
Bindings:
-
IpCamera - to detect camera smart events. I use the linecross smart event.
-
Z-Wave – to use the PIR sensor on the floodlight sensor to detect motion.
-
SMTP – to send email to text messages to notify me of events.
OPTION – If you use Synology’s Surveillance Station, alternatively you can also use the synologysurveillancestation binding to detect smart events from your camera rather than the IPcamera binding. I have found that both bindings work fine.
Here is how it works.
Create switch items for both the IpCamera linecross event and the z-wave floodlight PIR motion event that are enabled (turned to ON) when each one detects motion. The key is to use the ‘expiration’ feature so that each switch remains ‘ON’ for a defined period of time after it detects motion. I use 59 seconds. You can play with this to find a value that works for you.
A rule is create for each event and is triggered when motion is detected by the camera or the flood light. When triggered, the rule checks if the OTHER switch is also ‘ON’. Since you don’t know which sensor will be triggered first, you need a rule for each sensor and it checks if the other switch is also ‘ON’. If BOTH switches are on, then I am notified by text message that motion has been detected in my driveway.
I hope someone can find this useful. It works for me.
Here is the code:
The code consists of 2 rules, one for each sensor. You will also need to create 3 items, PTZ_LineCrossStatus, Flood_Driveway_Motion and DrivewayMotionDetected. See comments in the code below.
rule "PTZ Camera has detected line cross"
when
/* PTZ_LineCrossStatus - a switch item (with 59 second expiration) that is linked to the
'Line Crossing Alarm' channel of the IPcamera binding */
Item PTZ_LineCrossStatus changed from OFF to ON or
Item PTZ_LineCrossStatus changed from NULL to ON
then
/* If PTZ_LineCrossStatus changes to ON, then a check is made as to whether Flood_Driveway_Motion is also ON.
If so, and DrivewayMotionDetected has not already been triggered by the other sensor within the last 3
minutes, then a text notification is sent */
if (Flood_Driveway_Motion.state == ON && DrivewayMotionDetected.state != ON)
{
val mailActions = getActions("mail","mail:smtp:gmailsmtp")
mailActions.sendMail("905xxxyyyy@txt.bell.ca","Message from OpenHab","Driveway Motion Detected")
/* DrivewayMotionDetected - a motion event triggered by both sensors has been initiated. This is needed so another
event triggered by the other sensor does not subsequently follow. Uses 180 second Expiration timer. */
DrivewayMotionDetected.sendCommand(ON)
}
end
rule "Flood_Driveway_Motion is ON"
when
/* Flood_Driveway_Motion - a switch item (with 59 second expiration) that is linked to the
Motion Alarm 'alarm_motion' channel of the IPcamera binding */
Item Flood_Driveway_Motion changed from OFF to ON or
Item Flood_Driveway_Motion changed from NULL to ON
then
/* If Flood_Driveway_Motion changes to ON, then a check is made as to whether PTZ_LineCrossStatus is also ON.
If so, and DrivewayMotionDetected has not already been triggered by the other sensor within the last 3
minutes, then a text notification is sent */
if (PTZ_LineCrossStatus.state == ON && DrivewayMotionDetected.state != ON)
{
val mailActions = getActions("mail","mail:smtp:gmailsmtp")
mailActions.sendMail("905xxxyyyy@txt.bell.ca","Message from OpenHab","Driveway Motion Detected")
/* DrivewayMotionDetected - a motion event triggered by both sensors has been initiated. This is needed so another
event triggered by the other sensor does not subsequently follow. Uses 180 second Expiration timer. */
DrivewayMotionDetected.sendCommand(ON)
}
end