node-red-contrib-wled
node-red-contrib-wled copied to clipboard
Toggle command
Hey there, thank you for your plugin! Is it possible to send a toggle command to turn it on when off and off when on? Thank you! :)
I think your best bet is to read ipadress/json and change the value of "on"
to the opposite of whatever it is when you poll it. It simply moves the "toggle" part into your flow.
"state":{"on":true,"bri":128,"transition":7,"ps":1,"pss":4351,"pl":-1...
I use this node to turn an string of WLED LEDs on when the rest of my outdoor lighting comes on and off when it all goes off. I use a flow variable set by a Big Timer node to do the work. I use another timer to cycle randomly through 8 presets for random lengths of time (30-90s). In my code "n" is the preset number passed from another node:
var n = msg.payload.toString();
var on_off = flow.get('WLED_ON');
if( on_off ){
msg.payload = '{"on": true, "ps":' + n + ',"pl":-1,"ccnf":{"min":1,"max":8,"time":900}}'
return msg;
} else {
msg.payload = '{"on": false}'
return msg;
}
return msg;
On a side note, this node works fantastically well. Thanks.