Home Automation, part 7: Alarms and alerts flows with Nodered

Tuesday, March 9, 2021



Following my previous posts about my automation flows, my night and morning routines and my leaving and arriving home routines, in this post, I want to describe the different alerts mechanism I have in place.

The involved devices are: - A raspberry pi 0W with a fisheye camera pointing at the door entry running motion (but more on this in my next post); - Zwave devices: Door sensor, Water leak dectector, Smoke detectors; - My homelab cluster with NodeRed, Domoticz and Mosquitto;


Always on detectors

Smoke and Water leaks

I have a few “always on” detectors. I use a water leak and a smoke detectors. They do ring very loud in case of water or smoke detected but also connect over zwave so that domoticz can receive information when an alert is raised by one of the devices. I’ve explained how NodeRed listen to Domoticz MQTT message for all devices and republish this in a proper way.

This is the smoke detector flow:

Figure 1: NodeRed Smoke Flow

Figure 1: NodeRed Smoke Flow

As you can see, based on the message receive, I send a notification via telegram.

The Start Alert subflow looks like this:

Figure 2: NodeRed Startalert Subflow

Figure 2: NodeRed Startalert Subflow

The message indicates the alert, eg: “Alert: Water leak detected” or “Alert: Smoke detected”. Then, like for night / morning routines, it asks me if this is a real alert or not. If I don’t respond, it will tell me every 10min that the home is still under alerts.

If I say it is a real alert, then for now it does nothing except wishing me luck… Not very useful yet but I have some ideas to implement here.

This is the nodered flow that checks for unresolved alerts:

Figure 3: NodeRed checks for alert every 10min

Figure 3: NodeRed checks for alert every 10min

The rules here are just passing parameters to the alert to indicate it is a repeat and not a new alert. It means that the message will be different (eg: “Home is still under alert (<reason of the alert>), do something!”).

The “show notification” subflow will just display the alert on NodeRed dashboard (so at least on my touch screen in the living room and any other place where the dashboard is loaded).

This is the water leak flow:

Figure 4: NodeRed Water flow

Figure 4: NodeRed Water flow

Same kind of alert/questions is sent for this one. You can notice in this case that the alert can stopped itself if the water leak indicates that everything is fine again.

The stop alert subflow looks like this:

Figure 5: NodeRed Stop alert flow

Figure 5: NodeRed Stop alert flow

Very simple, remove the alert and send back a message.

Entry Door

I also have an “always on” check on the entry door where I have a small z-wave device that checks if the door is closed or opened. When home, I will get an alert if a door has been opened for more than 2 minutes.

The flow looks like this:

Figure 6: NodeRed Alarm Entry Door opened for 2min

Figure 6: NodeRed Alarm Entry Door opened for 2min

Basically start a counter that will wait for 2min. If nothing happened during this 2 minutes, then an message will be sent to my phone on telegram. If that’s the case while in away mode, it will raise an alert too (see below).

If the door is closed faster than 2 minutes, the counter is stopped and nothing is sent.

Away mode alerts

When in “Away” mode, I have the following running: - Check if entry door is close; - Check for movement in living room; - Check for movement in office. - Camera with motion detection pointing at the entry door;

The nodered flow for the first 3 ones looks like this (still based on the mqtt messages received1):

Figure 7: NodeRed Stop alert flow

Figure 7: NodeRed Stop alert flow

You can notice that the entry door alert here is fired by motion and the camera, not the entry door (not the same MQTT topic). That is because the entry door is managed elsewhere, as shown in the picture above in the entry door flow.

Basically, when receiving a mqtt message indicating some movement in the office, the living room or at the entry door, if the mode is “away” then it will start an alert as well as send me a notification via telegram.

Same for the entry door, if it is open while in “Away” mode, I’ll get a message on telegram and an alert will be raised.

I haven’t program anything yet in case of emergency, but I’m thinking potentially of a message indicating their faces have been recorded and sent to a remote server as well as playing an alarm sound at maximum level in every room. But I didn’t set it up yet.

A detailed post on managing the motion (on/off, captures, backups etc…) will follow soon as it would make this post way too long :).

  1. See this post for more details on mqtt management. ↩︎


If you find any issue or have any question about this article, feel free to reach out to me via email, mastodon, matrix or even IRC, see the About Me page for details.

See Also

Home Automation, part 8: Entry door detection with Motion and NodeRed

RCA of my homelab cluster downtime