# UI Switch node help

**URL:** <https://discourse.nodered.org/t/ui-switch-node-help/20605>\
**Category:** Dashboard\
**Created:** [19 January 2020 23:54 UTC](https://discourse.nodered.org/t/ui-switch-node-help/20605 "2020-01-19T23:54:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yawstick1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/yawstick1/32/11419_2.png) [@yawstick1](https://discourse.nodered.org/u/yawstick1)\
**Post date:** [19 January 2020 23:54 UTC](https://discourse.nodered.org/t/ui-switch-node-help/20605/1 "2020-01-19T23:54:47Z")

</div>

I'm trying to use the ui\_switch node to pass the original topic and msg thru if the switch is on and either change it or just not pass it if the switch is off. I'm not sure if it was designed to do this but could use a little help if its doable.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [20 January 2020 00:31 UTC](https://discourse.nodered.org/t/ui-switch-node-help/20605/2 "2020-01-20T00:31:09Z")

</div>

Welcome to the forum @yawstick1

You can use the ui\_switch node to control a gate that will pass or block messages.

Below post is a good reference on how to do that. Good examples there.

> [@Understanding dashboard switch](https://discourse.nodered.org/t/understanding-dashboard-switch/2334/4):
>
> Let the switch be the controller of the gate [{"id":"6f6a991e.4a28d8","type":"function","z":"81c5c63b.6b8288","name":"gate","func":"// read (or initialize) gate state\nvar gateIsOpen = context.get(\"gateIsOpen\") || false;\n\n//message is from switch\nif(msg.topic === \"gate\"){\n gateIsOpen = msg.payload;\n // store the gate state \n context.set(\"gateIsOpen\",gateIsOpen);\n}\n\n// message is from other sources\nelse{\n if(gateIsOpen === true){\n node.status({fill:\"green\",shape:\"ring\",text…

---

<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:** [6 March 2020 11:28 UTC](https://discourse.nodered.org/t/ui-switch-node-help/20605/4 "2020-03-06T11:28:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [6 March 2020 11:43 UTC](https://discourse.nodered.org/t/ui-switch-node-help/20605/5 "2020-03-06T11:43:53Z")

</div>

Reopening the automatically closed topic, awaiting a potential reply from the topic starter. It appears to have been solved, but there may be another addition.
