Hello to All,
I used the Dashoboard slider to activate different elements, in my case raspberry pi 4 GPIO connected to diodes. The idea is that the slider has 4 steps 0, 1, 2 and.
When the slider is on 0 no diode shines.
When the slider is on 1, 1 diode shines.
When the slider is on 2, 2 diodes shine.
When the slider is on 3, all 3 diodes shine.
Just for information I also use links as the raspberry pi logic is in another flow. For interacting with raspberry pi I use the module " node-red-node-pi-gpio" (you need to have Node-RED on the raspberry pi, to control its GPIO pins)
https://nodered.org/docs/faq/interacting-with-pi-gpio
The function "Func1" to make the fist diode to shine, when the slider is 1, 2 or 3 position is:
if (msg.payload == 1 || msg.payload == 2 || msg.payload == 3)
{
msg.payload = 1;
} else {
msg.payload = 0;
}
return msg;
[{"id":"58826869.170d3","type":"ui_slider","z":"794cd749.ae3b9","name":"","label":"slider","tooltip":"","group":"dd11ee4.37f1b1","order":1,"width":0,"height":0,"passthru":false,"outs":"end","topic":"","topicType":"str","min":"0","max":"3","step":1,"x":330,"y":220,"wires":[["e3cc053c.5a3a38","9315d9b8.578a88","5bd7ebe0.9520fc"]]},{"id":"79d30609.fb0ed8","type":"link out","z":"794cd749.ae3b9","name":"1","links":["c6843345.dbac1"],"x":1095,"y":140,"wires":[]},{"id":"eba0eeb4.6eb45","type":"link out","z":"794cd749.ae3b9","name":"2","links":["6ba11d90.a3f234"],"x":1095,"y":240,"wires":[]},{"id":"775d7f38.06d928","type":"link out","z":"794cd749.ae3b9","name":"3","links":["ab6516ea.646c18"],"x":1095,"y":320,"wires":[]},{"id":"e3cc053c.5a3a38","type":"function","z":"794cd749.ae3b9","name":"Func1","func":"if (msg.payload == 1 || msg.payload == 2 || msg.payload == 3)\n{\n msg.payload = 1;\n} else {\n \n msg.payload = 0;\n \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":140,"wires":[["79d30609.fb0ed8"]]},{"id":"9315d9b8.578a88","type":"function","z":"794cd749.ae3b9","name":"Func2","func":"if (msg.payload == 2 || msg.payload == 3)\n{\n msg.payload = 1;\n} else {\n \n msg.payload = 0;\n \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":240,"wires":[["eba0eeb4.6eb45"]]},{"id":"5bd7ebe0.9520fc","type":"function","z":"794cd749.ae3b9","name":"Func3","func":"if (msg.payload == 3)\n{\n msg.payload = 1;\n} else {\n \n msg.payload = 0;\n \n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":320,"wires":[["775d7f38.06d928"]]},{"id":"dd11ee4.37f1b1","type":"ui_group","name":"Default","tab":"e66b254.14380d8","order":1,"disp":true,"width":"6","collapse":false},{"id":"e66b254.14380d8","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]