Switch Node- Default

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?

I assume you mean the Dashboard ui_switch node and not the core switch node?

Yes, the dashboard switch.

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

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.

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'.

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

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

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

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

1 Like

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

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.

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.

2 Likes

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

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

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.

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

1 Like