We replaced a bunch of dummy switches with Inovelli LZW30. They have large LED with selectable color and intensity, and naturally we couldn’t agree on what looked best. So how do you go about mass updates of the respective parameters? Thankfully, the awesome Z-Wave JS developers dropped in a new service in the latest release! Here’s my flow to do this with as little effort as I could think of in my favorite engine, node-red:
The flow is made up of several nodes:
- It reads the HA device registry at /config/.storage/core.device_registry so that you can just point to a manufacturer/model rather then hardcoding the device_id you want to address.
- The output from the first node is then converted to JSON for further processing.
- The heart of the logic resides in a function node (see below). There is a wonderful compilation of device configurations at https://devices.zwave-js.io/
- A rate limiter is added to give the slowish Z-Wave a chance for success
- And finally, zwave_js.set_config_parameter is called for each device and parameter
The JavaScript code snippet only shows a single parameter, but you can add them all to the array. Until the service can update more than one parameter at a time, this array is needed to make individual service calls.
let devices = msg.payload.data.devices;
let manufacturer = 'Inovelli';
let model = 'LZW30';
let cfg = [
{
"description": "LED Indicator Color",
"parameter": 5,
"value": 21
},
]
for(let i = 0; i < devices.length; i++) {
let device = devices[i];
if(device.manufacturer == manufacturer
&& device.model == model){
for (let j in cfg){
msg.payload = {
'data': {
'device_id': device.id,
'parameter': cfg[j]['parameter'],
'value': cfg[j]['value']
}
}
node.send(msg);
}
}
}
I would have you know that, in the end, we agreed on setting the LEDs to orange at 10% intensity.