en.Tipps AlarmSystem - jens-maus/RaspberryMatic GitHub Wiki

This section will cover the setup of a versatile yet fairly basic alarm system on your RaspberryMatic. Out of the box, the RaspberryMatic installation comes without any logic for the alarm system allowing you to setup a system that behaves exactly as required for your own unique situation.

In this how-to, we will document how to setup a common scenario using a basic template that can be expanded upon as per your own needs. Some of the things documented here (like: the actions included in the example automation rules) are subject to your own personal setup and probably will need to be changed to fit your specific setup/needs. However, the basic framework of the setup I documented here should provide you a good starting point as well as some inspiration and best practices.

Index:

Overview

The Alarm system in this example will be based on 3 different modi (excuse the star-trek references):

  1. shields-down
    Alarm is off
  2. shields-up
    The alarm is protecting the outside of your building only. Use this when people are still inside the building. For example when you go bed, but still want to be able to move around your house to go to the toilet, or the fridge, etc.. Use this to arm the door/window sensors etc
  3. max-shields
    The alarm is protecting your entire building. Use this when there is no-one at home. Any movement inside the building will also trigger the alarm. Use this to in addition to the door/window sensors also arm the movement/presence detectors etc..

The basic idea behind this setup is to create a couple of system variables, and some automation rules to manipulate or act upon these.

Alarm Modi

System Variable: alarm status

The very first thing we will have to do is to create a system variable to store the current state of the alarm.

Go to settings --> system variables and create a new variable as per below screenshot:

Name: alarm_status
Type: Value list
Values: shields-down; shields-up; max-shields

Automation Rules: set modus

The first Automation rule would be required in order to set the currently active alarm modus.

Go to Programs and Connections --> Programs and RaspMatic connections and create a new automation rule as per below screenshots:

Name: ALARM - setMode
Description: Triggers that change the ALARM modus

The text explanation of what this rule does is as follows:

IF a button is pressed on a remote control device (short press)
  OR a button is pressed on a remote control device (long press)
AND the alarm is not already in state "shields-down" (OFF)
THEN change the alarm modus immediately to "shields-down"

IF a button is pressed on a remote control device (short press)
  OR a button is pressed on a remote control device (long press)
  OR a button is pressed on a light switch (long press)
AND the alarm modus is not already in the state "shields-up" (ON)
THEN change the alarm modus to "shields-up" with a 1-minute delay to give you some time to do whatever before the related actions get triggered (example: go upstairs before the lights are turned off)

IF a button is pressed on a remote control device (short press)
  OR a button is pressed on a remote control device (long press)
AND the alarm modus is not already in the state "max-shields" (ON)
THEN change the alarm modus to "max-shields" with a 2-minutes delay to give you some time to do whatever before the related actions get triggered (example: leave the house & close the front door, before the alarm is active)

In order to keep the system easy to maintain we will use this rule only to add more triggers and conditions related to changing the alarm modi. The actual actions the system needs to perform when the active modus is changed, are stored in another automation rule that we will create next.

Automation Rules: modus actions

Most likely you would like your automation system to take certain actions based on the fact that that alarm modus has just changed. For example: turning all lights off when you go bed, Turn down the heating while you are not at home, etc. This is what the next rule is for. It will listen to the system variable "alarm_status" which you manipulate in the previous automation rule.

Go to Programs and Connections --> Programs and RaspMatic connections and create a new automation rule as per below screenshots:

Name: ALARM - ModeActions
Description: Actions taken when Mode is changed

The text explanation of what this rule does is as follows:

IF system variable "alarm_status" is changed to "shields-down"
THEN take certain actions like:
        - turn heating back to automatic
        - disable the burglar siren (just in case it was triggered and you turn off the alarm due to this)
        - switch some indicator light to green
        - send a text message
        - etc...

ELSE IF system variable "alarm_status" is changed to "shields-up"
THEN take certain actions like:
        - turn heating modus to manual (and a certain setpoint temperature)
        - switch some indicator light to red
        - turn off all (or specific) lights in the building
        - send a text message
        - etc...

ELSE IF system variable "alarm_status" is changed to "max-shields"
THEN take certain actions like:
        - turn heating modus to manual (and a certain setpoint temperature)
        - switch some indicator light to red
        - turn off all (or specific) lights in the building
        - send a text message
        - etc...

This gives you the flexibility to take different kinds of actions based on the type of alarm modus you are setting. For example, you might not want to turn the heating to manual/off when you set "shields-up" and are sleeping in the building, but you might like to do this only when you use "max-shields" and no one is left inside the building.

Alarm Triggers

Now that we have a way to set an alarm modus (state), we will need a way to trigger the alarm. We will again use a system variable for this as this gives us the flexibility to add a delay in triggering the alarm, and also to link other existing automation rules to be triggered by this system variable.

System Variable: alarm trigger

Let's create a system variable to store the current state of the alarm trigger.

Go to settings --> system variables and create a new variable as per below screenshot:

Name: alarm_trigger
Type: Alarm Values: true=activ, false=inaktiv

With the system variable giving us a way to store the current state of the alarm trigger, we will now create a way for the system to detect if the alarm should be triggered or not. We will split this into 2 separate rules so we can define different conditions for "shields-up" and "max-shields".

Automation Rules: Trigger shields-up

This rule is to trigger the alarm in "shields-up" modus, This should contain all trigger conditions that relate to devices on the outside of the building only. (example: camera movements on the perimeter, door/window sensors, etc..)

Go to Programs and Connections --> Programs and RaspMatic connections and create a new automation rule as per below screenshots:

Name: ALARM - Alarm detection for shields-up
Description: how to detect that the alarm should trigger

The text explanation of what this rule does is as follows:

IF list of device or system states you want the alarm to trigger
AND "alarm_status" is set to "max-shields"
THEN change the system variable for the "alarm_trigger" to active

If you are one of these people that want often open a door or window only to realize that the alarm is still set, you could add a delay here allowing you to close the window again before the alert is actually triggered.

Automation Rules: Trigger max-shields

We should do the same for the "max-shields" protection mode, with the difference to also include the indoor presence/movement detectors or in-house door/window sensors etc that would trip the alarm when there is any activity inside the building.

Go to Programs and Connections --> Programs and RaspMatic connections and create a new automation rule as per below screenshots:

Name: ALARM - Alarm detection for max-shields
Description: how to detect that the alarm should trigger

The text explanation of what this rule does is as follows:

IF list of device or system states you want the alarm to trigger
AND "alarm_status" is set to "max-shields"
THEN change the system variable for the "alarm_trigger" to active

Trigger actions

So, so far we have a way to SET an alarm modus, and to take actions on the set mode, as well as being able to detect if the alarm is being triggered by something. The logical next thing to do is to create a set of actions for the system to execute when the alarm is triggered. We will do this with yet another automation rule.

Go to Programs and Connections --> Programs and RaspMatic connections and create a new automation rule as per below screenshots:

Name: ALARM - isTriggered
Description: what happens when the alarm is tripped

The text explanation of what this rule does is as follows:

IF "alarm_trigger" system variable is changed to "activ"
THEN do stuff like:
        - activate the burglar siren (1 or more)
        - turn on the lights, I have a slight delay to maximize the effect (also useful for yourself so you can see something when you arrive on the scene)
        - send a text message to phone/laptop etc..

NOTE: you might have to take note of some local laws here, for example in Germany you are only allowed to run your outside mounted burglar alarm for 180 seconds, so you might want to add a delayed action to this rule to turn off your outside siren after such time.

Additional inspirations

Some additional things you could do with this way of setting up your alarm system, that can be used as-is or as additional inspiration for your own application. If these inspire you for cool applications that are not yet documented here, I would appreciate if you add your solutions/ideas to this document.

Alarm reset

This automation rule gives you a way to reset the alarm without disabling the actual alarm. For example, you have opened a window by accident, and you only want to turn off the loud noise, but leave the alarm on for the rest of the night.

Repeating text messages

If you are like me, and you are likely to miss the alarm message on Telegram (even though I use a group for the complete family to receive these), you can also setup a repeating message every 30sec like so.

with the time schedule:

Timebased turn off

When I'm at home (alarm modus: shields-up) I like the alarm to turn off automatically just before I wake up in the morning. This is also easy to setup like so:

with the time schedule: