# How can I perform the on-off operation with a single button?

**URL:** https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004
**Category:** Dashboard
**Created:** [8 October 2021 06:32 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004 "2021-10-08T06:32:01Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![byramozgn](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@byramozgn](https://discourse.nodered.org/u/byramozgn)
#### Post date: [8 October 2021 06:32 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/1 "2021-10-08T06:32:01Z")

</div>

Can I change the same boolean address to true-false with a single button?

---

<div class="post-metadata">

### Author: ![Bobo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bobo/32/8401_2.png) [@Bobo](https://discourse.nodered.org/u/Bobo)
#### Post date: [8 October 2021 06:38 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/2 "2021-10-08T06:38:47Z")

</div>

Have you tried?

---

<div class="post-metadata">

### Author: ![byramozgn](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@byramozgn](https://discourse.nodered.org/u/byramozgn)
#### Post date: [8 October 2021 06:41 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/3 "2021-10-08T06:41:45Z")

</div>

Yes, I tried, but since I am new, I could not reach a result. Are there ready-made button patterns for this?  
I'm looking for a switch that will have the same operation as the switch in the node-red dashboard plugin, but with the appearance of a button.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [8 October 2021 07:56 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/4 "2021-10-08T07:56:47Z")

</div>

Search for Toggle Button in the forum.

---

<div class="post-metadata">

### Author: ![byramozgn](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@byramozgn](https://discourse.nodered.org/u/byramozgn)
#### Post date: [8 October 2021 07:57 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/5 "2021-10-08T07:57:32Z")

</div>

thank you .

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [8 October 2021 12:58 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/6 "2021-10-08T12:58:49Z")

</div>

Here's a simple flow with three examples of how to use a button to perform various actions.  
e.g. On/Off, Toggle or Count.  
Hope you find it useful.

```auto
[{"id":"60c6e074.6a27d","type":"inject","z":"c275af93.a0ced8","name":"Button_1 ON","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":150,"y":220,"wires":[["e470de66.2cd938"]]},{"id":"e470de66.2cd938","type":"function","z":"c275af93.a0ced8","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":370,"y":260,"wires":[["8eacc2e1.35574"]]},{"id":"5a1a61ad.3bf93","type":"inject","z":"c275af93.a0ced8","name":"Button_1 OFF","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":150,"y":300,"wires":[["e470de66.2cd938"]]},{"id":"6543e473.28ef04","type":"inject","z":"c275af93.a0ced8","name":"Reset at start-up","repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":170,"y":100,"wires":[["a9b8db.58384f28"]]},{"id":"a9b8db.58384f28","type":"function","z":"c275af93.a0ced8","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":440,"y":100,"wires":[["7ec3acf5.180e74"]]},{"id":"8eacc2e1.35574","type":"debug","z":"c275af93.a0ced8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":260,"wires":[]},{"id":"de533a20.15dad8","type":"inject","z":"c275af93.a0ced8","name":"Toggle Button_2","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"change","payloadType":"str","x":160,"y":420,"wires":[["fc06e83a.20e808"]]},{"id":"fc06e83a.20e808","type":"function","z":"c275af93.a0ced8","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,"noerr":0,"x":370,"y":420,"wires":[["a9e67527.c81b08"]]},{"id":"a9e67527.c81b08","type":"debug","z":"c275af93.a0ced8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":420,"wires":[]},{"id":"7ec3acf5.180e74","type":"link out","z":"c275af93.a0ced8","name":"initial_reset","links":["f770bcb7.c96638","cf329dda.1ed2b8","ead38ede.857b","7464e7ef.fdb638"],"x":635,"y":100,"wires":[]},{"id":"f770bcb7.c96638","type":"link in","z":"c275af93.a0ced8","name":"","links":["7ec3acf5.180e74"],"x":195,"y":260,"wires":[["e470de66.2cd938"]]},{"id":"cf329dda.1ed2b8","type":"link in","z":"c275af93.a0ced8","name":"","links":["7ec3acf5.180e74"],"x":195,"y":460,"wires":[["fc06e83a.20e808"]]},{"id":"597b6280.3be11c","type":"inject","z":"c275af93.a0ced8","name":"Count on Button_3","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"increment","payloadType":"str","x":170,"y":560,"wires":[["374defc.d4d1f9"]]},{"id":"374defc.d4d1f9","type":"function","z":"c275af93.a0ced8","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":370,"y":600,"wires":[["6b985784.d49828"]]},{"id":"6b985784.d49828","type":"debug","z":"c275af93.a0ced8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":560,"wires":[]},{"id":"ead38ede.857b","type":"link in","z":"c275af93.a0ced8","name":"","links":["7ec3acf5.180e74"],"x":195,"y":600,"wires":[["374defc.d4d1f9"]]},{"id":"cbc967e4.f27be8","type":"inject","z":"c275af93.a0ced8","name":"Reset the counter","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":170,"y":640,"wires":[["374defc.d4d1f9"]]},{"id":"acffc15e.44d5a8","type":"function","z":"c275af93.a0ced8","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,"initialize":"","finalize":"","libs":[],"x":1050,"y":280,"wires":[["1864c779.31fa79"]]},{"id":"7464e7ef.fdb638","type":"link in","z":"c275af93.a0ced8","name":"","links":["7ec3acf5.180e74"],"x":915,"y":280,"wires":[["acffc15e.44d5a8"]]},{"id":"c0b2baa6.ba63d","type":"ui_button","z":"c275af93.a0ced8","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":890,"y":240,"wires":[["acffc15e.44d5a8"]]},{"id":"393ac977.aee796","type":"ui_button","z":"c275af93.a0ced8","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":890,"y":320,"wires":[["acffc15e.44d5a8"]]},{"id":"1864c779.31fa79","type":"ui_text","z":"c275af93.a0ced8","group":"4bfa11d8.376b98","order":3,"width":"6","height":"1","name":"Button status","label":"Status: ","format":"{{msg.payload}}","layout":"row-center","x":1240,"y":280,"wires":[]},{"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}]

```

---

<div class="post-metadata">

### Author: ![byramozgn](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@byramozgn](https://discourse.nodered.org/u/byramozgn)
#### Post date: [8 October 2021 13:24 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/7 "2021-10-08T13:24:04Z")

</div>

I don't know how to use this code as I am new to node-red 🙂

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [8 October 2021 13:43 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/8 "2021-10-08T13:43:39Z")

</div>

What Dave has posted is an export/demo flow that you can import and test out (CTRL+I)

Also, as a new user, I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<div class="post-metadata">

### Author: ![byramozgn](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@byramozgn](https://discourse.nodered.org/u/byramozgn)
#### Post date: [8 October 2021 13:45 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/9 "2021-10-08T13:45:56Z")

</div>

Thank you

---

<div class="post-metadata">

### Author: ![byramozgn](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@byramozgn](https://discourse.nodered.org/u/byramozgn)
#### Post date: [8 October 2021 13:58 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/10 "2021-10-08T13:58:24Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c154c9f6d3c76652a94ad13964653e024da7a35f.png)  
With these codes, I provide what I am looking for, but the button does not appear on the dashboard, how can I display this button on the dashboard?

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [8 October 2021 14:05 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/11 "2021-10-08T14:05:08Z")

</div>

There is an example of using a ui-button on the Dashboard in the flow I posted.

---

<div class="post-metadata">

### Author: ![byramozgn](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@byramozgn](https://discourse.nodered.org/u/byramozgn)
#### Post date: [8 October 2021 14:10 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/12 "2021-10-08T14:10:48Z")

</div>

In the example you gave, there is this ui example, but there is an on-off operation with two buttons.  
What I want to do is the on-off operation with a single button.

Also, thank you very much for your answers.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [8 October 2021 14:42 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/13 "2021-10-08T14:42:42Z")

</div>

Search the forum for Toggle Button, there are many examples of how to do that.

---

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [8 October 2021 15:02 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/14 "2021-10-08T15:02:45Z")

</div>

Try this flow - toggle button action on the Dashboard.

```auto
[{"id":"c275af93.a0ced8","type":"tab","label":"Button examples","disabled":false,"info":""},{"id":"60c6e074.6a27d","type":"inject","z":"c275af93.a0ced8","name":"Button_1 ON","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":150,"y":220,"wires":[["e470de66.2cd938"]]},{"id":"e470de66.2cd938","type":"function","z":"c275af93.a0ced8","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":370,"y":260,"wires":[["8eacc2e1.35574"]]},{"id":"5a1a61ad.3bf93","type":"inject","z":"c275af93.a0ced8","name":"Button_1 OFF","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":150,"y":300,"wires":[["e470de66.2cd938"]]},{"id":"6543e473.28ef04","type":"inject","z":"c275af93.a0ced8","name":"Reset at start-up","repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":170,"y":100,"wires":[["a9b8db.58384f28"]]},{"id":"a9b8db.58384f28","type":"function","z":"c275af93.a0ced8","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":440,"y":100,"wires":[["7ec3acf5.180e74"]]},{"id":"8eacc2e1.35574","type":"debug","z":"c275af93.a0ced8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":260,"wires":[]},{"id":"de533a20.15dad8","type":"inject","z":"c275af93.a0ced8","name":"Toggle Button_2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"change","payloadType":"str","x":880,"y":500,"wires":[["fc06e83a.20e808"]]},{"id":"fc06e83a.20e808","type":"function","z":"c275af93.a0ced8","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,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1090,"y":500,"wires":[["a9e67527.c81b08","89939c22.bff49"]]},{"id":"a9e67527.c81b08","type":"debug","z":"c275af93.a0ced8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1270,"y":500,"wires":[]},{"id":"7ec3acf5.180e74","type":"link out","z":"c275af93.a0ced8","name":"initial_reset","links":["f770bcb7.c96638","cf329dda.1ed2b8","ead38ede.857b","7464e7ef.fdb638"],"x":635,"y":100,"wires":[]},{"id":"f770bcb7.c96638","type":"link in","z":"c275af93.a0ced8","name":"","links":["7ec3acf5.180e74"],"x":195,"y":260,"wires":[["e470de66.2cd938"]]},{"id":"cf329dda.1ed2b8","type":"link in","z":"c275af93.a0ced8","name":"","links":["7ec3acf5.180e74"],"x":915,"y":540,"wires":[["fc06e83a.20e808"]]},{"id":"597b6280.3be11c","type":"inject","z":"c275af93.a0ced8","name":"Count on Button_3","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"increment","payloadType":"str","x":170,"y":560,"wires":[["374defc.d4d1f9"]]},{"id":"374defc.d4d1f9","type":"function","z":"c275af93.a0ced8","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":370,"y":600,"wires":[["6b985784.d49828"]]},{"id":"6b985784.d49828","type":"debug","z":"c275af93.a0ced8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":560,"wires":[]},{"id":"ead38ede.857b","type":"link in","z":"c275af93.a0ced8","name":"","links":["7ec3acf5.180e74"],"x":195,"y":600,"wires":[["374defc.d4d1f9"]]},{"id":"cbc967e4.f27be8","type":"inject","z":"c275af93.a0ced8","name":"Reset the counter","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":170,"y":640,"wires":[["374defc.d4d1f9"]]},{"id":"acffc15e.44d5a8","type":"function","z":"c275af93.a0ced8","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,"initialize":"","finalize":"","libs":[],"x":1050,"y":280,"wires":[["1864c779.31fa79"]]},{"id":"7464e7ef.fdb638","type":"link in","z":"c275af93.a0ced8","name":"","links":["7ec3acf5.180e74"],"x":915,"y":280,"wires":[["acffc15e.44d5a8"]]},{"id":"c0b2baa6.ba63d","type":"ui_button","z":"c275af93.a0ced8","name":"On","group":"4bfa11d8.376b98","order":1,"width":"3","height":"1","passthru":false,"label":"On","tooltip":"","color":"","bgcolor":"","icon":"","payload":"on","payloadType":"str","topic":"","topicType":"str","x":890,"y":240,"wires":[["acffc15e.44d5a8"]]},{"id":"393ac977.aee796","type":"ui_button","z":"c275af93.a0ced8","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":890,"y":320,"wires":[["acffc15e.44d5a8"]]},{"id":"1864c779.31fa79","type":"ui_text","z":"c275af93.a0ced8","group":"4bfa11d8.376b98","order":3,"width":"6","height":"1","name":"Button status","label":"Status: ","format":"{{msg.payload}}","layout":"row-center","x":1240,"y":280,"wires":[]},{"id":"2e0818c.09bcee8","type":"ui_button","z":"c275af93.a0ced8","name":"On","group":"5f235325.3c90a4","order":1,"width":"3","height":"1","passthru":false,"label":"Toggle Me","tooltip":"","color":"","bgcolor":"","icon":"","payload":"change","payloadType":"str","topic":"","topicType":"str","x":890,"y":440,"wires":[["fc06e83a.20e808"]]},{"id":"89939c22.bff49","type":"ui_text","z":"c275af93.a0ced8","group":"5f235325.3c90a4","order":3,"width":"6","height":"1","name":"Button status","label":"Status: ","format":"{{msg.payload}}","layout":"row-center","x":1270,"y":440,"wires":[]},{"id":"d7f53c88.ef6b2","type":"comment","z":"c275af93.a0ced8","name":"Toggle button action on Dashboard","info":"","x":1080,"y":400,"wires":[]},{"id":"4bfa11d8.376b98","type":"ui_group","name":"on-off-demo","tab":"1f158e7d.631e42","order":1,"disp":true,"width":"6","collapse":false},{"id":"5f235325.3c90a4","type":"ui_group","name":"Toggle demo","tab":"1f158e7d.631e42","order":2,"disp":true,"width":"6","collapse":false},{"id":"1f158e7d.631e42","type":"ui_tab","name":"Button demo","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![byramozgn](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@byramozgn](https://discourse.nodered.org/u/byramozgn)
#### Post date: [12 October 2021 10:53 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/15 "2021-10-12T10:53:05Z")

</div>

Thank you so much. This is what I was looking for. 👍

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [26 October 2021 10:53 UTC](https://discourse.nodered.org/t/how-can-i-perform-the-on-off-operation-with-a-single-button/52004/16 "2021-10-26T10:53:33Z")

</div>

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