I’m going to show you how I used Home Assistant and Node-RED to make the LEDs on my Inovelli switches do a holiday dance whenever someone plays Christmas music with Alexa. Here’s what we’re going for:
Pointless? Pretty much. But maybe you’ll pick up some tricks to use in useful automations! Also, it was fun.
I bought some new Inovelli smart switches and dimmers for our new house. I’ve owned and sampled a lot of types of smart switches, and these are my favorites now (supplanting my previous choice, the Leviton Z-Wave). I like the Inovellis because they pack so much functionality into a well-built product at a good price, and the company is super engaged with its customers. Full review coming later.
Anyway, one of the features on Inovelli switches is a multi-colored LED. For on/off switches it’s a single light in the bottom right; for dimmers it is a multi-light bar that runs almost the entire height of the paddle.
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-2.png?resize=411%2C341&ssl=1)
Out of the box, these LEDs are blue and are used to show whether the switch is on/off and, for the dimmers, what the dim level is. But they can do so much more than that.
If you want to know how to do it, read on…it’s somewhat involved, but I learned a lot about Node-RED and Z-Wave configuration possibilities while doing this, so hopefully it will be enlightening (pun totally intended).
What you’ll need
The below assumes you have the following. It’s not a short list of stuff to setup, but I already had everything here installed for my normal home automation needs.
- Some Inovelli smart switches, obviously
- Home Assistant with the Open Z-Wave (beta as of now) integration setup, and your Inovelli switches added to it.
- The Node-RED add-on for Home Assistant and a basic familiarity with using it. There are tons of great tutorials out there for Node-RED, and I’ve switched to using it almost exclusively for my automation rules instead of the built-in Home Assistant automation framework.
- The wonderful Alexa Media Player add-on, which lets you take control of Alexa through your automations. This guide assumes you have this setup and your Alexa devices are shown in Home Assistant as media players.
For #2, it’s very important you use the new beta Open Z-Wave integration for managing your Z-Wave devices, not the “legacy” Z-Wave that’s the default in Home Assistant (as of late 2020). Only the newer Open Z-Wave will let you capture the events and send LED configuration parameters to the Inovelli switches that affect the LEDs.
Step 1: Detecting Christmas music from Alexa
The trigger for this all to happen is someone playing Christmas music with Alexa. To detect this, we’ll use the common “Events: State” node in Node-RED:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-3.png?resize=501%2C645&ssl=1)
I use an Alexa group called “Whole House” as my default speaker when we ask Alexa to play music, so that’s what I have this event node configured for. You should set it to whichever Home Assistant media player entity represents the right Alexa device for your situation.
Now, when this node activates, it fires off a message that includes the information we’re going to need next — that is, what music is playing. It’s buried in the object, which we can see if we send the message to a debug node:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-4.png?resize=580%2C354&ssl=1)
So using the information in this message, we can setup rules that will be able to determine when Christmas music is playing with an acceptable level of accuracy. Since I really only care about the “new_state” part of the above message, I use a Change node to quickly set that as the msg.data object (this saves a lot of typing in later nodes):
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-5.png?resize=494%2C323&ssl=1)
Then I use Switch nodes to check the title, album, and artist elements in the object for the string “Christmas”, since one of those will almost always contain that string when you ask for Christmas music. It’s not foolproof but it’s close enough:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-6.png?resize=616%2C195&ssl=1)
If the part of the message I’m targeting contains that string, the message is passed along. If not, it stops.
And that’s the Alexa part of the automation. Next we’ll dip into the Z-Wave part, which is where things get a bit more complicated.
Step 2: Setup your Z-Wave Node IDs and colors
Most Z-Wave devices have configuration options, called parameters, that can be set to control the device’s behavior. What parameters are available and what they do are up to the manufacturer. In the case of Inovelli, some of these parameters allow you to set the switch to display what they call a “notification”, which activates the LED according to a color, brightness, and blink pattern you specify.
The Open Z-Wave integration for Home Assistant allows us to set parameters for Z-Wave devices using the ozw.set_config_parameter
service. To use it, you have to provide three values: the node_id
(which device we’re targeting), the parameter
(which param we want to set), and value
(the value to set the parameter to).
Let’s test this on a single switch.
Finding your Node ID
To get the node ID, in Home Assistant go to Configuration > Devices and then search for an Inovelli switch that you have installed. For example, I have one that I had named “Kitchen Main” so I searched for that, and on that device’s details I can find the Node ID:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-7.png?resize=366%2C441&ssl=1)
We’ll eventually need to get the Node IDs for every dimmer and switch we want to make blink. NOTE: Keep the Node IDs for dimmers and on/off switches on separate lists, because the parameters and values we’ll be using are different for each type.
Find your parameter and value
Now that we know what Z-Wave node we’re going after, we have to figure out what parameter and value we’re going to give it. For this, we turn to a wonderful tool by Nathan Fiscus, the Inovelli Notification Calculator.
Using the calculator, we set our switch type (dimmer or on/off), then click on the Notifications tab. From here we can setup our LED to do whatever we want. Here I’ve picked a green color that uses the Fast Blink effect:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-8.png?resize=616%2C425&ssl=1)
You can also, usefully, set a duration, so the switch stops blinking on it’s own after awhile. You can do that, but I’m leaving mine at infinity because I am going to build my own control to stop them from blinking.
The box at the bottom called Configuration Value is what you’re after. For the dimmer shown above, to get the effects we’ve selected we’re going to set parameter 16 to the value 67045968.
Test it out in Developer Tools
Now that we have our node ID, parameter number, and value, we can test it in Home Assistant’s developer tools before we start wiring everything together in Node-RED. Go to Developer Tools > Services, then fill it out with your values:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-9.png?resize=512%2C423&ssl=1)
When you click Call Service, you should see the LED on the Inovelli switch start doing its thing.
Setup array of nodes
Now we need to get all the Node IDs and set them up as a flow object in Node-RED. We’re doing this so we can use other nodes later on to iterate/loop through all the switches we want to include in our automation.
Using an Inject node that fires on startup, linked to a Change node, we will set flow.xmas to an array of objects, each of which has a node ID, switch type, and the color we want it to be (red or green).
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-12.png?resize=616%2C218&ssl=1)
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-11.png?resize=616%2C899&ssl=1)
Getting the type correct for each node is very important, since the parameters for on/off switches and dimmers are different.
Step 3: Tie it all together
So by now we should have:
- A trigger and switches to check if Alexa is playing Christmas music.
- A flow.xmas object that contains all our Inovelli node IDs, along with the type and color for each.
Now comes the real Node-RED magic, where we’ll parse through our flow.xmas object and setup a message object for each switch.
The algorithm we’re creating is essentially this: Split the flow.xmas object, so that for each item in flow.xmas…
- Is it a dimmer or switch?
- If dimmer…
- Set parameter 16
- Red or green?
- Red: Set value = 67045889
- Green: Set value = 67045961
- If switch…
- Set parameter 8
- Red or green?
- Red: Set value = 50268673
- Green: Set value = 50268749
- If dimmer…
- Set node_id
- Call ozw.set_config_parameter service
To make that work in Node-RED, we’re going to use a combination of Switch and Change nodes. Along this flow, for each node ID we’re tying to build a message object that looks like this:
"payload": {
"data": {
"node_id": 6,
"parameter": 16,
"value": 6745889
}
}
When this message reaches the Call Service node at the end, the data object will be used as the service parameters (just like we did in Developer Tools).
What this piece looks like in its entirety:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-13.png?resize=616%2C103&ssl=1)
The leftmost node (which I have labeled as “Node IDs” is setting msg.payload
equal to the flow variable flow.xmas
, so we have a copy of our list of nodes in the msg object for processing by each node. Then, since that’s an array, we split it, so that the above sequence runs for each item in our xmas list. Therefore, the input to “Dimmer or switch” is an object where msg.payload
looks like this:
{
"node_id": 21,
"type": "dimmer",
"color": "green"
}
From there it’s just a series of conditionals (Switch nodes) and setting values (Change nodes).
For instance, we first check to see if it’s a dimmer or switch:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-15.png?resize=616%2C294&ssl=1)
Then, if it’s a dimmer, the first Change node sets the parameter to 16:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-14.png?resize=616%2C200&ssl=1)
We follow a similar pattern for setting the parameters for each color. Then the last step is to set the node ID, and finally call the ozw.set_config_parameter
service:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-16.png?resize=616%2C392&ssl=1)
Now we hook together our Alexa piece from Step 1 with this part we built in Step 3, and we’re done!
The finished product
The whole thing looks like this:
![](https://i0.wp.com/smartyhome.io/wp-content/uploads/2020/11/image-18.png?resize=616%2C90&ssl=1)
A few things to mention:
- Note the “Fire at startup” Inject node in the bottom left…the Change node it’s connected to is where the flow.xmas object (containing our switch/dimmer node list) gets set when Node-RED starts running.
- Along the bottom (after the 5 minute timer) I have a part of the flow that sets parameters to shut the blinking lights off. This follows a very similar pattern to turning them on, just setting different values. See the Inovelli calculator for the values to use to turn the notifications off.
- I have Inject nodes setup to Manually activate lights and Stop lights. This is useful for debugging and testing without having to be constantly asking Alexa to start and stop Christmas music.
And that’s it! After an hour or two of fiddling, you too can surprise your spouse with obnoxious green and red blinking LEDs whenever they ask Alexa to play Christmas music.
All kidding aside, there’s plenty of good stuff in here about how to build Node-RED flows and interact with Z-Wave device configurations, and I learned a lot building it. I’m still pretty new to Node-RED so I’m sure there’s much better ways to do this, but this worked for me.
Have you done any pointless/fun holiday automations? Share them!
Leave a Reply