# Have Objects in msg, need to take actions based on one of the payload codes

**URL:** <https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451>\
**Category:** General\
**Created:** [13 December 2020 19:17 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451 "2020-12-13T19:17:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [13 December 2020 19:17 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/1 "2020-12-13T19:17:45Z")

</div>

Hello, I am using rtl\_433 in my node red project and have the need to take actions within node red based upon the data within payload.code of my (msg.payload : Object). Here is an example of the message from the rtl\_433 node:

![rtl1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f88ff24bf7523dc93a8286fbee26605162d9b15.png)

I will be keeping rtl\_433 running and listening for 433mhz signals that I wish to use within my flow. Based upon the data in the "code" payload and intend to take action on ~20 different codes. I have attempted a few functions and other NOOB pokes at it, but to no avail. I was thinking some type of case statement perhaps then to the output I need. All ideas very welcome.

---

<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:** [13 December 2020 19:35 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/2 "2020-12-13T19:35:12Z")

</div>

> [@Tomadoggy](#):
>
> I was thinking some type of case statement

That is what a switch node does.

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<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:** [13 December 2020 19:37 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/3 "2020-12-13T19:37:07Z")

</div>

You may be able to simply use a switch node. Though if you need to switch on different payload properties, a function node might be easier.

If, for example you needed to decided based on the protocol: `msg.payload.protocol` is what you would choose in the switch node.

If, howeverm you need to decide based on \>1 property then almost certainly a function node will be easier.

---

<div class="post-metadata">

**Author:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [13 December 2020 20:12 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/4 "2020-12-13T20:12:36Z")

</div>

First of all thank you both! Making some progress with the Switch node as I can have many outputs and action on those appropriately. For now this looks like the correct path unless I need to look at more than one payload.xxx. I can now segregate the actions based upon the codes.

**Off-topic, but related to the solution I am attempting:**

Is there any way to read the status of the node-red UI switch node? As I am using the same rtl\_433 code to both switch on and off a relay I need to check the status of that UI node prior to sending the correct payload to it (On or Off) as my main goal here is to update the UI nodes properly based upon two methods of activating the relay. For instance, I have 433mhz wall switches that directly control the relays which are equipped with 433mhz receivers, I also have the UI node which when pressed sends the 433mhz code via a Python script on my Pi. So now my rtl\_433 is listening for the wall switch presses (basis of this thread) and I need to update the UI switch status appropriately based upon its current status.

![switch](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/1/4115b130e5f6e6160485c0b5bbf64414f87bf610.png)

Looks like I have to store the state of the switch using a function node, but attempting to now read that state prior to sending the proper message to it after reading the rtl\_433 code.

---

<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:** [14 December 2020 00:02 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/5 "2020-12-14T00:02:23Z")

</div>

> [@Tomadoggy](#):
>
> Is there any way to read the status of the node-red UI switch node

Yes, you can use the `status` node. However, I ~~trust~~ prefer to store the state in `flow` or `global` context so that I can access it in a function/switch/change node at any appropriate time.

e.g.

`[switch node]` ➡ `[change node]` _(set `flow.switch1` to `msg.payload`)_

then

`[some event]`➡ `[change node]` _(set `msg.payload` to `flow.switch1`)_ ➡ `[switch node]` _(on or off)_

---

<div class="post-metadata">

**Author:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [14 December 2020 00:18 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/6 "2020-12-14T00:18:17Z")

</div>

Thank you Steve. I have been experimenting with sending the state of the UI switch node to an MQTT topic (retain=true), then attempting to read that same MQTT switch state and use switch and change nodes from there. I have read through your explination several times but cannot seem to wrap my head around what you are suggesting which BTW sounds like a much better solution. Would you be able to expound on your proposed solution or provide a flow that gives me some traction?

---

<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:** [14 December 2020 01:15 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/7 "2020-12-14T01:15:10Z")

</div>

> [@Tomadoggy](#):
>
> I have read through your explination several times but cannot seem to wrap my head around what you are suggesting which BTW sounds like a much better solution

It all depends on the end goal.

This is what I meant...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/a/6af607f556ee1b0d8fdade4cf26e23f8c15eef18.png)

```auto
[{"id":"38d8e069.8596d","type":"ui_switch","z":"dabbee39.9c292","name":"","label":"switch","tooltip":"","group":"dce9e7a2.d20c78","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":390,"y":180,"wires":[["306abda4.e31ad2"]]},{"id":"306abda4.e31ad2","type":"change","z":"dabbee39.9c292","name":"copy msg.payload --> flow.switch1","rules":[{"t":"set","p":"switch1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":180,"wires":[[]]},{"id":"d4a3ba82.f67da8","type":"inject","z":"dabbee39.9c292","name":"some event","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":280,"wires":[["18aba6d4.3147c9"]]},{"id":"18aba6d4.3147c9","type":"change","z":"dabbee39.9c292","name":"copy flow.switch1 --> msg.payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"switch1","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":280,"wires":[["1b228ad.6e3ce75"]]},{"id":"1b228ad.6e3ce75","type":"switch","z":"dabbee39.9c292","name":"is payload true or false?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":360,"wires":[["1342f993.77b066"],["ba2b469a.e26418"]]},{"id":"1342f993.77b066","type":"debug","z":"dabbee39.9c292","name":"switch1 is true :)","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":340,"wires":[]},{"id":"ba2b469a.e26418","type":"debug","z":"dabbee39.9c292","name":"switch1 is false :(","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":380,"wires":[]},{"id":"44b9eec.395dc1","type":"comment","z":"dabbee39.9c292","name":"When sw changes, store payload in flow.switch1","info":"","x":520,"y":140,"wires":[]},{"id":"5ad2ff93.dcf1b","type":"comment","z":"dabbee39.9c292","name":"When something unrelated happens, get flow.switch1 & do something based on its value","info":"","x":600,"y":240,"wires":[]},{"id":"dce9e7a2.d20c78","type":"ui_group","name":"Object detection","tab":"5132060d.4cde48","order":1,"disp":true,"width":"7","collapse":false},{"id":"5132060d.4cde48","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

note: this is a fairly verbose demo purely to demonstrate the use of flow context

---

<div class="post-metadata">

**Author:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [14 December 2020 13:19 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/8 "2020-12-14T13:19:22Z")

</div>

Steve, so very interesting. I have never seen the change node used to do the Set, I can see this being very useful! I will spend some time with your example which does look very promising. I will share my solution when I get it properly functioning. Again, I wish to thank you for sharing your skills and time!

---

<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:** [14 December 2020 14:40 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/9 "2020-12-14T14:40:23Z")

</div>

> [@Tomadoggy](#):
>
> I have never seen the change node used to do the Set

That is pretty much its primary purpose

You might do well to spend an hour or so 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:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [14 December 2020 15:05 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/10 "2020-12-14T15:05:24Z")

</div>

Will do, Thank you!

---

<div class="post-metadata">

**Author:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [14 December 2020 15:52 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/11 "2020-12-14T15:52:19Z")

</div>

Making progress, but since the UI switch needs to activate the relay via my python script sending the 433mhz signal the flow goes into a loop of on/off as the rtl\_433 sees that 433mhz send when the UI switch is changed. I tried some delays, but that negates the seamless UI update and/or delays the relay on/off. Any ideas?

```auto
[{"id":"18e8e789.778a08","type":"tab","label":"Translate 433mhz","disabled":false,"info":""},{"id":"68134d2b.4fc204","type":"debug","z":"18e8e789.778a08","name":"From rtl_433","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":110,"y":80,"wires":[]},{"id":"31e8fc24.42c854","type":"rtl_433","z":"18e8e789.778a08","name":"","device":"","frequency":"","protocols":"","x":90,"y":20,"wires":[["68134d2b.4fc204","a153d738.c85908"]]},{"id":"a153d738.c85908","type":"switch","z":"18e8e789.778a08","name":"","property":"payload.code","propertyType":"msg","rules":[{"t":"eq","v":"450513","vt":"str"},{"t":"eq","v":"8529fb","vt":"str"},{"t":"eq","v":"2529fb","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":290,"y":35.5,"wires":[["98768616.8d5188"],["51f1aacb.c56824"],["6c42780f.3f0e48"]]},{"id":"2f917e27.809da2","type":"mqtt out","z":"18e8e789.778a08","name":"","topic":"Relay_1","qos":"0","retain":"true","broker":"98e43eb6.346e2","x":580,"y":40,"wires":[]},{"id":"38d8e069.8596d","type":"ui_switch","z":"18e8e789.778a08","name":"","label":"Relay #1","tooltip":"","group":"dce9e7a2.d20c78","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":864,"y":160,"wires":[["306abda4.e31ad2","cd668987.36ce98"]]},{"id":"306abda4.e31ad2","type":"change","z":"18e8e789.778a08","name":"copy msg.payload --> flow.relay1","rules":[{"t":"set","p":"relay1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":804,"y":240,"wires":[[]]},{"id":"cd668987.36ce98","type":"exec","z":"18e8e789.778a08","command":"python3 send.py -p 367 -t 1 13148322","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Relay #1 Send Code","x":1080,"y":160,"wires":[[],[],[]]},{"id":"98768616.8d5188","type":"change","z":"18e8e789.778a08","name":"copy flow.relay1 --> msg.payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"relay1","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":184,"y":160,"wires":[["d81f173e.5ee2b8","afa62b39.2c6098"]]},{"id":"d81f173e.5ee2b8","type":"switch","z":"18e8e789.778a08","name":"is payload true or false?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":457,"y":160,"wires":[["f5f80e84.274ab"],["b9f164e3.15b8b8"]]},{"id":"b9f164e3.15b8b8","type":"change","z":"18e8e789.778a08","name":"if false, set to true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":684,"y":180,"wires":[["38d8e069.8596d"]]},{"id":"f5f80e84.274ab","type":"change","z":"18e8e789.778a08","name":"if true, set to false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":684,"y":140,"wires":[["38d8e069.8596d"]]},{"id":"e424bb0.13bf448","type":"ui_switch","z":"18e8e789.778a08","name":"","label":"Relay #2","tooltip":"","group":"dce9e7a2.d20c78","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":864,"y":320,"wires":[["3a3857ba.4f26d8"]]},{"id":"3a3857ba.4f26d8","type":"change","z":"18e8e789.778a08","name":"copy msg.payload --> flow.relay2","rules":[{"t":"set","p":"relay2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":804,"y":400,"wires":[[]]},{"id":"51f1aacb.c56824","type":"change","z":"18e8e789.778a08","name":"copy flow.relay2 --> msg.payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"relay2","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":184,"y":320,"wires":[["7fa2de29.568a7"]]},{"id":"7fa2de29.568a7","type":"switch","z":"18e8e789.778a08","name":"is payload true or false?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":457,"y":320,"wires":[["8b9b6c87.31283"],["b767b732.b24208"]]},{"id":"b767b732.b24208","type":"change","z":"18e8e789.778a08","name":"if false, set to true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":684,"y":340,"wires":[["e424bb0.13bf448"]]},{"id":"8b9b6c87.31283","type":"change","z":"18e8e789.778a08","name":"if true, set to false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":684,"y":300,"wires":[["e424bb0.13bf448"]]},{"id":"91ed0081.468b1","type":"ui_switch","z":"18e8e789.778a08","name":"","label":"Relay #3","tooltip":"","group":"dce9e7a2.d20c78","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":864,"y":480,"wires":[["fafae55a.39ab68"]]},{"id":"fafae55a.39ab68","type":"change","z":"18e8e789.778a08","name":"copy msg.payload --> flow.relay3","rules":[{"t":"set","p":"relay3","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":804,"y":560,"wires":[[]]},{"id":"6c42780f.3f0e48","type":"change","z":"18e8e789.778a08","name":"copy flow.relay3 --> msg.payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"relay3","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":184,"y":480,"wires":[["c748a6a4.1998b8"]]},{"id":"c748a6a4.1998b8","type":"switch","z":"18e8e789.778a08","name":"is payload true or false?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":457,"y":480,"wires":[["734d2956.3af778"],["1ed2c16c.91c21f"]]},{"id":"1ed2c16c.91c21f","type":"change","z":"18e8e789.778a08","name":"if false, set to true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":684,"y":500,"wires":[["91ed0081.468b1"]]},{"id":"734d2956.3af778","type":"change","z":"18e8e789.778a08","name":"if true, set to false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":684,"y":460,"wires":[["91ed0081.468b1"]]},{"id":"afa62b39.2c6098","type":"debug","z":"18e8e789.778a08","name":"relay 1 state","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":350,"y":240,"wires":[]},{"id":"98e43eb6.346e2","type":"mqtt-broker","name":"P-Pi-Gibson","broker":"192.168.1.101","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"dce9e7a2.d20c78","type":"ui_group","name":"Object detection","tab":"5132060d.4cde48","order":1,"disp":true,"width":"7","collapse":false},{"id":"5132060d.4cde48","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<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:** [14 December 2020 16:02 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/12 "2020-12-14T16:02:02Z")

</div>

Could be pass though causing a loop (switch it off)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/09c951fdc46db740c00013ddbd53082d8bd22ed4.png)

---

<div class="post-metadata">

**Author:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [14 December 2020 16:13 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/13 "2020-12-14T16:13:50Z")

</div>

Steve, I failed to mention that I also tried that...however in doing so the set UI switch payload fails to update and thus the incoming new state does not alter the UI switch status.

---

<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:** [14 December 2020 16:24 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/14 "2020-12-14T16:24:54Z")

</div>

What is the logic you wish to achieve (in steps please)

e.g.

1. Opertaing UI Switch from OFF--\>ON sends XXX??? to Python Script

2. RF input from Relay is recieved in node-red (value is XXXX)

etc.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 December 2020 16:25 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/15 "2020-12-14T16:25:04Z")

</div>

Set the ui switch to show the state of the input, not the output.

---

<div class="post-metadata">

**Author:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [14 December 2020 16:49 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/16 "2020-12-14T16:49:56Z")

</div>

Here is the logic, hopefully it is clear:

1. 433mhz **single button** wall switch sends signal to the relay which is equipped with a 433 receiver.

2. I also need to control the relay via the node red UI via the switch node

3. rtl\_433 is running on the pi and listening for ALL 433mhz transmissions, the node red rtl node is followed by the switch node to separate out each 433mhz captured code into actions to be taken against the UI switch node

---

<div class="post-metadata">

**Author:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [14 December 2020 19:46 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/17 "2020-12-14T19:46:14Z")

</div>

Colin, I am not certain what you are recommending here. I don't see any such option in the UI switch

> Set the ui switch to show the state of the input, not the output.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 December 2020 20:13 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/18 "2020-12-14T20:13:32Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/4/a44ac57616d62021094ca965e4f82f82addf5892.png)

It appears when you tell it not to pass through (there is no difference whether it shows the in or the out if the message is being passed through). The way the switch then works is that when you click it the switch icon does not change immediately, the instruction goes off to the real world to change the hardware state, and when confirmation comes back in to the input that it has changed then the icon changes. That way the icon always shows what the real world is doing.

---

<div class="post-metadata">

**Author:** ![Tomadoggy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tomadoggy/32/34065_2.png) [@Tomadoggy](https://discourse.nodered.org/u/Tomadoggy)\
**Post date:** [14 December 2020 21:42 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/19 "2020-12-14T21:42:42Z")

</div>

Interesting...my UI switch node does not have the option you show??

 ![switchui](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/9/19be818dbd8b638068831b8c312309702f49ea44.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [14 December 2020 21:50 UTC](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451/20 "2020-12-14T21:50:18Z")

</div>

> [@Colin](#):
>
> It appears when you tell it not to pass through

@Tomadoggy, Clear the Pass Through checkbox.

[Next page](https://discourse.nodered.org/t/have-objects-in-msg-need-to-take-actions-based-on-one-of-the-payload-codes/37451.md?page=2)
