The three-state switch always sends a message after the Deploy of "Modified flows"

I’m a novice to Node-Red, but I have already discovered that the typical behaviour is that, after Deploy of “Modified flows”, it only restarts the nodes in the flows that have changed. However, this is not the case for the three-state switch. It always sends a message with the topic: ‘Switch/state’ after Deploy Modified flows.

Switch/state : msg : Object
object
payload: 0
topic: "Switch/state"
source_path: "/SwitchableOutput/output_1/State"

However, this can cause issues when you control a node connected to a physical relay by auto mode. While doing some logic in auto mode, you may decide to set the relay to ON. After deploying the Modified flows, the relay state may briefly switch to the opposite state (due to Switch/state message arrive into same node). This is unwanted and it’s difficult to create a workaround. For example, I was thinking to use Inject node (set to ‘Inject once after…’) to set some flow variable and block such message using a switch node. But this is not possible, because such an Inject node is not executed after Deploy Modified flows. The solution might be to use Full deploy, but this completely restarts other flows that you don’t want to affect while you’re experimenting with a new flow.

Is there any other workaround or possibility to modify the node so that it doesn’t behave like that?

You are right, sometimes the relay flips over on on even a gx restart. It has been something that happened since the first relay on a GX controlled by node red.
There have been a couple of threads discussing the behaviour

In fact, this isn’t primarily an issue with the GX/Cerbo relay. The same issue can occur with relays from other manufacturers, such as Shelly.

It appears that the main cause is the three-state switch, which sends redundant messages (and possibly rerversed). It’s not just the relay that can be affected in this way — anything connected to that node can be affected too.

Ok. So not the issue i was thinking about then.
I haven’t had then.

Setting only update only on changes? Or a delay?

That might solve the problem, but even this is a Victron node, the Changes Only option isn’t available in its settings. A delay won’t help, because the flip will still occur—just later.

If you have done any work on a flow the default for the switch in virtual devices auto is switched to manual. Usually defaults to off.

So instead of sending modified flow, just send modified nodes. That then will then not affect the auto manual switch (unless you edited it)