# MQTT in Node - sort/switch the input

**URL:** <https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603>\
**Category:** General\
**Created:** [16 December 2020 22:16 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603 "2020-12-16T22:16:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [16 December 2020 22:16 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603/1 "2020-12-16T22:16:45Z")

</div>

Hello  
i have some msg.payload coming from a Raspi-with433MHz Dongel.  
They nicely drop in Node Red MQTT IN with output a parsed JSON object  
The Question how do i splitt the Message to use them and later add to InfluxDB?  
The id: will ich change, or how will it work when two device have the same ID?  
Do i have to use the Switch node, to splitt the differen input?

iot12-rpi3b-gw-433 : msg.payload : Object  
object  
time: "2020-12-16 21:31:37"  
brand: "OS"  
model: "Oregon-THGR122N"  
id: 126  
channel: 2  
battery\_ok: 1  
temperature\_C: 6.2  
humidity: 77

have a nice day  
vinc

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [16 December 2020 23:02 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603/2 "2020-12-16T23:02:28Z")

</div>

Why do you think you have to split the message up? For example, You could send the msg to three different debug nodes and each one would have all the data. All you need to do is address the item you want like msg.payload.humidity

---

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [17 December 2020 05:30 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603/3 "2020-12-17T05:30:56Z")

</div>

@zenofmud thanks for your feedback  
not the Message itself but the flow of message have to be splitt. i think but not to sure!  
have a nice day  
vinc

---

<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:** [17 December 2020 07:32 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603/4 "2020-12-17T07:32:21Z")

</div>

> [@vikozo](#):
>
> not the Message itself but the flow of message have to be splitt. i think but not to sure!

There is no point working out how to do something if you don't even know whether you need to do it. What is it that you need to do?

---

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [17 December 2020 09:02 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603/5 "2020-12-17T09:02:02Z")

</div>

i have all 433MHz Message coming in with MQTT.  
Some device i Know some not.  
the one i know i would like to store it in a Database and also send message if Battery is low.  
the device i am not sure should just be listed and after a while should be deleted

have a nice day  
vinc

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 December 2020 10:30 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603/6 "2020-12-17T10:30:29Z")

</div>

@vikozo

1. What is building the JSON object?
2. If you have multiple devices with the same 'id' is the 'model' different? Can you change the 'id' on the device?
3. is the data coming from the different devices different? for example, it one device reporting temperature and humidity while another is reporting if a window is open or closed?

If you have multiple devices sending in the same ID and the MODEL is the same, there is no way to tell which device it came from. That would have to be determined before the data makes it to Node-RED.

Once the data gets to NR, you you could use a switch node to send the msg to different legs of the flow.

---

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [17 December 2020 14:37 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603/7 "2020-12-17T14:37:18Z")

</div>

@zenofmud Hello Paul  
it is called up or send from a Raspberry Pi with 433 Dongel  
rtl\_433 -F json -M utc | mosquitto\_pub -h 192.168.x.xxx -p 1883 -t home/rtl\_433 -l

like this all come in!  
time : 2020-12-14 22:10:55  
model : TFA-Pool Id : 142  
Channel : 1 Battery : 1 Temperature: 2.9 C Integrity : CHECKSUM

* * *

time : 2020-12-14 22:10:59 brand : OS  
model : Oregon-THGR122N House Code: 16  
Channel : 1 Battery : 1 Temperature: 23.20 C Humidity : 38 %

* * *

time : 2020-12-14 22:10:59 brand : OS  
model : Oregon-THGR122N House Code: 126  
Channel : 2 Battery : 1 Temperature: 22.70 C Humidity : 52 %

the model is strange because the THGR122N are two different device but send the same Information.

no i can't change the ID - i dont know where it commes from

i would have been thinking  
a switch and sort/splitt the device between the known and the other  
so switch model : Oregon-THGR122N and then a second switch for the channel or the ID  
this both the data should go to a database

the other is just for curiosity what is arround which i could also be added to the known as soon i know where it stay

have a nice day  
vinc

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 December 2020 15:03 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603/8 "2020-12-17T15:03:20Z")

</div>

Can you put a `debug` node (set to display the 'Complete msg object) on the output of the `mqtt-in` node. After it spits out some data, expand all the items in the debug log and copy and past a couple into a reply.

---

<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:** [15 February 2021 15:03 UTC](https://discourse.nodered.org/t/mqtt-in-node-sort-switch-the-input/37603/9 "2021-02-15T15:03:21Z")

</div>

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