Using the following scripts it's possible to do yourself a complete burglar alarm system with Domoticz controller running in a RaspberryPI (single board computer with 2.3W power consumption) , RockPIS (tiny single board computer with only 400mW power consumption) or another type of hardware.

It manages 3 different types of alarm:

  1. Away, when nobody is home
  2. Night, when everybody is home sleeping
  3. Day, when somebody is home and want to detect any intrusion attempt

Why Domoticz? Because Domoticz is free and very reliable, it can be automatically updated safely; also it supports LUA scripting that permits to make easy-to-manage automations: in this case, a configuration file and some LUA  or Bash scripts: one is called at the activation of the scenes AlarmAway, AlarmNight, AlarmDay, and onother one is called to record video from IPcams in case of outdoor sensors activation.  Just change the config file to set which sensors and sirens to manage.

Using DomBus modules to interface alarm sensors it's possible to get reliable home automation wired network, with bus cable that interconnect all sensors carrying both data and power supply. Also, it's possible to supply everything with a 12V lead acid backup battery, so the system will work even in case of power outage.  In any case, the alarm scripts described below work with any kind of sensors. Last, but not least, DomBus modules permits to achieve a very very low power power consumption.

The alarm can be enabled/disabled through 3 scenes/group, as showing in the picture, or by pushbuttons, fingerprint readers, keyboards, RFID or NFC tags, ....

Check the section below to know how to add icons on your smartphone to activate/disactivate alarm!

All notifications will be available in Telegram, as like as short videos that are recorded and sent to Telegram when an external sensor is activated: to make it easier to check what happen when a sensor activates, 20 seconds of video is recorded with speed 2x, so it's possible to check it in only 10 seconds.


telegram app showing alarm status and videos


  1. Three types of alarm: day (only emits a short pulse on internal siren, if someone open a door or window or shutter), night (activates only internal sirens and some lights), away (activates internal and external sirens).
  2. full notifications through Telegram app
  3. manages up to 64+64 magnetic contact sensors (but can be easily expandable to a higher number), 32 PIRs, 32 tampers, 32 sirens
  4. alarm can be activated/disactivated by pushbuttons, smartphone or other devices (fingerprint readers, keyboards, ...)
  5. the script is able to send a short IP-Cam video (15-20s) when external PIRs/Radar/sensors have been activated, showing the video in Telegram to let the owner know what happen externally. This is useful to monitor if someone (or maybe a cat!) is walking around the building while alarm is activated. To get a fast video checking, video are recorded with speed 2x!
  6. Also, one or more displays connected to IP-Cam or NVR can be power-on when a external sensor has been activated, showing the external IP-CAMs


From linux shell, type the following commands (copy&paste):

sudo su -   #get root access
apt update; apt install lua-dkjson git #install lua dkjson library and git
cd ~pi/domoticz/scripts/lua
git clone #get all scripts from CreasolTech into domoticz_lua_scripts dir
cd domoticz_lua_scripts
#add some files, if they not exists
cp -n config_alarm.lua globalfunctions.lua globalvariables.lua script_device_alarm.lua ..
cd ..


First, name all devices using the following prefixes:

  • MCS_ for magnetic contact sensors, for example MCS_Door_Garage, MCS_Window_Kitchen, ...
  • PIR_ for PIRs, for example PIR_Garage, PIR_Kitchen, ...
  • TAMPER_ for tampers, for example TAMPER_Blinds_GroundFloor, ...
  • SIREN_ for sirens, for example SIREN_External, SIREN_Internal
  • ALARM_ for pushbuttons used to activate/disable alarm, for example ALARM_Pushbutton_Bedroom, ...

Configure the file scripts/lua/globalvariables.lua writing your telegram chatid, api key, ....

Configure the file scripts/lua/config_alarm.lua writing the list of sensors and your preferences

Configure the file scripts/lua/ writing in the SIREN_IDX the list, separated by a space, of all idx of devices that are activated in case of alarm (external siren, internal siren, lights, buzzers, ...): in this case if a alarm occurr, it's possible to push the Off button on AlarmXXXX scene/group to activate the script that will disable all sirens/buzzer/lights that have been activated by the script_device_alarm.lua script.

Screenshot of the configuration file for the free burglar alarm system using Domoticz


Domoticz supports several protocols and hardware types.
As we produce home automation modules for home automation systems, we can say that our DomBus modules are very reliable, work also in case of power outage (just use a 12V lead-acid battery to supply the bus), very low latency and very very low power consumption.

DomBus37 is a module designed specifically for alarm system, with 11x inputs (doors/windows/blinds magnetic contact sensors, PIRs, tamper, ...), ability to supply and monitor power usage of an external siren, 3x relay outputs and 3x AC inputs (to monitor power outages on heat pump, fridges, whole house, ...).

DomBus37 alarm module for home automation systems, with 11 inputs, siren power supply and monitor, 3 outputs, 3 AC inputs

DomBusTH for example is a cheap and compact module, no case, that can be placed on blank covers with a 3-4mm hole in the center, and it's ideal to be placed in any room to monitor temperature+humidity, has red/green/white leds that can be used as status and emergency light, 4 I/Os that can be connected to magnetic contact sensors, PIRs, pushbutton, buzzer, counters, ... and 2 open-drain outputs that can be connected to external relays.

Creasol DomBusTH domotic module to realize a powerful and cheap burglar alarm system


DomBus12 is another cheap and compact module, with 7 inputs, that can be used to connect alarm sensors , and 2 open-drain outputs, that can be connected to external relays.

Creasol DomBus12 application note: PIR, magnetic contact sensors, to realize a burglar alarm system using Domoticz home automation


DomBus31 is a domotic module with 8 relays, optimized for very low power consumption: less than 10mW in stand-by (all relays OFF), and LESS THAN 500mW with all 8 relays ON: unbeatable!
As comparison, usually home automation modules consumes at least 400mW for a single relay!

DomBus23 is a sophisticated module with different types of inputs and outputs.

DomBus modules are not wireless devices: they communicates by the strong RS485 standardl at 115200bps, so they can be connected together using any kind of bus topology using a thin 4 wire shielded cable: 2 wires for 12V power supply and 2 wires to exchange data. No RF pollution, no batteries, no latency!
Using a 12V power supplier that manages a 12V lead-acid backup battery, it's possible to get a domotic network that works even in case of blackout.
When a DomBus module is connected to the network, Domoticz automatically recognized and show all ports (plug&play): each port can be configured through the Domoticz web interface. Also, to get the home automation system working even in case the controller (Domoticz) is down, it's possible to program each port to control ports on the same or other devices, like KNX network: for example, if a button is pushed for less than 0.5s, switch ON for 123 seconds the output2 of module X and output 1 of module Y, while if it's pushed for 1 second, toggle ON/OFF output 3 of module Z. Or, if temperature < 21 degrees, turn ON heater, while if temperature > 21.4 degrees turn it OFF. More info in the device page, DCMD section.

DomBus network and connection - Home automation system

Add icons to smartphone to enable and disable alarm system

It's very useful to have in the smartphone an icon to enable away alarm when leaving the house, and one to deactivate the alarm system before entering the house.

Adding icons on the smartphone to have HTTP URL shortcuts to some functions, such as alarm on and offDomoticz supports many HTTP commands to activate scenes, groups, switches, ... and smartphones have many applications that can be used to call such URLs.

  • Install on your smartphone the HTTP Shortcuts app
  • Create a new regular shortcut, specifying a name (in the example Alarm Away)
  • Specify the URL to call the Alarm Away group/scene (you have to edit that group/scene to get its idx, 13 in the example) writing the right parameters (IP, PORT, idx)
  • Enable base autentication, specifying the domoticz username and password
  • Choose an icon
  • Save, and add the icon to your smartphone home screen.
  •  Duplicate this icon, edit the new one, change name to Alarm Off, change icon, change URL replacing On with Off , save and add icon to the home screen.

Now you have two icons on the smartphone, one to activate alarm system and one to disable it.