# Enable a switch

**URL:** <https://discourse.nodered.org/t/enable-a-switch/63062>\
**Category:** Dashboard\
**Tags:** node-red-dashboard\
**Created:** [25 May 2022 16:13 UTC](https://discourse.nodered.org/t/enable-a-switch/63062 "2022-05-25T16:13:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nilpferd](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nilpferd](https://discourse.nodered.org/u/Nilpferd)\
**Post date:** [25 May 2022 16:13 UTC](https://discourse.nodered.org/t/enable-a-switch/63062/1 "2022-05-25T16:13:28Z")

</div>

I would like to start the power supply of a NAS with a switch. To avoid activating the switch by mistake I would like to attach another switch to enable the first one for i.e. 5 seconds. after the 5 seconds no more activating of the first switch should be possible. On the other hand the status of the first switch should be ON also after the enabled time until shut off manually.  
Any ideas to help me please?

Erwin

---

<div class="post-metadata">

**Author:** ![Napest](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/napest/32/55656_2.png) [@Napest](https://discourse.nodered.org/u/Napest)\
**Post date:** [28 May 2022 19:30 UTC](https://discourse.nodered.org/t/enable-a-switch/63062/2 "2022-05-28T19:30:02Z")

</div>

Hi Erwin,

I've prepared something for you.

```auto
[{"id":"ef1fc105685aed46","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"08ed4bf3d8fe21d9","type":"ui_switch","z":"ef1fc105685aed46","name":"","label":"NAS on/off","tooltip":"","group":"e924fd1fd06cf83a","order":0,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":370,"y":240,"wires":[["0344fa4b5d334dbe"]]},{"id":"040e3cd0157b0925","type":"change","z":"ef1fc105685aed46","name":"","rules":[{"t":"set","p":"gate","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":160,"wires":[[]]},{"id":"0344fa4b5d334dbe","type":"switch","z":"ef1fc105685aed46","name":"","property":"gate","propertyType":"flow","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":300,"wires":[["08ed4bf3d8fe21d9","4610c433a0a4734d"],[]]},{"id":"2302680fbf4e2b27","type":"ui_switch","z":"ef1fc105685aed46","name":"","label":"Enable","tooltip":"","group":"e924fd1fd06cf83a","order":1,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":360,"y":80,"wires":[["c9376a86c72a1cbd"]]},{"id":"c9376a86c72a1cbd","type":"trigger","z":"ef1fc105685aed46","name":"","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":540,"y":140,"wires":[["2302680fbf4e2b27","040e3cd0157b0925","9d39129e738d8f80"]]},{"id":"9d39129e738d8f80","type":"ui_text","z":"ef1fc105685aed46","group":"e924fd1fd06cf83a","order":2,"width":0,"height":0,"name":"","label":"Enable:","format":"{{msg.payload}}","layout":"row-spread","className":"","x":740,"y":120,"wires":[]},{"id":"4610c433a0a4734d","type":"ui_text","z":"ef1fc105685aed46","group":"e924fd1fd06cf83a","order":2,"width":0,"height":0,"name":"","label":"NAS:","format":"{{msg.payload}}","layout":"row-spread","className":"","x":730,"y":300,"wires":[]},{"id":"e924fd1fd06cf83a","type":"ui_group","name":"Default","tab":"854bd9cd49df7ac1","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"854bd9cd49df7ac1","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

I hope I have understood your needs well.

Stepan

---

<div class="post-metadata">

**Author:** ![9toejack](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9toejack/32/56868_2.png) [@9toejack](https://discourse.nodered.org/u/9toejack)\
**Post date:** [31 May 2022 08:02 UTC](https://discourse.nodered.org/t/enable-a-switch/63062/3 "2022-05-31T08:02:37Z")

</div>

That is a good idea so something isn't accidently swiped while scrolling down, Nice one @Napest

---

<div class="post-metadata">

**Author:** ![Nilpferd](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@Nilpferd](https://discourse.nodered.org/u/Nilpferd)\
**Post date:** [5 June 2022 07:30 UTC](https://discourse.nodered.org/t/enable-a-switch/63062/4 "2022-06-05T07:30:44Z")

</div>

Many thanks. Thats a wonderful solution.

Erwin

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [5 June 2022 09:07 UTC](https://discourse.nodered.org/t/enable-a-switch/63062/5 "2022-06-05T09:07:36Z")

</div>

Or use the built in enabled property to actually disable the switch, no context needed or switch node.

```auto
[{"id":"cf150158.9206d8","type":"ui_button","z":"ef1fc105685aed46","name":"","group":"e924fd1fd06cf83a","order":8,"width":0,"height":0,"passthru":false,"label":"Enable","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"true","payloadType":"bool","topic":"topic","topicType":"msg","x":350,"y":140,"wires":[["c9376a86c72a1cbd"]]},{"id":"c9376a86c72a1cbd","type":"trigger","z":"ef1fc105685aed46","name":"","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":540,"y":140,"wires":[["9d39129e738d8f80","c086f399.b02cd"]]},{"id":"9d39129e738d8f80","type":"ui_text","z":"ef1fc105685aed46","group":"e924fd1fd06cf83a","order":2,"width":0,"height":0,"name":"","label":"Enabled:","format":"{{msg.payload}}","layout":"row-spread","className":"","x":750,"y":120,"wires":[]},{"id":"c086f399.b02cd","type":"change","z":"ef1fc105685aed46","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"enabled","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":160,"wires":[["08ed4bf3d8fe21d9"]]},{"id":"08ed4bf3d8fe21d9","type":"ui_switch","z":"ef1fc105685aed46","name":"","label":"NAS on/off","tooltip":"","group":"e924fd1fd06cf83a","order":0,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":380,"y":220,"wires":[["4610c433a0a4734d"]]},{"id":"4610c433a0a4734d","type":"ui_text","z":"ef1fc105685aed46","group":"e924fd1fd06cf83a","order":2,"width":0,"height":0,"name":"","label":"NAS:","format":"{{msg.payload}}","layout":"row-spread","className":"","x":590,"y":220,"wires":[]},{"id":"e924fd1fd06cf83a","type":"ui_group","name":"Default","tab":"854bd9cd49df7ac1","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"854bd9cd49df7ac1","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<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:** [19 June 2022 09:07 UTC](https://discourse.nodered.org/t/enable-a-switch/63062/6 "2022-06-19T09:07:58Z")

</div>

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