# Select one source out of many and send IR Commands to selected source

**URL:** <https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253>\
**Category:** General\
**Created:** [15 April 2024 17:54 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253 "2024-04-15T17:54:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonH](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@JasonH](https://discourse.nodered.org/u/JasonH)\
**Post date:** [15 April 2024 17:54 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/1 "2024-04-15T17:54:54Z")

</div>

I'm trying to send IR commands by first picking the correct source and then depending upon the source selected send IR commands to that selected source. My sources are all DISH Network receivers, I have the correct codes and I'm using Global Cache to flash the IR codes at the receivers. If I send the IR codes directly to the source it works; however, I cannot seem to find a way to first pick the source and then send to the source based upon the selection. I don't want to send the IR commands to all the sources at once...

This flow sends the IR commands thru the Global Cache correctly:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/5/d5a8c838f3134fa0a622916bcd54f04a6b72ef80.png)

This is the idea I had to first select a source, but is not working:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/8/586aa578f5dd35a1f78e7271d02302c85aaa888f.png)

Anyone create a flow to send IR commands to one source out of many?  
Sincerely

---

<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:** [15 April 2024 18:06 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/2 "2024-04-15T18:06:12Z")

</div>

Wire the drop-down to a change node that sets `flow.source`

Next wire the buttons to a change node that compares `flow.source` and add a bunch of `==` string value comparisons from from the change node outputs to the transmitters

---

<div class="post-metadata">

**Author:** ![JasonH](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@JasonH](https://discourse.nodered.org/u/JasonH)\
**Post date:** [15 April 2024 18:59 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/3 "2024-04-15T18:59:45Z")

</div>

Thanks for your help!

In my change nodes below:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/f/5f7f84c53687beca0b74618da093a435f2cacf64.png)

I have Set, Change, Delete or Move in the change nodes...How do I compare the data from the first change node? also, do I need to have a change node for each button or can I do all the comparison thru the 2nd change node?

---

<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:** [15 April 2024 19:20 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/4 "2024-04-15T19:20:00Z")

</div>

Flow 1

```plaintext
drop-down --> change node (set flow.source)

```

Flow 2

```plaintext
Button --+--> Switch --+--> IR Node
Button --+ +--> IR Node
Button --+ +--> IR Node
Button --+           

```

* * *

If you don't mind me saying, I think a little training would help:

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<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:** [15 April 2024 19:27 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/5 "2024-04-15T19:27:03Z")

</div>

> [@JasonH](#):
>
> How do I compare the data from the first change node

To clarify this. Setting flow.xxx means you can, in a separate flow, compare flow.xxx

I.e. it is simply a place to store the selected value until at some later time (i.e. when you click a button), you can the compare the flow.xxx value in a switch node to route the message to the correct IR node based on the value of flow.xxx

---

<div class="post-metadata">

**Author:** ![JasonH](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@JasonH](https://discourse.nodered.org/u/JasonH)\
**Post date:** [16 April 2024 20:12 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/6 "2024-04-16T20:12:47Z")

</div>

Thanks for helping. I watched the videos and did learn some things.

 ![Capture 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b98038ea6ea5257e23a6a61b6c146005fd3d70f9.jpeg)  
I'm getting a payload of 11 or 12 etc...with a flow.source set in the change node (below)  
 ![Capture 2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/acadce81c8406c297e26077af2d153c494fa320a.jpeg)  
Then in the switch node I have the property set to flow.source (below)  
 ![Capture 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0ea0c2983113acb88fb025a519dc998b0eb83498.jpeg)  
I'm checking flow.source and looking for 11, 12 etc...  
 ![Capture 4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/2/723dbca6d15b3d9ec4ec28b3a16e1c3ca620c931.jpeg)  
It is not passing any data through...

---

<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:** [16 April 2024 20:26 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/7 "2024-04-16T20:26:35Z")

</div>

Show me the flow context in the context viewer (drop-down near debug icon top right)

I suspect the stored value is a number and you are comparing to strings in the switch node (note the `a/z` icons)

---

<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:** [16 April 2024 20:28 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/8 "2024-04-16T20:28:54Z")

</div>

> [@JasonH](#):
>
> flow.source set in the change node (below)  
> ![Capture 2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/acadce81c8406c297e26077af2d153c494fa320a.jpeg)

Also, you are setting flow.souce to an empty string. It should be msg.payload (that's where the data from the drop down is, so you should be setting that into the flow.souce)

---

<div class="post-metadata">

**Author:** ![JasonH](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@JasonH](https://discourse.nodered.org/u/JasonH)\
**Post date:** [17 April 2024 18:00 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/9 "2024-04-17T18:00:00Z")

</div>

Thanks for your help on this! It is working fine based upon your suggestions.

---

<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:** [16 July 2024 18:00 UTC](https://discourse.nodered.org/t/select-one-source-out-of-many-and-send-ir-commands-to-selected-source/87253/10 "2024-07-16T18:00:50Z")

</div>

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