Save state Switch node

Hi

I have a switch node that I set the the flow to port 1 or 2.
After I restart my Raspberry PI the node reset to port 0.
Is there a way to save the flow of the node?

Switch is based on some variable. To make that persistent across restarts, you need a retained variable. You can change the settings for node-red to add retained variables as an option (the default is in-memory only) and use a change node in front of the switch to recover the variable onto the msg that gets passed to the switch.

If you re using MQTT, you can use a retained topic to similar effect execpt that you need an mqtt-in node set to the retained topic, that node will fire a msg if the topic value changes or if node-red restarts.

Thank you a lot.

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