Node-RED + Home Assistant Security System

In this post, I will show how I setup my home security system. Setup this way, it is a manual system, and will need to be manually armed and disarmed. I will share how I’ve automated the system in later posts, that will be linked here.

My last two houses were smart homes. SmartThings was my hub of choice at the beginning, and it was good. One of the things I liked so much about SmartThings was the Smart Home Monitor that is built in. This does a few things, one of which is act as a security system, which is what we used it for. There is nothing like this built into Home Assistant out of the box, so one of my first goals when learning Node-RED was to create a home security system.

Home Assistant has a built in Manual Alarm Control Panel that can be used to build a security system, which all has to happen in the config files. Since I’m doing all of my automations in Node-RED, I wanted to try building a security system from a combination of the built in panel and Node-RED. I wanted to be able to set the alarm mode from the panel and have Node-RED handle the rest.

To start off, I created an “alarm.yaml” in the config directory of Home Assistant, and made sure to add “alarm_control_panel: !include alarm.yaml” in the config file. This is the code that I used, which will allow the away alarm to trigger after 120 seconds, and give you 30 seconds to leave the house once it’s armed. All other modes arm instantly.

This will create a “alarm_control_panel.home_alarm” entity, which when used in Lovelace, looks like this:

So now that the front-end is done, time to move on to the back-end of the machine. I built all of the logic within Node-Red. This is how the finished result looks.

The “events: state” node undefined grabs the status of the Manual Alarm Control Panel, and passes it on to the switch node undefined which then filters the alarm status to the appropriate output.

Below that, is the trigger automation. The “Alarm Triggers” sub-flow contains all of the doors and windows in the house, which is connected to another sub-flow that checks if the alarm is armed either home, or away, and then passes it on to a call service node that triggers the alarm, and finally sends a Telegram notification letting us know the alarm has been triggered, along with a button to Disarm the alarm. Example of the “Armed Home” sub-flow.

Sub-flow for the Armed Home mode for reference,

Since there’s so much going on with this flow, I won’t go through it in detail, but I will post the code which you should be able to work off. It’s pretty straight forward.

Here’s the Node-RED code: Security System
Here’s the yaml code for the panel: alarm.yaml

Currently, there is zero automation involved. This has to be manually set, but I have location and timed based automations which I will share in future postings.


8/24/2020 – Updated the alarm.yaml code to reflect recent updates Home Assistant has had regarding the manual alarm panel.

15 thoughts on “Node-RED + Home Assistant Security System

  • A big THANK YOU!! I stumbled onto your page by luck. Thank you for the great writeup. I’ve already started integrating it into my HA system using Node-Red and Konnected.


  • Justin, question that you might be able to assist with. Ideas on flows for including a motion sensor during away mode vs stay? I can’t seem to wrap my mind around that.


  • Hello, when alarm-away is active and a sensor triggers alarm, the alarm ‘triggers’ after the delay-time (pending). No problem so far. But how can you automate (with node red) a notification that is send after the delay time. My nofiticati


      • Hi, sorry for my not complete comment. But I already found a solution. Thanks anyway. And thank you for your post regarding the alarm setup


  • Hi Justin, solution I have found is not optimal. This is the case: When alarm_away is active and it is triggered you can set a delay in configuration.yaml. The alarm is triggered after delay. So far so good. But I want an alarm (trigger) notification and in the same (!) notification which sensor is triggering the alarm. Any ideas?


  • Hi Justin. This helped me a lot. Thank you. I have a question you may help with. I have both door sensors and motion sensors. I want both door and motion sensor to trigger if armed_away is armed. But in armed_home I only want my door sensors to be triggered. This is useful if I want to turn on alarm when at home at night etc. Do you have any ideas how this could be done?


      • Hi, like the person below would really like to have a look at your seperate home and armed. Could you share a link to your codes? Thank you!


  • Hi, the file “yaml code for the panel: alarm.yaml” is missing from the server.
    If you are so kind to check… thank you


  • Hey Justin- this flow has been great. Quick one: How do I prevent the system from arming when one of the door/window triggers are already on? (In other words, I don’t want to arm the house having accidentally left a door open.)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s