Initial value of virtual switch in v3.7

I am trying out the new Cerbo UI for virtual switches in firmware 3.70. I have created a flow that configures my equipment based on the setting of a particular switch. I noticed that the flow only seems to execute when I actually change the switch in the UI. It does NOT execute upon initial deployment of my flows. Is this a bug? Is there some technique to get the flow to read and flow the current value of the virtual switch?

Clarification: I am talking about the yellow “virtual switch” node in the node pallette. I just discovered the BLUE “switch” node in the pallette . It appears this outputs the current value of a switch. So, I THINK the yellow switch node is used to create the switch, and the blue switch node is used to get its value. Does that sound correct?

You’ll need to enable persistent storage on your Cerbo if you haven’t already ( Node Red - Enable Persistent Context Store - VictronEnergy )

1 Like

Yes, the Orange defines the switch, the blue is used to get the switch. This is how I have mine. I do not know about values on Node-RED deployment but they seem to work OK. I have not enabled persistent storage so check to see if this is actually required or not first.

It’s sort of expected behavior.
At startup Node Red doesn’t know what state the switch is in, so it is none.
In electronics this is often called tri-state - not on but also not off either.

To set a fixed value at Node Red startup you can hook a one-time Inject node to the switch input.
If the switch in the UI is linked to an actual switch, you can read the value of the actual switch (set to “Only changes”) and feed that to the switch node input.
If you want the switch state to persist after a Node Red restart you’ll have to enable persistent storage.

1 Like