Get sender objects

i have 4 switches connected to a function that needs to check the state of each one.
how can i get from which switch came the msg????


Sorry thats a little vague.

  • What's a switch? Electrical switch, The switch Node?
  • What's the content of the messages?
  • Can you share your flow?

Basically, i need to check if both the switch (Manual and y+) are on, if both are on i take a value from a slider and i exec my script.
How can i setup the switch in order to check both?
the second question i need that the slider (Y axes velocity) work if the switches (manual and y+) are on, but how is configured now in my flow i can run the script also if the manual and the y+ are off.

A fundamental aspect of node-red is that messages (msg) only travel down one wire at a time and NEVER arrive at the next node at the same time.

In order to know the state of both the "Manual" button and the "Y +" button, you need to either join the 2 into one msg OR store the values for later retrieval.

Using Context

Flow 1

Manual Node → Change Node (store msg.payload in flow.manualSwitch)

Flow 2

Y + Node → Change Node (store msg.payload in flow.ySwitch)

Flow 3

Y Axes Velocity → Switch Node (is flow.manualSwitch true?) → Switch Node (is flow.ySwitch true?) → do something

Using Join Node

See this article in the cookbook for an example of how to join messages into one object.

Once you have both values in the payload, you can test msg.payload.ySwitch and msg.payload.manualSwitch in a single message

1 Like

Please try to at least be more specific with tagging your queries if you can. That helps ensure people don't waste time trying to work out what something refers to. I this case, I've moved the thread to the Dashboard category as this seems to be what the question best relates to.

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