# \`switch\` node. Need help understading things

**URL:** <https://discourse.nodered.org/t/switch-node-need-help-understading-things/26998>\
**Category:** General\
**Created:** [20 May 2020 12:35 UTC](https://discourse.nodered.org/t/switch-node-need-help-understading-things/26998 "2020-05-20T12:35:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [20 May 2020 12:35 UTC](https://discourse.nodered.org/t/switch-node-need-help-understading-things/26998/1 "2020-05-20T12:35:38Z")

</div>

The dashboard `switch` node.

As hard as I am trying I can't get my head around:

> In pass through mode the switch state can be updated by an incoming `msg.payload` with the specified values, that must also match the specified type (number, string, etc). When not in passthrough mode then the icon can either track the state of the output - or the input msg.payload, in order to provide a closed loop feedback.

I have one of these nodes and on boot (if/when) it needs to be set to a _default_ value/state.

But I am trying, but not succeeding in getting it working.

This is what I have:

```auto
[{"id":"b65e3427.d0f1a","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"On/Off","tooltip":"","group":"4a387253.a6300c","order":32,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"open","onvalueType":"str","onicon":"","oncolor":"","offvalue":"close","offvalueType":"str","officon":"","offcolor":"","x":870,"y":990,"wires":[[]]},{"id":"37cfbf3a.73feb","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":690,"y":960,"wires":[["b65e3427.d0f1a"]]},{"id":"69aef393.5aa95c","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":690,"y":1030,"wires":[["b65e3427.d0f1a"]]},{"id":"4a387253.a6300c","type":"ui_group","z":"","name":"SPARE","tab":"de5134a7.f0a0d","order":3,"disp":true,"width":"6","collapse":false},{"id":"de5134a7.f0a0d","type":"ui_tab","name":"Tab 6","icon":"dashboard","order":5}]

```

But am missing that illusive elephant.

To clarify:

I want this as an INPUT. Just I also want to set the _default_ state at _boot_ by injecting a message.

I have since seen I can alter a setting and the `switch` indicates the condition of the input.  
Not really much good if I want to use the `switch` as an input device, as it now can't be clicked on to toggle its condition.

## (Typically)

After posting the question I got it working.

See next post

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [20 May 2020 12:42 UTC](https://discourse.nodered.org/t/switch-node-need-help-understading-things/26998/2 "2020-05-20T12:42:51Z")

</div>

Solved. With this code:

with this code:

```auto
[{"id":"b65e3427.d0f1a","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"On/Off","tooltip":"","group":"4a387253.a6300c","order":32,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"open","onvalueType":"str","onicon":"","oncolor":"","offvalue":"close","offvalueType":"str","officon":"","offcolor":"","x":870,"y":990,"wires":[["2eb7254a.5392d2"]]},{"id":"37cfbf3a.73feb","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":690,"y":960,"wires":[["b65e3427.d0f1a"]]},{"id":"69aef393.5aa95c","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":690,"y":1030,"wires":[["b65e3427.d0f1a"]]},{"id":"2eb7254a.5392d2","type":"debug","z":"b9924a74.4d98f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1030,"y":990,"wires":[]},{"id":"4a387253.a6300c","type":"ui_group","z":"","name":"SPARE","tab":"de5134a7.f0a0d","order":3,"disp":true,"width":"6","collapse":false},{"id":"de5134a7.f0a0d","type":"ui_tab","name":"Tab 6","icon":"dashboard","order":5}]

```

---

<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:** [3 June 2020 12:42 UTC](https://discourse.nodered.org/t/switch-node-need-help-understading-things/26998/3 "2020-06-03T12:42:58Z")

</div>

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