Alarm system 'wiki'
Posted: Saturday 21 November 2015 14:05
All,
IMPORTANT: The original WIKI was created when domoticz still recognised changes in user variables and was able to trigger events. That is no longer the case. User variables need to be replaced with dummy devices instead.
Since my existing, built in alarm, is getting to an end, I needed to replace it with something new. Obviously, domoticz was my first choice so I decided to give it a go.
My key challenge was that I found bits and pieces everywhere but wanted a more 'all-encompassing' approach which turned into something that could be considered sort of a generic wiki. Since this would be my first wiki, I would like some feedback before I post so here it goes
. Be gentle
.
Practical guide to building an alarm system using Domoticz
Contents
General concept
Building resilience
Detection devices
Sirens
Arm/Disarm
Putting it all together
Alerting
Actions
Contents
Setting up a fully capable, industry grade alarm system using Domoticz is pretty doable and quite cost effective. Obviously Domoticz will not be using wired devices and wireless devices are never as secure as wired ones. If that's what you need then you will be better off buying a separate, wired alarm system. That said, using a mixed system of devices (z-wave, 433) will make it hard for any burglar to jam everything at the same time giving quite a decent base system.
There is quite a bit of info in this wiki and it may seem complex but it really isn't. It does require basic knowledge of domoticz but you should not have to do any (major) lua programming yourself if you don't feel comfortable.
General concept
This design is based on the following basic principles:
1. use the domoticz built-in security panel (arm, disarm, check states)
2. use any standard detection devices: motion detectors as well as door/window sensors and name them such that you can easily detect them generically (motion detected, door opened) : 2 simple lua scripts handle either motion detection (PIR) or door/window sensor detection. All motion/PIR sensors need to be named PIR_something (e.g. PIR_hallway, PIR_livingroom), all door/window sensors need to be named MCS_something (e.g. MCS_backdoor, MCS_frontdoor). This way, you can easily add sensors without having to change anything in the rest of system.
3. separation between detection and action: instead of dealing with the threat in the detection script itself, I decided to handle any action outside of the detection scripts. That gives me a lot more flexibility in dealing with these. The detection scripts set a user variable “AlarmDetected” to 1 if an alert is detected. Using either scripting or (blocky) events, you can then act on these. I currently use events (being lazy by nature, it's easier to make a change rather than to have to login and change/test lua scripts). Either way, once an action is done, you need to set the user variable “AlarmDetected” back to 0 in order for new alarms to be raised.
4. Any PIR or MCS activity when the alarm is armed is notified through the notification system. Set that up and you get a notification on the exact trigger.
Building resilience & security
Any alarm system built on computing technologies is as good as the availability of the system. Once the computer is down, so is your alarm. A couple of things that can be done to increase the resilience of the system. Also, it's tempting to connect domoticz to the internet and access it from outside yout house. Once domoticz controls your alarm, that may not be the best idea as you don;t want hackers to control your security in any way.
In order to increase resilience, I can recommend using (some of) the following:
Detection devices
Building the system, you have a choice of detection devices:
There are a number of different sirens on the market in various technologies. I decided to use 433 based linked smoke detectors, in my case the König SAS SA200. These are cheap but connectable smoke detectors. I have 3 of them (garage/laundry, kitchen/living and upstairs) that are linked. If one goes off, so do the others. Domoticz can also trigger them causing a 3x 85db noise which I can assure you is quite effective. There are other options including z-wave sirens. Again, these are more dependable and will definitely go off if Domoticz tells it to (again, a 433 signal may get undetected). A z-wave device will probably cost as much as my 3 smoke detectors together.
Arm/Disarm
Domoticz has a security panel built in which works perfectly but requires a computer (phone, tablet) to arm. For convenience, I have added the z-wave zipato mini keypad. Not only is it very small and easy to use but it uses rfid tags to arm/disarm. There is an excellent wiki on how to install with domoticz: https://www.domoticz.com/wiki/Zwave#Usi ... Tag_Reader. Adding rfid tags (and user pin codes) was a breeze and you can have it up and running in a matter of minutes. It creates multiple devices of which I use 2 (3 if you count the tamper switch which I don't think I will use as I hope my alarm has gone off by then):
Once that's done, you need to let the zipato keypad control the domoticz alarm state. There are different ways this can be done. I used a simple lua script that sets the domoticz security state based on the keypad action as follows:
Sweet and simple. The beauty is that arming the security panel uses the built in security panel's delay as configured in the domoticz settings. Again, there are different ways you can do this.
Putting it all together
1. Create a user variable called “AlarmDetected” (without the quotes obviously) of type string. Set it to 0.
2. If you use the zipato keypad, save the AlarmPanel script in the domoticz/scrips/lua directory
3. Set up any notifications you want in the domoticz notifications system. I use both pushalot for my windows phone and that works really well. I also use pushover for my ipad (and soon my wife's iphone) which also works well
4. Save the following 2 lua scripts in the domoticz/scrips/lua directory:
5. If you use a camera, set it up as described above and create the dummy switch so you can take a picture when triggering the switch. Make sure you set up your email address so it can actually send you the picture as well (instead of the burglar ending up with a nice picture of him/herself)
6. Decide how you want to deal with the alarms generated. A simple way could be to create an event called AlarmNotification with the following blocky:

This (only) sends a notification and switches the AlarmDetected flag off after 20 seconds kind off creating a silent alarm. In my case, this is still WIP. Considerations for me are:
if after sundown and before sun-up (simple addition to the event above), switch on the lights and use my indoor camera to take a picture (or start recording?)
if I get an alarm notification on my phone, am I better off asking my neighbors to check up on the house using our community whatsapp group? If after 1am and before 7am, should I still sound the alarm since nobody is looking at their phones?
Do I want any speaker connected to my pi saying that the police is on their way now?
As you can see, the possibilities are endless and I still need to make up my mind how exactly I will handle them. Domoticz at least allows us to do whatever I would want to do in a way that is much more flexible than any standard alarm system.
IMPORTANT: The original WIKI was created when domoticz still recognised changes in user variables and was able to trigger events. That is no longer the case. User variables need to be replaced with dummy devices instead.
Since my existing, built in alarm, is getting to an end, I needed to replace it with something new. Obviously, domoticz was my first choice so I decided to give it a go.
My key challenge was that I found bits and pieces everywhere but wanted a more 'all-encompassing' approach which turned into something that could be considered sort of a generic wiki. Since this would be my first wiki, I would like some feedback before I post so here it goes


Practical guide to building an alarm system using Domoticz
Contents
General concept
Building resilience
Detection devices
Sirens
Arm/Disarm
Putting it all together
Alerting
Actions
Contents
Setting up a fully capable, industry grade alarm system using Domoticz is pretty doable and quite cost effective. Obviously Domoticz will not be using wired devices and wireless devices are never as secure as wired ones. If that's what you need then you will be better off buying a separate, wired alarm system. That said, using a mixed system of devices (z-wave, 433) will make it hard for any burglar to jam everything at the same time giving quite a decent base system.
There is quite a bit of info in this wiki and it may seem complex but it really isn't. It does require basic knowledge of domoticz but you should not have to do any (major) lua programming yourself if you don't feel comfortable.
General concept
This design is based on the following basic principles:
1. use the domoticz built-in security panel (arm, disarm, check states)
2. use any standard detection devices: motion detectors as well as door/window sensors and name them such that you can easily detect them generically (motion detected, door opened) : 2 simple lua scripts handle either motion detection (PIR) or door/window sensor detection. All motion/PIR sensors need to be named PIR_something (e.g. PIR_hallway, PIR_livingroom), all door/window sensors need to be named MCS_something (e.g. MCS_backdoor, MCS_frontdoor). This way, you can easily add sensors without having to change anything in the rest of system.
3. separation between detection and action: instead of dealing with the threat in the detection script itself, I decided to handle any action outside of the detection scripts. That gives me a lot more flexibility in dealing with these. The detection scripts set a user variable “AlarmDetected” to 1 if an alert is detected. Using either scripting or (blocky) events, you can then act on these. I currently use events (being lazy by nature, it's easier to make a change rather than to have to login and change/test lua scripts). Either way, once an action is done, you need to set the user variable “AlarmDetected” back to 0 in order for new alarms to be raised.
4. Any PIR or MCS activity when the alarm is armed is notified through the notification system. Set that up and you get a notification on the exact trigger.
Building resilience & security
Any alarm system built on computing technologies is as good as the availability of the system. Once the computer is down, so is your alarm. A couple of things that can be done to increase the resilience of the system. Also, it's tempting to connect domoticz to the internet and access it from outside yout house. Once domoticz controls your alarm, that may not be the best idea as you don;t want hackers to control your security in any way.
In order to increase resilience, I can recommend using (some of) the following:
- Equip domoticz with a (small) UPS. I use the very cheap Sweex 1000VA UPS (usually around 85 bucks) for both my electronics cabinet as well as for domoticz (which is in a different place). Since domoticz, in my case, runs on a raspberry pi, it can go on for days on the UPS if need be
use a watchdog if your system has one. The raspberry pi does. This ensures that if the system locks up (hangs or CPU max), it gets restarted automatically. There are general pages for the pi as well as a specific page for domoticz. Google is your friend.
Make sure that not only domoticz is on an UPS but everything else you need in order to get a message out. If your router is not on the UPS then no internet if the power is down.
Consider a cell network data plan with a dongle in order to send messages even if all the power in the neighborhood is out. Neighborhood wide power outages are notorious burglar events. Some routers support a dongle based backup if the main internet is out but you can also equip your system directly with a dongle.
Just make sure that the entire end to end chain (end points and switches in between), is on an UPS as, having a pi desperately trying to alert you without a network is not good. Note that it's not uncommon for a burglar to short-cut an outside electricity socket to trip the main switch/RCD in your home. If your power is down, can you still get a message out?
Detection devices
Building the system, you have a choice of detection devices:
- Movement detection devices aka PIR or passive infra-red: these come in various technologies both 433, z-wave and probably others. This wiki will use both KAKU AWST-6000 (the downside is that they create a 5-10s signal burst during which rfxcom cannot send/receive other signals so essentially not a good choice, I need to replace them) as well as z-wave Philio PST02-1B. Again, call these PIR_something.
Door-window sensors: these also come various technologies. I use the KAKU AWST-606 (they are cheap). Obviously the Philio sensors are much more dependable and you will not miss a signal but they are 3-4x more expensive. Since it's strongly advised to equip all external and some internal doors/windows with a sensor (and I have a lot) then decide whether you want to spend the money (in my case, 12x a difference of 35 euros ie 400 euros for just the door sensors). Also recognise that you should combine these with motion detection as any burglar smashing in a window will not trigger the window/door sensor. Make sure you put a sensor on your utilities cabinet (Meterkast) in case anyone is looking to cut off your electricity. My sensor triggers an immediate alarm if the alarm system is armed. Again, call these MCS_something.
Glass break sensors: this seems to be a rather weak area in home automation as there don't seem to be too many options here. I have found the vision security ZS5101 z-wave shock sensor which is listed as being able to detect glass breaks. It has mixed feedback on the internet. Please report any confirmed working glass break sensors
Camera's: you have a choice of confirmed supporting camera's that you can buy in local shops or order any of these cheap chinese IP wifi camera's and pray they will work. Many of them have both infrared support as well as some form of motion detection. In most cases, the motion detection is not integrated in domoticz AFAIK but there are guides on how to do this. Again, google is your friend. It's not difficult to add a (supported) camera to domoticz (Setup→>More Options→Camera → Add Camera) and then to add the camera to a dummy switch. When you press the switch, the camera takes a picture and sends it to you vial email.
There are a number of different sirens on the market in various technologies. I decided to use 433 based linked smoke detectors, in my case the König SAS SA200. These are cheap but connectable smoke detectors. I have 3 of them (garage/laundry, kitchen/living and upstairs) that are linked. If one goes off, so do the others. Domoticz can also trigger them causing a 3x 85db noise which I can assure you is quite effective. There are other options including z-wave sirens. Again, these are more dependable and will definitely go off if Domoticz tells it to (again, a 433 signal may get undetected). A z-wave device will probably cost as much as my 3 smoke detectors together.
Arm/Disarm
Domoticz has a security panel built in which works perfectly but requires a computer (phone, tablet) to arm. For convenience, I have added the z-wave zipato mini keypad. Not only is it very small and easy to use but it uses rfid tags to arm/disarm. There is an excellent wiki on how to install with domoticz: https://www.domoticz.com/wiki/Zwave#Usi ... Tag_Reader. Adding rfid tags (and user pin codes) was a breeze and you can have it up and running in a matter of minutes. It creates multiple devices of which I use 2 (3 if you count the tamper switch which I don't think I will use as I hope my alarm has gone off by then):
- Alarm level: on means the peypad was armed (away button), off means disarmed (home button)
Switch: this is the feedback of the device ie the beeps when you arm it. I renamed it to keypad Ack based on 'lolautruche' recommendations in the domoticz forum and set it to on when the keypad is disarmed. That way, next time the alarm is armed, you hear the beeps indicating the system is about to arm.
Once that's done, you need to let the zipato keypad control the domoticz alarm state. There are different ways this can be done. I used a simple lua script that sets the domoticz security state based on the keypad action as follows:
Code: Select all
-- Title: script_device_AlarmPanel.lua
-- Date: 19-11-2015
--
-- this scrip switches the Alarm Status according to the alarm panel
--
commandArray = {}
tc=next(devicechanged)
Panel=tostring(tc)
if (Panel == 'Keypad Alarm Level') then
-- set the group to the status of the switch
if (devicechanged[Panel] == 'On') then
print('AlarmPanel Arm Away')
commandArray['Security Panel'] = 'Arm Away'
else
print('AlarmPanel Disarm')
commandArray['Security Panel'] = 'Disarm'
commandArray['Variable:AlarmDetected'] = '0'
commandArray['Keypad Ack'] = 'On'
end
end
return commandArray
Putting it all together
1. Create a user variable called “AlarmDetected” (without the quotes obviously) of type string. Set it to 0.
2. If you use the zipato keypad, save the AlarmPanel script in the domoticz/scrips/lua directory
3. Set up any notifications you want in the domoticz notifications system. I use both pushalot for my windows phone and that works really well. I also use pushover for my ipad (and soon my wife's iphone) which also works well
4. Save the following 2 lua scripts in the domoticz/scrips/lua directory:
Code: Select all
-- Title: script_device_MCSAlarm.lua
-- Date: 12-11-2015
-- checks for MCS during Alarm Away status
-- if detected then alert and set the alarm flag
--
commandArray = {}
tc=next(devicechanged)
MCS_switch=tostring(tc)
if (MCS_switch:sub(1,3) == 'MCS') then
if(otherdevices['Security Panel'] == 'Arm Away') then
print('MCS motion detected:'..MCS_switch)
commandArray['SendNotification']='MCS motion detected:'..MCS_switch
commandArray['Variable:AlarmDetected'] = '1'
end
end
return commandArray
Code: Select all
-- Title: script_device_PIRAlarm.lua
-- Date: 12-11-2015
-- checks for PIR during Alarm Away status
-- if detected then alert and set the alarm flag
--
commandArray = {}
tc=next(devicechanged)
PIR_switch=tostring(tc)
if (PIR_switch:sub(1,3) == 'PIR') then
if(otherdevices['Security Panel'] == 'Arm Away') then
print('PIR motion detected:'..PIR_switch)
commandArray['SendNotification']='PIR motion detected:'..PIR_switch
commandArray['Variable:AlarmDetected'] = '1'
end
end
return commandArray
6. Decide how you want to deal with the alarms generated. A simple way could be to create an event called AlarmNotification with the following blocky:

This (only) sends a notification and switches the AlarmDetected flag off after 20 seconds kind off creating a silent alarm. In my case, this is still WIP. Considerations for me are:
if after sundown and before sun-up (simple addition to the event above), switch on the lights and use my indoor camera to take a picture (or start recording?)
if I get an alarm notification on my phone, am I better off asking my neighbors to check up on the house using our community whatsapp group? If after 1am and before 7am, should I still sound the alarm since nobody is looking at their phones?
Do I want any speaker connected to my pi saying that the police is on their way now?
As you can see, the possibilities are endless and I still need to make up my mind how exactly I will handle them. Domoticz at least allows us to do whatever I would want to do in a way that is much more flexible than any standard alarm system.