A newer idea for having *dangerous* buttons in a flow

If you have dangerous buttons in a flow, it is sometimes nice to have a safety switch to stop them being accidentally pressed.

I have posted flows in the library in the past which do this but in a more complicated way.

This is really easy, simple and not anywhere as difficult to apply as the previous efforts.

It also has the advantage that it is virtually limitless to how many buttons it can do.
It doesn't get more difficult as you get more buttons.

Hope you enjoy it and find it useful.

Instructions are included in the flow - the Read me please node.

[{"id":"bdefd8a7.9ef1c","type":"function","z":"f64521da.ed6a","name":"Button enable","func":"if (msg.payload === 1)\n{\n    context.set('enabled',1);\n    msg1 = {enabled:true,background:\"lime\"};\n} else\nif (msg.payload === 0)\n{\n    context.set('enabled',0);\n    msg1 = {enabled:false,background:\"brown\"};\n}\nreturn msg1;\n","outputs":1,"noerr":0,"x":290,"y":2480,"wires":[["44e441b1.889338","1a0a59ca.e6d186","43a17780.e88aa8","44f51402.b2a11c","c4b72c2d.1d2f28"]],"outputLabels":["Control output"],"info":"Output functions:\n#1 - Auto/Manual.   Controls gate to allow\n    automatic control of fan.\n    Improvement:\n    3 states for output.\n    1 - AUTO\n    2 - MANUAL OFF\n    3 - MANUAL ON\n\n#2 - FAN ON button state\n#3 - FAN OFF button state\n#4 - MANUAL state\n#5 - AUTO button state"},{"id":"dc5e2b75.cfc368","type":"ui_button","z":"f64521da.ed6a","name":"Enable","group":"121d9647.28a96a","order":1,"width":"3","height":"1","passthru":false,"label":"Enable","tooltip":"","color":"","bgcolor":"coral","icon":"","payload":"true","payloadType":"bool","topic":"ENABLE","x":270,"y":2400,"wires":[["d26862d1.b0b168"]]},{"id":"d26862d1.b0b168","type":"trigger","z":"f64521da.ed6a","op1":"1","op2":"0","op1type":"num","op2type":"num","duration":"2","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":270,"y":2440,"wires":[["bdefd8a7.9ef1c"]]},{"id":"44e441b1.889338","type":"ui_button","z":"f64521da.ed6a","name":"Button 1","group":"121d9647.28a96a","order":1,"width":"3","height":"1","passthru":false,"label":"Button 1","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"Button 1","payloadType":"str","topic":"","x":270,"y":2520,"wires":[["265e201.506fe6"]]},{"id":"1a0a59ca.e6d186","type":"ui_button","z":"f64521da.ed6a","name":"Button 2","group":"121d9647.28a96a","order":1,"width":"3","height":"1","passthru":false,"label":"Button 2","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"Button 2","payloadType":"str","topic":"","x":270,"y":2560,"wires":[["265e201.506fe6"]]},{"id":"43a17780.e88aa8","type":"ui_button","z":"f64521da.ed6a","name":"Button 3","group":"121d9647.28a96a","order":1,"width":"3","height":"1","passthru":false,"label":"Button 3","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"Button 3","payloadType":"str","topic":"","x":270,"y":2600,"wires":[["265e201.506fe6"]]},{"id":"44f51402.b2a11c","type":"ui_button","z":"f64521da.ed6a","name":"Button 4","group":"121d9647.28a96a","order":1,"width":"3","height":"1","passthru":false,"label":"Button 4","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"Button 4","payloadType":"str","topic":"","x":270,"y":2640,"wires":[["265e201.506fe6"]]},{"id":"c4b72c2d.1d2f28","type":"ui_button","z":"f64521da.ed6a","name":"Button 5","group":"121d9647.28a96a","order":1,"width":"3","height":"1","passthru":false,"label":"Button 5","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"Button 5","payloadType":"str","topic":"","x":270,"y":2680,"wires":[["265e201.506fe6"]]},{"id":"265e201.506fe6","type":"debug","z":"f64521da.ed6a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":2600,"wires":[]},{"id":"7064bc67.8a4184","type":"inject","z":"f64521da.ed6a","name":"Setup","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":260,"y":2360,"wires":[["bdefd8a7.9ef1c"]]},{"id":"8c639ef9.2f54e8","type":"comment","z":"f64521da.ed6a","name":"Read me please","info":"Overview:\nThis is a _trick_ I have since developed to allow\nyou to put _dangerous_ buttons in a flow which you\ndon't want to be pressed too easily.\nThis blocks any button presses until the `Enable`\nbutton is pressed and then only allows them to\nbe pressed for a certain time.   (Set by you)\n\nYou can have as many buttons as you desire.\nJust set them to accept {{msg.background}} as\ntheir background colour, and be sure to **NOT**\nhave the _pass input message_ button ticked -\nthough this is default OFF.\n\n---\n\nIn the `Button enable` node (`function`)\nyou set the colours for when the buttons are\nenabled and disabled.\nThe actual buttons can send what ever you want.\nI have them sending their names only for clarity\nand simplisity at this stage.\n\nThe `Setup` at the top injects a signal to disable\nthe buttons at start up.\nPress the `Enable` button to allow the buttons to\nbe pressed.\nThe time can be edited/changed by adjusting the\n`trigger` node from 2 seconds to how ever long you\nthink is a good ammount of time.","x":600,"y":2370,"wires":[]},{"id":"121d9647.28a96a","type":"ui_group","name":"Group 5","tab":"b5ae1056.1d289","order":5,"disp":true,"width":6},{"id":"b5ae1056.1d289","type":"ui_tab","z":"","name":"Master Control prototype","icon":"dashboard","order":26,"disabled":false,"hidden":false}]
2 Likes