# Separate Two MQTT Temperature Payloads?

**URL:** https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398
**Category:** General
**Created:** [22 September 2021 15:14 UTC](https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398 "2021-09-22T15:14:23Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Choder](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/choder/32/48464_2.png) [@Choder](https://discourse.nodered.org/u/Choder)
#### Post date: [22 September 2021 15:14 UTC](https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398/1 "2021-09-22T15:14:24Z")

</div>

How do I separate these two MQTT temp payloads so that I can work with them. I have tried using a function node but, I'm really lost.

I have a nodemcu running tasmota with two DS18B20 sensors attached and returning 2 separate temperature readings using MQTT.

This is the debug I get from my MQTT input on Nodered.

![nodered](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ff99cc0df265ee607a9bc7002a978e3743ca1510.jpeg)

object

topic: "tele/relaystack/SENSOR"

payload: "{"Time":"2021-09-22T16:10:36","DS18B20-1":{"Id":"0516A37095FF","Temperature":23.6},"DS18B20-2":{"Id":"3C01F095CECB","Temperature":23.7},"TempUnit":"C"}"  
qos: 0  
retain: false  
\_msgid: "4cb28f7c.a6be3"

Tasmota output

16:09:46.424 MQT: tele/relaystack/SENSOR = {"Time":"2021-09-22T16:09:46","DS18B20-1":{"Id":"0516A37095FF","Temperature":23.6},"DS18B20-2":{"Id":"3C01F095CECB","Temperature":23.7},"TempUnit":"C"}

---

<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: [22 September 2021 15:29 UTC](https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398/2 "2021-09-22T15:29:58Z")

</div>

firstly, set the MQTT in node to parse JSON

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

Next, you can use the "copy path" button in the debug to get the path to any item - then use 2 change nodes to move the values around

* * *

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.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

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

  

* * *
  

PS, please use the "copy value" button when posting values / code on the forum. Also, use the `</>` code button so that code is formatted correctly

---

<div class="post-metadata">

### Author: ![Choder](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/choder/32/48464_2.png) [@Choder](https://discourse.nodered.org/u/Choder)
#### Post date: [22 September 2021 15:49 UTC](https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398/3 "2021-09-22T15:49:31Z")

</div>

Thanks for the help.

I have switched it as you said to JSON object.

I'm not sure what to put in the change node.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/878687b135f242ad4bce3b710bfebc9ef52a4179.png)

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

```auto
[{"id":"2451fec2.edb1b2","type":"mqtt in","z":"c74b932.e47c17","name":"DS18B20 Temp Sensors","topic":"tele/relaystack/SENSOR","qos":"0","datatype":"json","broker":"389dd264.7716de","nl":false,"rap":true,"rh":0,"x":390,"y":1820,"wires":[["6fb9b1fa.e3e9a","7f1002d3.21145c","7d2b290.61cfcd8"]]},{"id":"698c33fb.3193cc","type":"debug","z":"c74b932.e47c17","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1050,"y":1860,"wires":[]},{"id":"682f8968.4c2698","type":"debug","z":"c74b932.e47c17","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1050,"y":1800,"wires":[]},{"id":"7f1002d3.21145c","type":"change","z":"c74b932.e47c17","name":"","rules":[{"t":"set","p":"payload[\"DS18B20-1\"].Temperature","pt":"msg","to":"","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1800,"wires":[["682f8968.4c2698"]]},{"id":"7d2b290.61cfcd8","type":"change","z":"c74b932.e47c17","name":"","rules":[{"t":"set","p":"payload[\"DS18B20-2\"].Temperature","pt":"msg","to":"","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1860,"wires":[["698c33fb.3193cc"]]},{"id":"389dd264.7716de","type":"mqtt-broker","z":"c74b932.e47c17","name":"","broker":"192.168.10.65","port":"1883","clientid":"Node-Red","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

```

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [22 September 2021 16:13 UTC](https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398/4 "2021-09-22T16:13:29Z")

</div>

Set msg.payload to the path (from Copy Path button) of the element you want.

For example  
 ![Untitled 8](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/6/062f5cfa506e5f625e925bd0d07746c385badcbd.jpeg)

---

<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: [22 September 2021 16:27 UTC](https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398/5 "2021-09-22T16:27:28Z")

</div>

Or, if you prefer, which I generally do as it seems more intuitive, is use Move rather than Set. Then it is Move msg.payload.whatever To msg.payload.

---

<div class="post-metadata">

### Author: ![Choder](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/choder/32/48464_2.png) [@Choder](https://discourse.nodered.org/u/Choder)
#### Post date: [22 September 2021 17:36 UTC](https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398/6 "2021-09-22T17:36:19Z")

</div>

I couldn't figure out the "set msg.payload"

But the "move msg.payload" worked.

Thanks for the help.

Here is the flow.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/9/79108f183cf1fbc28508522828e93d79d9cbb81a.png)

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

```auto
[{"id":"2451fec2.edb1b2","type":"mqtt in","z":"c74b932.e47c17","name":"DS18B20 Temp Sensors","topic":"tele/relaystack/SENSOR","qos":"0","datatype":"json","broker":"389dd264.7716de","nl":false,"rap":true,"rh":0,"x":350,"y":1860,"wires":[["6fb9b1fa.e3e9a","7f1002d3.21145c","7d2b290.61cfcd8"]]},{"id":"698c33fb.3193cc","type":"debug","z":"c74b932.e47c17","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":1880,"wires":[]},{"id":"682f8968.4c2698","type":"debug","z":"c74b932.e47c17","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":1840,"wires":[]},{"id":"7f1002d3.21145c","type":"change","z":"c74b932.e47c17","name":"Prob 1","rules":[{"t":"move","p":"payload[\"DS18B20-1\"].Temperature","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":1840,"wires":[["682f8968.4c2698","864641df.89983"]]},{"id":"7d2b290.61cfcd8","type":"change","z":"c74b932.e47c17","name":"Prob 2","rules":[{"t":"move","p":"payload[\"DS18B20-2\"].Temperature","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":1880,"wires":[["698c33fb.3193cc"]]},{"id":"389dd264.7716de","type":"mqtt-broker","z":"c74b932.e47c17","name":"","broker":"192.168.10.65","port":"1883","clientid":"Node-Red","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

```

I am building a pool controller with an Arduino for the sensors and relays inside the steel control panel and a raspberry pie with a built in 5 inch touch screen placed on the patio, to replace my old dated goldline pool controller.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/d/6d76898a61e69966cab320b259e03aab06edc787.jpeg)

---

<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: [22 September 2021 20:00 UTC](https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398/7 "2021-09-22T20:00:08Z")

</div>

> [@Choder](#):
>
> I couldn't figure out the "set msg.payload"

I don't know why the Set syntax is confusing. It is perfectly logical. If I said Set the volume control To 50% you would know exactly what I meant, and it would be obviously incorrect if I said Set 50% To the volume control. But if I put, in the Change node, Set msg.payload To msg.payload.some\_property then for some unfathomable reason it isn't immediately obvious and I have to think about what it means. That is why I almost always use Move.

---

<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: [6 October 2021 20:00 UTC](https://discourse.nodered.org/t/separate-two-mqtt-temperature-payloads/51398/8 "2021-10-06T20:00:17Z")

</div>

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