*The article below contains affiliate links. If you purchase an item after clicking on that link, I will receive a commission. Thank you!
So you have a light switch, and you can turn a light or set of lights on and off. That’s standard. But what if you could double tap that same light switch and turn on a separate set of lights? Maybe you have Philips Hue or LifX bulbs and no remote, and don’t want to get your phone out? You could double tap your light switch and turn them on that way. Just got home from work and like to turn on some ambient lighting and start Dean Martin radio playing through your speakers? Just a double- or triple-tap away with your new z-wave smart switch. How is that possible? Let me show you.
Prerequisites
For starters you will need to have your home assistant server setup and ready to go. You will also need to have the Z-Wave JS integration setup and installed. In order to control Z-Wave devices in your smart home, you will need a Z-Wave dongle installed. You will also need to have the Node-Red add-on installed and set up. For this example we will be looking at a Z-Wave light switch. More specifically we will be exploring the Enbrighten Z-Wave Dimmer switch. You can read my review on the Enbrighten dimmer switch here.
Node Red Flow
In order to explore our z-wave switch, we will need to use two nodes. We will need an Events:All node and a debug node.
Events: all Node
The events all node is exactly what it says. It listens to every event that happens in your smart home and passes those down the flow. This node needs to be setup since there are way too many events happening at all times to try and decipher them. We will need to add the listener so that we are only listening for events fired for the Z-Wave JS integration. The exact value for this is zwave_js_value_notification.
Name: Name this to keep it organized. I use “Z-Wave Events”
Event Type: This is where you input the event you want to listen to. We will use “zwave_js_value_notificatio”
Debug Node
This node does not require any setup. This node will take the information passed to it, and display it on the debug screen. The debug screen can be found on the far right side of Node-Red. You may need to select the bug icon to see the screen. It is also a good idea to press the trash can to delete any debug information that is already on that screen.
Firing Events
Now that we have the flow deployed and we are looking at the debug screen, it is time to fire events. Walk over to the switch that you want to control and press the “on” paddle. This will turn on your light, for one, but it will also send a z-wave event to your smart home. That z-wave event will go through the z-wave integration and show up in the debug screen.
Interpreting Events
We now have our payload object for our “on” event from our Enbrighten Z-Wave switch. If you are using a different switch, or using a different device, your debug screen might look slightly different. We want to press the small arrows in the debug log so that we can expand it and see what was actually sent to the server.
Looking at this expanded z-wave log, we can see the event object and all of the information sent to the server. There are a few important pieces of information we are looking for in this log. First, we will need to keep note of the “node_id.” In may case the node_id is “4.”This tells the server which light switch sent the signal. When we look to use this switch for automations, we will use the node_id to make sure we grab the correct events.
Next in the z-wave log is the scene that was sent. Each separate event in this z-wave switch is a scene. When you press the “on” paddle of this switch, it sends the “Scene 001” command. This is found on the “label” tag in this z-wave event log.
The value tag explains what happened for that scene. In this case the paddle was pressed one time, so it says “KeyPressed.”
Putting it all together, we can see that pressing the “on” paddle on this switch sends a signal to our smart home that says node_id 4 sent the Scene 1 command.
Finding All Commands
Now that you know how to interpret one command, it is time to start hitting buttons to find what else the switch that can do. You can press the switch off and get the next scene, you can hold the switch on and/or off to see what that scene shows, and you can also get fancy. This switch allows for double- and triple-clicks.
Pressing the “off” paddle on the switch sends the above event. Scene 002 is the scene that gets called when you press the “off” paddle on the z-wave switch. The important information here is in the value. It now says “KeyPressed2x.” This is because we pressed it twice. If we pressed it three times, it would be Scene 002 with the value of “KeyPressed3x.”
Enbrighten Quick Reference
For the Enbrighten Z-Wave switch, which you can buy here, I have gone through and found all of the available commands. Below I will break them down by scene and event:
Physical Switch Activity | “Label” From Z-Wave JS | “Value” From Z-Wave JS |
---|---|---|
Press On Once | Scene 001 | KeyPressed |
Press On Twice | Scene 001 | KeyPressed2x |
Press On Three Times | Scene 001 | KeyPressed3x |
Press Off Once | Scene 002 | KeyPressed |
Press Off Twice | Scene 002 | KeyPressed2x |
Press Off Three Times | Scene 002 | KeyPressed3x |
Hold On | Scene 001 | KeyHeldDown |
Release On | Scene 001 | KeyReleased |
Hold Off | Scene 002 | KeyHeldDown |
Release Off | Scene 002 | KeyReleased |
Bonus Node-Red Flow
You now know how everything from this switch works. Using some switch nodes in Node-Red we can create a flow that can handle all of these switches throughout your smart home.
Let’s walk through this flow, first we have the Z-wave JS value notification events coming in. The first stop is to check which switch sent the message, we use a Switch node to filter the node_id for this. This value is found within the event section of the payload so the property value of the switch node should read msg.payload.event.node_id. You will add a new line for every light or “node” in your system, and type in the exact node number for that switch. My switch for the example above was node “4” so the number 4 is one of the items on the list. Every light switch will have it’s own set of the following nodes. On or off will determine if the on or off switch was pressed. We do this by capturing whether Scene 001 or Scene 002 was sent. After that you will check for multiple presses, so another switch node that will filter KeyPressed, KeyPressed2x, and KeyPressed3x.
Using this flow, you can add a new line to the “Check Switch” node and add the next switch into the system. So theoretically, you can have 6 events fired from every z-wave switch in your smart home.