Node-RED - Is it possible to not trigger events with changes inside Node?

Anybody knows if it is possible to have a events:state node or similar that only triggers if the state change comes outside from Node-RED?

For example i have a switch that is turned on/off inside a flow but can also be turned on/off directly in homeassistant. I would like to have another flow that only triggers when the switch is changed outside of Node-RED.

Thank you for any suggestion.

The only thing I can think of is to set a global variable.

In a function node you can do:

flow.set("variable_name", "variable_value");

Then in switch nodes you can change to flow instead of msg.
That way you can set a variable when you use node red to do changes. Perhaps…

That’s kind of what i’ve been doing so far but i was looking for a more elegant solution.

Thanks!

I see the user id’s are different when state is changes via lovelace vs node-red