I have recently been playing with dashboards and while playing with buttons, I needed a “fail safe” to prevent me pressing a button by mistake.
So I put an “Activate” button to allow the other button to be pressed.
I haven’t worked out how to do colours, and other fancy stuff, but at the end of the day it works.
How to use:
The ACTIVATE button enables the RESET ALL button.
That is done by the timeout node which I have set to 2 seconds.
I put a switch in the equation as well to indicate the time allowed.
Then, when you press the RESET ALL button, the message is passed through.
That is taken from the output of the EN node and then processed as you need.
I know it isn’t that great, but someone may find it helpful/handy, and I feel I should give back after all the questions I ask.
Code below:
[{"id":"e300107f.8667e8","type":"ui_button","z":"fb549e2f.4d026","name":"","group":"5a16edf3.798c04","order":3,"width":0,"height":0,"passthru":true,"label":"Reset All!","color":"","bgcolor":"","icon":"","payload":"RESET","payloadType":"str","topic":"","x":680,"y":170,"wires":[["1f5cca83.8f19c5"]]},{"id":"1f5cca83.8f19c5","type":"function","z":"fb549e2f.4d026","name":"EN","func":"if (msg.topic === \"ENABLE\")\n{\n //\n if (msg.payload === 'true')\n {\n node.status({fill:\"yellow\",shape:\"dot\",text:\"ENABLED\"});\n context.set('enable',1);\n }\n //if (msg.payload === 'false')\n else\n {\n context.set('enable',0);\n// context.enable = 0;\n// context.set('enable',enable_topic);\n node.status({fill:\"red\",shape:\"dot\",text:\"DISABLED\"});\n }\n}\nif (msg.topic != \"ENABLE\")\n{\n if (context.get('enable') == 1)\n {\n //\n node.status({fill:\"green\",shape:\"dot\",text:\"On-line\"});\n return msg;\n }\n}\n","outputs":1,"noerr":0,"x":810,"y":170,"wires":[["2205799b.d99d3e","5bb56ab7.6882ac"]]},{"id":"99fc784c.cb71b8","type":"function","z":"fb549e2f.4d026","name":"Set Topic","func":"msg.topic=\"ENABLE\";\nreturn msg;","outputs":1,"noerr":0,"x":820,"y":90,"wires":[["9f1b1a02.1ab5"]]},{"id":"14983a82.e709bd","type":"ui_button","z":"fb549e2f.4d026","name":"","group":"5a16edf3.798c04","order":1,"width":0,"height":0,"passthru":true,"label":"Enable","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"str","topic":"","x":680,"y":90,"wires":[["99fc784c.cb71b8"]]},{"id":"9f1b1a02.1ab5","type":"timeouttrigger","z":"fb549e2f.4d026","ontimeouttype":"bool","ontimeoutval":"false","duration":"2","units":"s","name":"","x":690,"y":130,"wires":[["1f5cca83.8f19c5","f81b8be4.ad3f7"]]},{"id":"f81b8be4.ad3f7","type":"ui_switch","z":"fb549e2f.4d026","name":"","label":"switch","group":"5a16edf3.798c04","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":820,"y":130,"wires":[["4d56bc1b.f1220c"]]},{"id":"5a16edf3.798c04","type":"ui_group","z":"","name":"Input","tab":"cababfc5.7b2f6","order":4,"disp":true,"width":"4","collapse":false},{"id":"cababfc5.7b2f6","type":"ui_tab","z":"","name":"Control Display","icon":"dashboard","order":6}]