Rules allow you to easily define and customize how you
want your sensor to work with the system. A rule is a set of conditions that, when met, trigger and action. For example you may want the system to alert you if the temperature of your house reaches freezing, or is very hot.
You don't need to worry
about programming these rules, we have created an easy-to-use graphical tool
for defining rules, as shown below.
Figure 1: An example of a rule for the alarm system
Make sure you are on the latest version of PrivateEyePi
Instruction on how to install the PrivateEyePi software on your Raspberry Pi can be found HERE.
Rules explained further
Rules are made up of Conditions and Actions:
If [CONDITION] Then [Action]
of popular rules:
- If Sensor Open And Sensor = Front Door Then Send
- If Sensor Open And Sensor = Front Door Then Alarm
- If Sensor Open And Sensor = Front Door And Hour Of
Day is between 9 and 17 Then Alarm
- If Sensor Open and Zone is Armed And Sensor =
Front Door Then Alarm
- If Sensor Value is between -10 and 0 And Sensor =
Outside Temperature then Send Email
- If Sensor is open for 5 minutes And Sensor =
Garage Door Then Send Email
- If Day Of Week = Friday and Hour Of Day = 17 Then
Arm Zone Office
- If Day Of Week = Monday and Hour Of Day = 9 Then
Disarm Zone Office
condition is the part of the rule that needs to be met before action is
taken. Each condition within a rule is connected with every other
condition within that rule with an AND operator (e.g. door open And Zone
is armed). You can define an infinite amount of rules, but every rule can
only have between 1 and 4 conditions. We have found that 4 conditions are
ample, but could add more in the future if required.
currently support the following conditions (further described below):
- Zone is armed
- Zone is not armed
- Sensor open
- Sensor closed
- Sensor value
- Rule delay
- Sensor is closed for x minutes
- Day of week
- Hour of day
The sensor condition is where you specify
which sensor you wish to apply the rule to. Every rule must be
associated with a sensor.
Zone is armed, zone is not armed
These conditions will be met if the zone(s) to which the
sensor is linked are either armed or disarmed.
Sensor is open or sensor is closed
These conditions apply to sensor that has two states
only (sensor values of 1 and 0). For example a door switch or PIR sensor that
are either open or closed.
Sensor Value (Primary)
Sensor value is any numeric sensor value that needs to be met (e.g. temperature value). We also allow you to specify a numeric range (e.g. 20-30).
Sensor Value (Secondary)
Some sensor have two values (e.g. temperature and humidity). You can use the secondary value to implement rules on the secondary value (e.g. humidity). Sensor value is any numeric sensor value that needs to be met. We also allow you to specify a numeric range (e.g. 20-30).
Rule Delay (minutes)
A rule delay is a time period that the rule needs to me met before triggering the action. An example of this is alerting you when your garage
door has been open for 5 minutes. Another popular example is when monitoring a freezer which may fluctuate when opened and closed, so adding a delay will allow you to open and close the freezer and only trigger the rule if the temperature is sustained for a period of time.
Day of week
The day of week condition allows you to perform specific
actions only on specific days of the week. We also allow you to specify a day
of week range (e.g. Mon-Fri, or Sat-Sun).
Hour of day
The hour of day condition allows you to perform specific
actions only on specific hours of the day. The hourly range is specified in
24h notation (0-23). We also allow you to specify a hourly ranges (e.g.
An action is performed when a condition or set of
conditions are met. The actions that we currently support are:
- Alarm (this is sound the alarm for the zone(s) to
which the sensor is linked
- Arm (you specify which zone you want to arm)
- Disarm (you specify which zone you want to disarm)
- Relay On/ Relay Off
- Text (see here for further details on how to configure rules)
Chime and Siren
There are some new configurations in the globals.py file that allow you to customize how your want the siren and chime to work. You can set the chime duration which is the amount of time the chime will sound. This is useful if you want to know if someone enters the house or you have a new customer in your shop. Siren delay will delay the siren for a period of time (seconds). You can have a intermittent beep during the delay to warn you that the alarm is about to sound (BeepDuringDelay).
UseSiren = False
SirenGPIOPin = 18
SirenDelay=30 #The amount of time the siren will delay before it sounds
BeepDuringDelay = True #if your want the siren to beep during the SirenDelay period
SirenTimeout = 30 #siren will timeout after 30 seconds
ChimeDuration = 5
In order to define rules go to :
Log in using your normal user and password.
There is a new menu item called Rules(Beta) where you can
add new rules.
To add new rules select the Rule(Beta) menu option then click on the Add button after which the
screen to add new rules will be displayed (Figure 2). You will be presented with a grid
of 5 lines where the top 4 lines are condition and the last line is the
Figure 2 - How to define a new rule
Note: You need to define all your alarm system rules. Rules that were hard coded into the old alarm system need to be defined by you. For example the old system would trigger an
alert email, insert a log and sound the alarm when a sensor is opened. Now you need to define each of those rules in the system. For an alarm system each sensor needs three rules, one for
the alarm and one for the email and one for the log entry.