Advanced Events handling in Domoticz

In previous post (can be found here) we created a simple event handler in Domoticz to control a power plug based on the events from a motion sensor. In this post we will step it up a notch and build a basic alarm system. If you are not familiar with the Events interface in Domoticz, we recommend you go through our previous post first.

Building a basic alarm system using the Events interface in Domoticz

We want our alarm system to be able to do the following once we have set up the handling of the events:

  • Arm/disarm the alarm system
  • Trigger the alarm (if armed) with a delay of 45 seconds. The reason for this is that we want to be able to enter the door and have time to disarm the alarm without triggering
  • Stop the siren if entering the correct pin code
  • Let the siren time-out after 3 minutes. The alarm system will still be in “armed” mode. If the burglar has not been scarred after 3 minutes, the siren will most likely only annoy your neighbours.

For this project, we will use the following hardware:

We will be using the Z-Wave Power Plug to switch on a lamp instead of a siren, since it’s more friendly for our ears while developing. Once you’re done, it’s simple to exchange the power plug for a Z-Wave siren.

Starting with a map of states for the alarm system

Since this is a slightly more advance event handling then simply have a motion sensor control a lamp, we need to map out which states our alarm system can have during operation:

  • State 1: Disarmed
  • State 2: Armed
  • State 3: Motion Triggered
  • State 4: Sound siren!

The alarm system will switch state dependant on the events appearing. Here is how the system will jump between different states:

  • Person arming the system on the security panel: the system will jump to “Armed”.
  • Person disarming the system on the security panel: the system will jump to “Disarmed” regardless of previous state, the siren will be turned off.
  • If the system is armed and the motion sensor is triggered: the system will jump to “Motion Triggered”
  • If the system is in “Motion Triggered” after 45 seconds: the system will jump to “Sound siren!”
  • The siren has sounded for 3 minutes: the system will jump to “Armed” and the siren will be turned off. The system is ready to detect new motion.

Sketching this on a piece of paper looks something like this:


I know it looks a bit cluttered but it will be a big help when building the event handling.

Controlling events using states in Domoticz

First we need to create two things that we need for building our alarm system:

  1. A user variable that we call: “Alarm State”
  2. A dummy switch that we call: “Sound Siren”

Creating a user variable in Domoticz

Go to the Domoticz “Setup” drop-down menu and select “More Options” -> “User variables”.


Then enter the name “Alarm State” and the variable value “1”, and click “Add”.


Creating a dummy switch in Domoticz

Go to the “Setup” menu and select “Hardware”. This view should be familiar to you by now.


Enter the name “Sound Siren” and select “Dummy” in the “Type” drop-down list. Click “Add”.


The dummy hardware appears in the list where your Raspberry is. Next, click on “Create Virtual Sensors”.


Enter the name “Sound Siren Dummy” and select “Switch” in the “Sensor Type” drop-down list. Click “OK”. We will use this dummy switch to decide if we should start the siren. The condition is that we are in alarm state “Motion Triggered” and that the delay time of 45 seconds has passed. Now, on to building the events handling.

Building the events handling using the Events (Blockly) interface

Select “More Options” -> “Events” from the “Setup” menu. You can check the previous post if you’re not familiar with how the Events interface works (here). To arm our alarm system, we build the following event handler.


This will move the alarm system from state 1 (Disarmed) to state 2 (Armed). You find the “Alarm State” variable in the category “User variables” in the left side menu. The “Security status” switch is found in the “Security” category and is directly controlled by the Domoticz security panel that we will use later on. We save the event with the name “Arm alarm”. Don’t forget to tick the check box “Event active”. Next we create an event handler for disarming the alarm system.


This event handler puts the alarm system in state 1 (Disarmed) regardless of previous state. We also sets our Z-Wave power plug to “Off” since this represents our siren and we want the siren to be turned off once a valid pin code is entered on the security panel. Most often the siren is not on when someone enters the pin code since the most common use case is that you enter the pin code as soon as you open the door. In this case you have 45 seconds to disarm the alarm system before the siren goes off. We also make sure the dummy switch “Sound Siren Dummy” is set to “Off”. We save this event handler with the name “Disarm alarm”. Next we will create the event handler for state 2 (Armed).


This event handler captures the event of the motion sensor, puts the alarm system in state 3 (Motion Triggered), and starts a timer to sound the siren after 45 seconds. This time allows the owner of the house to disarm the alarm system without the siren going off. Save it as “Motion triggered”. We’re almost done, we now make the event handler for jumping from state 3 to state 4 (Sound siren!).


If we get the event of “Sound Siren Dummy” after the 45 seconds time delay in state 3, we should sound the siren. We also sets a 3 minute (180 seconds) time-out on the siren. Save this as “Sound siren”. Finally we need to create an event handler for state 4 (Sound siren!).


This will turn off the siren after 3 minutes and put the alarm system in state 2 (Armed) and the system will be ready to detect new movement. We save this event handler as “Siren time-out” which will give us the following complete list of event handlers:


Next we go on to using the security panel of Domoticz.

Using and configuring the security panel in Domoticz

If you go to the “Setup” menu and select “More Options” -> “Security Panel”, you see this view.


With this panel, you can arm and disarm the alarm system with just built. You can select the pin code in the “Setup” menu under “Settings”. Here you can also set a delay time in order for you to have time to exit your house before the alarm system is armed. Once you have tested the alarm system to make sure it works ok, you can replace the Z-Wave power plug with a Z-Wave siren.

Using Events in Domoticz

In previous post we learned how to group two devices (post can be found here). In this post we will use the Events interface in Domoticz to tell a switch to act on a certain event that appears. We make sure that we have “ungrouped” our Multisensor and Z-Wave power plug from previous post, since we are going to use events instead in this post. You ungroup in the same “Groups & Network” view showed in previous post. In this post we will use Events in Domoticz to control a Z-Wave power switch when an Aeon Labs Multisensor is triggered.

Equipment used in this post to control using Events in Domoticz

We will be using the same equipment as previous post:

Opening the Events interface in Domoticz

You find the Events editor by selecting “More Options” in the “Setup” menu and the select “Events”.


In the Events editor. You find a list of categories on the left. You can see this as the toolbox of blocks you will be using to control and manage your events. Click on the first entry in the list “Control”.


You see two blocks that looks like pieces in a puzzle, which they in fact are. We will be combining puzzle pieces in order to control our Z-Wave power plug when our Aeon Labs Multisensor is triggered. We start by dragging the first “If/Do” block piece to the white work space.


This “If/Do” block will allow us to “do” something “if” something else happens. If you’re a programmer, this is simple for you. If not, you will understand when you go through the next steps. Since we want to DO turn on our Z-Wave power plug IF our motion sensor is triggered, we go to “Devices” and select “Switches”. Here we find our motion sensor.


We click on “Our motion sensor” in order for it to appear next to the “If/Do” block that we place on the work space.


We do the same thing with our Z-Wave power plug.


Now, to control the logic so that the power plugs turns on when the motion sensor is triggered we need some additional logic blocks. Go to “Logic”.


Select the first green block with the “=” sign so it appears on the work space.


Go back to the “Logic” category and select the green box that says “On”. We now see the following blocks.


Since we want to DO something IF our motion sensor turns on, we attach the blocks to one another like this:


We almost done, but the power plug block is still not connected. We need a “Set” block and an “On” block to trigger the power plug.  Select these from the “Logic” category as you did with the previous blocks.


We connect these blocks to the “Do” part.


The logic won’t just work yet. We need to save it.


On the right side in Domoticz, enter a name of your choice, tic the “Event active” box, and click “Save”. If you now trigger the motion sensor, the Z-Wave power plug turns on. Yes! If you want the power plug to turn off when the motion sensor turns off, you can build the following logic. Don’t forget to save it for it to work.


The Aeon Labs motion sensor has a default time out set to 4 minutes.

In upcoming posts we will go through how to make more advanced logic using the Events editor in Domoticz.

Grouping an Aeon Labs Multisensor with a Z-Wave power plug in Domoticz

The Z-Wave technology allows for building a home automation network of sensors and switches. These sensors and switches, also called nodes, can communicate with each other through a central Z-Wave controller (i.e. a hub) or directly with each other. In this post we will show how to group an Aeon Labs motion sensor (actually a multisensor) with a Z-Wave power plug. By grouping these two nodes they can communicate independently of the central Z-Wave controller. That means I can turn off or remove the central Z-Wave controller and the communications between the Multisensor and the Z-Wave power plug still works. The setup we will go through here will be able to turn on a lamp when someone triggers the motion sensor.

What equipment do we use to group the Aeon Labs Multisensor with a Z-Wave power plug?


Grouping the Multisensor and the Z-Wave power plug

In Domoticz, go to the “Nodes” list for your Raspberry controller. You do this by selecting “Hardware” in the “Setup” menu in the upper right corner of Domoticz.


Then click on the blue “Setup” button. Now you should see the “Nodes” list. Go on by selecting “Groups & Network” from the “Node management” drop down menu.


In the table of nodes and groups, you can see which nodes are associated to which groups. Each node can add other nodes to its groups to make the added nodes listen to certain events without the need for going through the central Z-Wave controller (in our case our Raspberry unit). What we want to do is to turn on the lamp connected to our Z-Wave power plug when someone triggers the Aeon Labs motion sensor.


In our case, node number 6 is the Aeon Labs Multisensor 6 and node number 5 is the Z-Wave power plug. Node number 1 is the controller (i.e. our Raspberry). To make our Z-Wave power plug turn on and thus turn on our lamp, we need to add it to Group 1 of the Aeon Multisensor. So, we go to the row for node number 6 and click on the blue “+” button next to the number “1”.


In the pop-up box, we enter “5” since this is the number of our Z-Wave power plug who should get the information that the motion sensor is triggered. Click “Save”.


You might have to close the “Groups & Network” view and open it again for the group information to be updated. Now, node number 5 should be visible in group 1 of the Multisensor (i.e. node 6). At the dashboard off Domoticz, we ensure our Z-Wave power plug is turned off and that the motion sensor is not triggered already.


We test if our group association between the Aeon Labs Multisensor and the Z-Wave power plug works by triggering the motion sensor (i.e. waving our hand in front of the sensor). And…


…yes it works! Success! If you wait until the motion sensor times out (default it’s 4 minutes), the lamp should go off since the Z-Wave power plug listens to the “off” signal from the motion sensor. This only works if no motion is detected during these 4 minutes. You can also verify that the association between the motion sensor and the Z-Wave power plug works without the central controller, by simply turning off the Raspberry.

In future posts we will go through how to do more advanced controlling of sensors and switches by programming states, events and timers.

Adding and configuring Aeon Labs Multisensor 6 in Domoticz

In previous post we added a Z-Wave power plug in Domoticz (click here to read the post). Now, in this post we will add and configure an Aeon Labs Multisensor 6 in Domoticz. The multisensor is one physical device but comprises six different sensors:

  1. Motion sensor
  2. Temperature sensor
  3. Humidity sensor
  4. Vibration sensor (mainly for tampering alerts)
  5. Light sensor (measured in Lux)
  6. UV sensor

After adding the multisensor, we will be focusing on the features of the motion sensor, the temperature sensor and humidity sensor.

What equipment do we use to add and configure the Multisensor 6?


  • A Raspberry Pi 2 (model B) with a Razberry Z-Wave add-on card
  • Domoticz (installation guide can be found here)
  • Our Aeon Labs Multisensor 6
  • A 5 volt micro USB power adapter (or two CR123A batteries)

Adding the Multisensor 6 in Domoticz

Our Multisensor has factory settings. If yours has not, make sure you reset it by pressing and holding the action button for 20 seconds carefully while the Multisensor is powered on. This will reset it to factory settings.


You can use the Multisensor with both a power adapter and batteries. For the sake of simplicity we use a 5 volt micro USB power adapter while we configure it. To add the Multisensor in Domoticz, we start exactly as we did with the power plug (explained in this post) by selecting “Hardware” in the “Setup” menu, which gives us this view.


Then we click on the blue “Setup” button next to the version number.


In the ”Node management” dropdown list, click on ”Include Node”.


The inclusion process starts and we click once on the Action Button on the Multisensor (make sure it’s powered on).


In the nodes list of our Raspberry controller we can now see our Aeon Labs Multisensor 6 showing up next to our Philio power plug we added previously.


Selecting “Devices” in the “Setup” menu in the upper right corner of Domoticz, gives us the list of devices in our Z-Wave network. You realize that we have 7 new entries. This is because the Aeon Labs Multisensor 6 comprises several sensors in one physical unit (hence the name “multisensor”) and two virtual sensors.


We’d like to use the motion sensor and the Temp + Humidity sensor and add them to our dashboard of Domoticz. On the right side of the row of the Temp + Humidity sensor we click on the green arrow to add the device to the “Temperature” tab of Domoticz.


Give it a name of your choice and click “Add Device”.


Now, go to the “Temperature” tab and click on the star icon (to the left side of the “Log” button) so it turns yellow.


Looking at the “Dashboard” tab of Domoticz, we find our temperature and humidity sensor and our previously added Z-Wave power plug.


We do the same thing for the motion sensor (default name is “Sensor” in the device list) so it shows up on the dashboard as well.

Calibrating the values of the Aeon Labs Multisensor 6

You might already have recognized that the temperature and humidity values of the Aeon Labs Multisensor 6 are incorrect. The good news is that they are possible to be calibrated. Start by taking a temperature sensor you trust showing a correct value and place it next to the Multisensor.



Take note of the value the external temperature sensor shows and also the value that the Multisensor reports to the Domoticz user interface. In our case, we get 21.3 C on our external temperature sensor versus 23.5 C from the Multisensor. The temperature difference is thus -2.2 C. To calibrate our Multisensor by this difference we go to our “Nodes” list by selected “Hardware” in the “Setup” menu and then click on the blue “Setup” button.


Make sure you have clicked on the “Aeotec Multisensor 6” row in order for the parameter input fields to show up under “Configuration”. Scroll down to parameter 201.


If your Aeon Labs Multisensor 6 shows an incorrect temperature value, you need to enter a calibration offset value in the “Temperature Calibration” field. For example, if your Multisensor shows a 1.4 C too low value, you should enter the value 14 (if it’s 2.3 C too low, show should enter 23 and so on). It’s a bit more tricky if your Multisensor shows a too high value, which is our case. We want to calibrate the Multisensor by adjusting -2.2 C degrees. To do this we substract 22 from 256 and end up with 234. This is the value we enter. If it would have been -3.4 C degrees, we’d have to enter 256 – 34 = 222 instead.


We enter 234 and click the blue button “Apply configuration for this device” at the bottom of the page. Soon, we should see our Multisensor reporting a correct temperature value. It might take some time dependant how frequently the temperature sensor reports the temperature value to the Raspberry controller.


Yes! Now the temperature looks much better. We go back to the configuration parameters again and do the same thing to calibrate the humidity value.