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 grabs the status of the Manual Alarm Control Panel, and passes it on to the switch node
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.

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.
Updates:
8/24/2020 – Updated the alarm.yaml code to reflect recent updates Home Assistant has had regarding the manual alarm panel.
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.
LikeLike
I’m very happy that it’s been helpful to you!
LikeLike
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.
LikeLike
What do you mean exactly? I’m happy to help, but give me a bit more info.
LikeLike
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
LikeLike
It looks like your comment got caught off, so you may have started to explain this, but do you already have notifications setup within Home Assistant?
LikeLike
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
LikeLike
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?
LikeLike