# Switch Node- Default

**URL:** <https://discourse.nodered.org/t/switch-node-default/13403>\
**Category:** Feature Requests\
**Created:** [17 July 2019 13:17 UTC](https://discourse.nodered.org/t/switch-node-default/13403 "2019-07-17T13:17:18Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [17 July 2019 13:17 UTC](https://discourse.nodered.org/t/switch-node-default/13403/1 "2019-07-17T13:17:18Z")

</div>

Shouldn't there be a way to make the switch node to default to "On"?

When I want a switch to default to "on" I use an inject node to set it to "on" at startup, but I was wondering why the default state be couldn't be selectable in the switch node?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [17 July 2019 13:28 UTC](https://discourse.nodered.org/t/switch-node-default/13403/2 "2019-07-17T13:28:56Z")

</div>

I assume you mean the Dashboard ui\_switch node and not the core switch node?

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [17 July 2019 14:17 UTC](https://discourse.nodered.org/t/switch-node-default/13403/3 "2019-07-17T14:17:02Z")

</div>

Yes, the dashboard switch.

---

<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:** [17 July 2019 15:00 UTC](https://discourse.nodered.org/t/switch-node-default/13403/4 "2019-07-17T15:00:07Z")

</div>

Do you just want it to default to On or do you also want it to send an On message?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 July 2019 15:06 UTC](https://discourse.nodered.org/t/switch-node-default/13403/5 "2019-07-17T15:06:27Z")

</div>

Colin is right. The ui is just a reflection of the backend flow, so really it should be in an unknown state until told to be in a certain state.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [17 July 2019 15:10 UTC](https://discourse.nodered.org/t/switch-node-default/13403/6 "2019-07-17T15:10:44Z")

</div>

But visually the switch assumes the off position until told otherwise. I don't think it's unreasonable to want it to 'assume the on position until told otherwise'.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 July 2019 15:12 UTC](https://discourse.nodered.org/t/switch-node-default/13403/7 "2019-07-17T15:12:24Z")

</div>

I look forwards to reviewing the Pull Request when I get back from vacation 🙂

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [17 July 2019 15:13 UTC](https://discourse.nodered.org/t/switch-node-default/13403/8 "2019-07-17T15:13:20Z")

</div>

So I assume that means you agree in principle the switch node should provide that functionality?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 July 2019 15:21 UTC](https://discourse.nodered.org/t/switch-node-default/13403/9 "2019-07-17T15:21:30Z")

</div>

2/10. It could. As mentioned it won’t mean the value in the flow is that value, it would be purely visual.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [17 July 2019 15:27 UTC](https://discourse.nodered.org/t/switch-node-default/13403/10 "2019-07-17T15:27:35Z")

</div>

> [@dceejay](#):
>
> it would be purely visual

Which then adds another layer of confusion ... specially for beginners

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 July 2019 15:28 UTC](https://discourse.nodered.org/t/switch-node-default/13403/11 "2019-07-17T15:28:06Z")

</div>

Maybe better if the option was to set and send at start with 3 options - nothing (as now) , on , or off

Though a preceding inject at start makes things definite

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [17 July 2019 15:36 UTC](https://discourse.nodered.org/t/switch-node-default/13403/12 "2019-07-17T15:36:40Z")

</div>

> [@dceejay](#):
>
> Maybe better if the option was to send set and send at start with 3 options - nothing (as now) , on , or off

I think this still misses the scenario in question. We are not talking about the switch node sending messages. This is about what the switch node looks like until it is told what state it should be in.

Today it appears 'off' until it is told otherwise. That are perfectly legitimate reasons to want the default appearance to be 'on' until told otherwise.

---

<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:** [17 July 2019 15:46 UTC](https://discourse.nodered.org/t/switch-node-default/13403/13 "2019-07-17T15:46:39Z")

</div>

Of course at the moment it shows Off but again that does not mean the corresponding value in the flow is off.  
I maintain all my system state in retained topics in MQTT and on startup that automatically gets sent to the switch and anything else that needs it so the question does not arise.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 July 2019 16:15 UTC](https://discourse.nodered.org/t/switch-node-default/13403/14 "2019-07-17T16:15:37Z")

</div>

My concern is that it sets the expectation that the choice is the actual value (even more so than now)

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [17 July 2019 21:05 UTC](https://discourse.nodered.org/t/switch-node-default/13403/15 "2019-07-17T21:05:34Z")

</div>

My workaround is to send an "on" msg to the switch from an inject node on startup. In this case the "If msg arrives on input, pass through to output:" handles whether I want the injected "on" to go to the output.

So if there were a default (I.E. initial state), it could work the same way. Treat the default as an incoming msg at the input.

```
Steve
```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 July 2019 21:32 UTC](https://discourse.nodered.org/t/switch-node-default/13403/16 "2019-07-17T21:32:30Z")

</div>

That is not a workaround. ( To me at least) that is the correct thing to do, as the flow and switch are then in sync. Just having it start looking like it is on may or may not reflect the state of the flow.

---

<div class="post-metadata">

**Author:** ![SteveMann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stevemann/32/3810_2.png) [@SteveMann](https://discourse.nodered.org/u/SteveMann)\
**Post date:** [17 July 2019 21:35 UTC](https://discourse.nodered.org/t/switch-node-default/13403/17 "2019-07-17T21:35:51Z")

</div>

Then, I've been doing it right all along. What a concept.
