Home automation using Domoticz, MQTT and Node-red


I've been using Domoticz as my main sensor/actor software for a while now. I've started using a Raspberry Pi, and slowly moved my gear onto a great small piece of 64bit computing called Pine A64.

The SoC board runs Debian Jessie, aarch64.
Connected to this board is the ZWave shield for Pine A64 and I have a RFLink connected to it.

First of all I should explain the difference between ZWave and the devices that are being used with the RFLink device.

ZWave is an encrypted bidirectional protocol that enables you to have reliable wireless connections. The ZWave devices build a mesh network and the more you have the more stable the network becomes. Because ZWave is bidirectional it provides you with feedback. For example: a ZWave light switch will confirm if the action you triggered was actually executed.

RFLink is a device that is able to send and/or receive 433Mhz and 868Mhz signals from the air. These signals are not standarized and the signals are fire and forget. These kind of devices are ideal to use for non-critical nodes in your Smart Home, I use them for christmas lights and other temporary switches. You can also use them to read out weather stations (which usually use 433Mhz to transmit their data) or similar equipment.

As you can notice I have a distinction in the kind of service I expect from my devices. There is a critical class and a non-critical class.

For all the devices that Domoticz supports it works pretty well. But you are dependant on the supported equipment list. Also the rule engine of Domoticz is pretty basic using Blockly or pretty advanced if you're using LUA scripts. After using this setup for a while I noticed that I would like more flexibility from it.

Node-Red And this is where Node Red comes in. Node red is described as a "A visual tool for wiring the Internet of Things". And this is exactly what it does. The concept works with nodes and flows. Nodes are pieces of logic, flows are the data stream that consists of several nodes.

To connect Node-Red to Domoticz you have to use a messagebus, MQTT. I have used the reference implementation: Mosquitto

Domoticz publishes every event that happens into the MQTT bus out-queue, and it continously listens to events in the in-queue. This enables us to talk to Domoticz and listen to it's events.

We can pick up these events in Node-Red by using the MQTT in-node. This node subscribes to in-queue events and enables us to pick up this data and use it in Node-Red. The same way we can use the MQTT out-node to trigger actions on devices connected to Domoticz.

Example use-case

I am slowly migrating all my home automation logic into Node-Red, making my logic less dependant on a specific piece of software like Domoticz. And it enables me to combine the Domoticz set of features with other logic functions.

For example I have an IP camera in my garage. I also have a motion detector in a corner of the garage picking up movement. As soon as Domoticz publishes a movement event Node-Red triggers a HTTP GET request to the camera to get an snapshot. It puts this in a binary buffer and forwards this to a Telegram chatbot node. Whenever someone enters my garage I now receive an image on my phone.


In this blog I explained how I setup my home automation setup and my reasoning for it. In upcoming blogs I will explain a bit more how it is setup in detail.