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.
I have 6 Hue A19 Color bulbs in the ceiling of my kitchen. We were using them with standard dummy switches, which was a pain as I had to constantly remind people to leave the switches on. Not to mention that it is bad for smart bulbs to be constantly powered on and off. I was about to pull out the smart bulbs and install standard LED lights and go with smart switches, but I really did not want to do this, as the individual bulbs are used for certain automations. For example, a nightlight where bulbs 1 and 3 are motion controlled to come on at 5% if everything else is turned off, and it’s dark outside.
How to get around this to keep my smart bulbs AND keep them powered at all times? At first, I tried using a Sylvania Dimming switch and control the lights with a scene. This switch is placed over the existing dummy switch, which you leave flipped on. Since this was a 3-way setup, I put a switch cover over the second switch (you could also get a second Sylvania switch). This worked….I now had always powered and physically controllable smart bulbs, and although it was a practical solution, it was kind of ugly. The wife definitely didn’t like the look in her new home, so I was back to trying to figure this out.
All of the smart switches in my house are of the Go Control / Linear / Nu Tone variety. These are all made by the same manufacturer, but sold under different names. They are not Z-Wave Plus, but I got the first one years ago and have been matching them together ever since. I haven’t noticed any downfalls of them not being Z-Wave Plus, but they’ll eventually be upgraded. For a three way setup, there is the NuTone NWT00Z which are not standard add-on switches. These are “virtual 3-way” switches. The low ratings on Amazon are somewhat understandable as the documentation (PDF of the manual here and here) is cryptic at best, and does not say explicitly how to use these. I will say that we’ve had these installed for a few months now with zero issues.
The way these are intended to work, are as “remotes” to other switches. In my entryway, I have one installed in a 3-way setup with a NWD500Z dimmer switch. You wire it up and and it controls the master switch in a zwave group association, but we’re going to do something different with them.
I used two of these in my kitchen. The way to wire them and have the lights always on is an odd way. Take the load, line and traveler wires from the wall, as well as the load line from the first switch and connect them all together. The ground and neutral are wired up as normal. The second switch needs to be wired a little differently as well. Take the line and load wires from the wall, cap them together and stuff them into the wall. Take the traveler wire, which is now a constant 120v line, and connect it to the load line of the NWT00Z. Wire the ground and neutral up as normal.
Now what we have are two smart switches that are wired up and connected to the mains, but they do not control the power to the lights. The power is now constant to the smart bulbs. At this point, the lights will stay powered on, unless you control them from Lovelace or using voice if you have Google Home/Alexa setup, but theres no way to mechanically control them yet. The hard part is done and we now have to head over to Node-RED and start working on the automation to turn these on or off.
We can’t add the switches to a Zwave group association, as the Hue lights are zigbee. So we need to grab the zwave event type commands coming from the switch. To do this, use a “events: all” node and filter “zwave.node_event” commands. Example below.
So now we’re grabbing all node_events from the “zwave.” domain, now we need to filter them. To do this, we need a switch node to filter the “payload.entity_id” from the specific switches we setup. You’ll need to use the name that you gave these switches when including them in your network. One thing to remember, you need to use the “zwave” domain name, NOT the “switch” domain name.
At this point, we’re filtering the two switches with “payload.entity_id”. Now we need to filter it down again to get the actual commands from the switches. With these switches, “0” is off and “255” is on. We need another switch node and filter “payload.event.basic_level“. This will grab all “.basic_level” events that come over the two switches. You’ll want to connect both output nodes from the previous switch node to the input on this switch node. This will filter all commands from both switches to this node. In this node, the top output will be “on” and the bottom output will be “off”.
We’re almost done at this point. Now we need to use a call service node to turn on, and off the lights. I forgot to mention earlier that the easiest way to control multiple lights, is with a light group. This will create a “group.kitchen_lights” entity in Home Assistant. You’ll need to do this in your config.yaml or groups.yaml in Home Assistant.
Now we take a call service node, and configure it to control the kitchen_lights group. We need one for on, and one for off. The “on” node will be connected to the top output, and the “off” node will be connected to the bottom output.
Here is how the entire flow looks:
With this setup, we have Hue smart bulbs that are always powered and can be manually controlled by a switch. This allows individual bulbs to be used in automations and you don’t have to worry about the switches, like in me previous example of using lights 1 and 3 for a nightlight.
One more thing to keep in mind; When smart bulbs lose power, they will come on at full brightness when power is restored. The Hue bridge however has a setting for “power on behavior” where you can tell the bulbs what to do when power is restored.