After install the node Toggel. I dont find

Here's a screenshot of the flow from my very old tutorial.


And here's the code you can import and adapt.

[{"id":"1774ba78f53ce4da","type":"tab","label":"Button_examples","disabled":false,"info":"","env":[]},{"id":"4825e2cb12334bc4","type":"inject","z":"1774ba78f53ce4da","name":"Button_1 ON","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":130,"y":260,"wires":[["c2e6b3e851c7a717"]]},{"id":"c2e6b3e851c7a717","type":"function","z":"1774ba78f53ce4da","name":"A","func":"if ( (msg.payload == \"off\") || (msg.payload == \"reset\") ) {\n    flow.set(\"button_1\",\"off\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"Button_1 is OFF\"});\n    \n    msg.payload = 0; // Set this to what you want to pass on\n    return msg;\n}\nelse if (msg.payload == \"on\") {\n    flow.set(\"button_1\",\"on\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"Button_1 is ON\"});\n    \n    msg.payload = 1; // Set this to what you want to pass on\n    return msg;\n}\n","outputs":1,"noerr":0,"x":350,"y":300,"wires":[["447c476969db8d5c"]]},{"id":"2b98df168a10cad8","type":"inject","z":"1774ba78f53ce4da","name":"Button_1 OFF","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":130,"y":340,"wires":[["c2e6b3e851c7a717"]]},{"id":"a0c4f780c33a80f7","type":"inject","z":"1774ba78f53ce4da","name":"Reset at start-up","repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":150,"y":140,"wires":[["939d409b26c12b3e"]]},{"id":"939d409b26c12b3e","type":"function","z":"1774ba78f53ce4da","name":"Set all buttons to OFF state","func":"flow.set(\"button_1\",\"off\");\nflow.set(\"button_2\",\"off\");\n\nflow.set(\"counter\",0);\n\nmsg.payload = \"reset\";\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":140,"wires":[["be8d2b42fbbb6108"]]},{"id":"447c476969db8d5c","type":"debug","z":"1774ba78f53ce4da","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":300,"wires":[]},{"id":"9f8003dc511ff6d5","type":"inject","z":"1774ba78f53ce4da","name":"Toggle Button_2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"change","payloadType":"str","x":140,"y":460,"wires":[["04d6ffdcd9087a2a"]]},{"id":"04d6ffdcd9087a2a","type":"function","z":"1774ba78f53ce4da","name":"B","func":"if (msg.payload == \"change\") {\n    var state = flow.get(\"button_2\") || \"off\";\n    if (state == \"off\") {\n        state = \"on\";\n        node.status({fill:\"green\",shape:\"dot\",text:\"Button_2 is ON\"});\n        msg.payload = 1; // Set this to what you want to pass on\n    }\n    else if (state == \"on\") {\n        state = \"off\";\n        node.status({fill:\"red\",shape:\"dot\",text:\"Button_2 is OFF\"});\n        msg.payload = 0; // Set this to what you want to pass on\n    }\n    flow.set(\"button_2\",state);\n    return msg;\n}\n\nelse if (msg.payload == \"reset\") {\n    flow.set(\"button_2\",\"off\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"Button_2 is OFF\"});\n    msg.payload = 0; // Set this to what you want to pass on\n    return msg;\n}\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":460,"wires":[["535a5daa5fc83194"]]},{"id":"535a5daa5fc83194","type":"debug","z":"1774ba78f53ce4da","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":460,"wires":[]},{"id":"be8d2b42fbbb6108","type":"link out","z":"1774ba78f53ce4da","name":"initial_reset","links":["be5faf56e2a51ab3","fa363fb466604d9b","704d1a01235a86a4","1efa68ecc6533533"],"x":615,"y":140,"wires":[]},{"id":"be5faf56e2a51ab3","type":"link in","z":"1774ba78f53ce4da","name":"","links":["be8d2b42fbbb6108"],"x":175,"y":300,"wires":[["c2e6b3e851c7a717"]]},{"id":"fa363fb466604d9b","type":"link in","z":"1774ba78f53ce4da","name":"","links":["be8d2b42fbbb6108"],"x":175,"y":500,"wires":[["04d6ffdcd9087a2a"]]},{"id":"26284ccd7a95b13e","type":"inject","z":"1774ba78f53ce4da","name":"Count on Button_3","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"increment","payloadType":"str","x":150,"y":600,"wires":[["9c9c576e8024bb83"]]},{"id":"9c9c576e8024bb83","type":"function","z":"1774ba78f53ce4da","name":"C","func":"if (msg.payload == \"increment\") {\n    var counter = flow.get(\"counter\") || 0;\n    counter = counter + 1;\n    node.status({text:\"Counter = \"+counter});\n    flow.set(\"counter\",counter);\n    msg.payload = counter;\n    return msg;\n}\n\nelse if (msg.payload == \"reset\") {\n    flow.set(\"counter\",0);\n    node.status({text:\"Counter = 0\"});\n    msg.payload = 0;\n    return msg;\n}\n","outputs":1,"noerr":0,"x":350,"y":640,"wires":[["5b9a826c09caca52"]]},{"id":"5b9a826c09caca52","type":"debug","z":"1774ba78f53ce4da","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":600,"wires":[]},{"id":"704d1a01235a86a4","type":"link in","z":"1774ba78f53ce4da","name":"","links":["be8d2b42fbbb6108"],"x":175,"y":640,"wires":[["9c9c576e8024bb83"]]},{"id":"08e0b002d4f126f4","type":"inject","z":"1774ba78f53ce4da","name":"Reset the counter","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":150,"y":680,"wires":[["9c9c576e8024bb83"]]},{"id":"4e4ee4b89a45f5b2","type":"ui_button","z":"1774ba78f53ce4da","name":"On","group":"4bfa11d8.376b98","order":1,"width":"3","height":"1","passthru":false,"label":"On","tooltip":"","color":"","bgcolor":"","icon":"","payload":"on","payloadType":"str","topic":"","x":870,"y":280,"wires":[["21dcf5bd9ce91ab1"]]},{"id":"ff4300fcc0e323a7","type":"ui_button","z":"1774ba78f53ce4da","name":"","group":"4bfa11d8.376b98","order":2,"width":"3","height":"1","passthru":false,"label":"Off","tooltip":"","color":"","bgcolor":"","icon":"","payload":"off","payloadType":"str","topic":"Off","x":870,"y":360,"wires":[["21dcf5bd9ce91ab1"]]},{"id":"20aa8df75ef15247","type":"ui_text","z":"1774ba78f53ce4da","group":"4bfa11d8.376b98","order":3,"width":"6","height":"1","name":"Button status","label":"Status: ","format":"{{msg.payload}}","layout":"row-center","x":1220,"y":320,"wires":[]},{"id":"21dcf5bd9ce91ab1","type":"function","z":"1774ba78f53ce4da","name":"E","func":"if ( (msg.payload == \"off\") || (msg.payload == \"reset\") ) {\n    flow.set(\"button_3\",\"off\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"Button_3 is OFF\"});\n    \n    msg.payload = \"Button_3 is OFF\"; // Set this to what you want to pass on\n    return msg;\n}\nelse if (msg.payload == \"on\") {\n    flow.set(\"button_3\",\"on\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"Button_3 is ON\"});\n    \n    msg.payload = \"Button_3 is ON\"; // Set this to what you want to pass on\n    return msg;\n}\n","outputs":1,"noerr":0,"x":1030,"y":320,"wires":[["20aa8df75ef15247"]]},{"id":"1efa68ecc6533533","type":"link in","z":"1774ba78f53ce4da","name":"","links":["be8d2b42fbbb6108"],"x":895,"y":320,"wires":[["21dcf5bd9ce91ab1"]]},{"id":"4bfa11d8.376b98","type":"ui_group","name":"on-off-demo","tab":"1f158e7d.631e42","order":1,"disp":true,"width":"6","collapse":false},{"id":"1f158e7d.631e42","type":"ui_tab","name":"Button demo","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.