# Get sender objects

**URL:** <https://discourse.nodered.org/t/get-sender-objects/74561>\
**Category:** Dashboard\
**Created:** [1 February 2023 14:17 UTC](https://discourse.nodered.org/t/get-sender-objects/74561 "2023-02-01T14:17:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![superlogan72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superlogan72/32/74680_2.png) [@superlogan72](https://discourse.nodered.org/u/superlogan72)\
**Post date:** [1 February 2023 14:17 UTC](https://discourse.nodered.org/t/get-sender-objects/74561/1 "2023-02-01T14:17:05Z")

</div>

Hello  
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????  
Thanks

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [1 February 2023 14:24 UTC](https://discourse.nodered.org/t/get-sender-objects/74561/2 "2023-02-01T14:24:52Z")

</div>

Hi,

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?

---

<div class="post-metadata">

**Author:** ![superlogan72](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/superlogan72/32/74680_2.png) [@superlogan72](https://discourse.nodered.org/u/superlogan72)\
**Post date:** [1 February 2023 18:03 UTC](https://discourse.nodered.org/t/get-sender-objects/74561/3 "2023-02-01T18:03:29Z")

</div>

Hello  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ff0a5b4e34773b983669e4526ca7d33ccb992db2.png)  
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.  
Thanks

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [1 February 2023 18:16 UTC](https://discourse.nodered.org/t/get-sender-objects/74561/4 "2023-02-01T18:16:26Z")

</div>

> [@superlogan72](#):
>
> Hello
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ff0a5b4e34773b983669e4526ca7d33ccb992db2.png)  
> 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?

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](https://cookbook.nodered.org/basic/join-streams) 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

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [1 February 2023 20:25 UTC](https://discourse.nodered.org/t/get-sender-objects/74561/5 "2023-02-01T20:25:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 April 2023 20:25 UTC](https://discourse.nodered.org/t/get-sender-objects/74561/6 "2023-04-02T20:25:39Z")

</div>

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