Node Red Power on state

Dear folks, when I restart Node Red or restart my Pi running Node Red under Home Assitant, some switch changes state. From on to off.
I have noticed that there is tugging at a restart,
How can I ensure that the status remains as before the restart.

I would store the state of the switch is persistent storage (flow or global contect) and then when you restart NR have an inject node that would read the flow or global variable and set the switches to that value.

Or if you are using MQTT then use a Retained topic to keep the state of the switch. Feed this in the front of the switch and on startup the switch will automatically be set to the last value.

This has the additional advantage that you can separate the control of the process from the ui, as on a separate tab (or even in a different node-red server, provided it has access to the mqtt broker) you can use the state from mqtt to drive the process. Keeping the UI separate from the process control can make the flows much simpler. Also easier to build as your brain only needs to think about a portion of the system at a time. First get the UI working, then use the mqtt topics to drive the process, and data from the process gets fed back into mqtt, which then gets picked up again in the UI flows to drive the gauges or whatever.

Dear Colin, thank you for your response.

I just don't get much of it. This is entirely up to me.
I will try to explain what kind of flow I want to make.
I want a switch on the dashboard, Ui from home assitant. I want to use this switch in a flow in node red. I want this switch to switch several mqtt switches.
I created an entity for this in node red (see pic)

.I can make this visible as a switch in Home Assistant. So far so good.
But now I found out that when I change a flow and want to save (deploy), this switch is triggered and because I use a toggle switch, it turns on at that moment. This also applies if the Home Assistant has to be restarted. But this is natural because Node red runs on my PI under Home Assistant.

How can I most easily make a switch in node red that I can also use in ui from Home Assistant.
I am really a new with Node Red en Home assistant.

gr Vlak

Sorry I don't know about HA.

No problem. can you come up with solution ?

Since I don't know about HA and you are asking a question about how to do something in HA then no I can't, perhaps someone else can.

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