# Accessing Temperature property in payload (DS18B20 - Tasmota - MQTT)

**URL:** <https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913>\
**Category:** General\
**Created:** [29 April 2021 07:05 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913 "2021-04-29T07:05:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolf6660](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wolf6660/32/40964_2.png) [@Wolf6660](https://discourse.nodered.org/u/Wolf6660)\
**Post date:** [29 April 2021 07:05 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/1 "2021-04-29T07:05:11Z")

</div>

Hi,

I am a newbie and want to bring my temperature from the ESP8266 to NodeRed.

This is my Payload:  
payload: "{"Time":"2021-04-29T07:48:11","DS18B20-1":{"Id":"3C01D60745B0","Temperature":42.9},"DS18B20-2":{"Id":"3C01D607558B","Temperature":35.5},"DS18B20-3":{"Id":"3C01D607C8F9","Temperature":35.9},"DS18B20-4":{"Id":"3C01D607DBB3","Temperature":27.9},"TempUnit":"C"}"

I need the temperature of the individual sensors. Who can I split this?

thanks

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [29 April 2021 07:12 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/2 "2021-04-29T07:12:05Z")

</div>

Not sure if that is a json string or a object, Have you set the mqtt node to output an object. If you do then the temps will be available at  
`msg.payload.DS18B20-1.Temperature`  
`msg.payload.DS18B20-2.Temperature`  
etc

---

<div class="post-metadata">

**Author:** ![Wolf6660](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wolf6660/32/40964_2.png) [@Wolf6660](https://discourse.nodered.org/u/Wolf6660)\
**Post date:** [29 April 2021 07:55 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/3 "2021-04-29T07:55:51Z")

</div>

yes it is an Object

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/9/7976b18169063df990d85da2d4eb186f63c3a8f2.jpeg)

Which node do I have to take

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [29 April 2021 08:25 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/4 "2021-04-29T08:25:30Z")

</div>

The split node is for splitting and it works for your case with default configuration. It makes multiple messages from that single object and sends all of them downstream. Then you can send every individual message to the separated branch of flow if needed.

Here is an example

```auto
[{"id":"86eb867f.fdaa38","type":"function","z":"c9512783.9493c8","name":"DATA","func":"msg.payload = {\"Time\":\"2021-04-29T11:11:37\",\"DS18B20-1\":{\"Id\":\"0417C3DCF9FF\",\"Temperature\":23.8},\"DS18B20-2\":{\"Id\":\"0417C43F83FF\",\"Temperature\":25.4},\"DS18B20-3\":{\"Id\":\"0517C458DEFF\",\"Temperature\":26.8},\"DS18B20-4\":{\"Id\":\"9C9D8D116461\",\"Temperature\":25.1},\"TempUnit\":\"C\"}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":380,"wires":[["f7ce04bb.e41528"]]},{"id":"bda6c376.ef5dd","type":"inject","z":"c9512783.9493c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":380,"wires":[["86eb867f.fdaa38"]]},{"id":"ac095bc6.147bc8","type":"debug","z":"c9512783.9493c8","name":"SPLITTED","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":340,"wires":[]},{"id":"f7ce04bb.e41528","type":"split","z":"c9512783.9493c8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":430,"y":380,"wires":[["ac095bc6.147bc8","f66474c3.1d8b38"]]},{"id":"f66474c3.1d8b38","type":"switch","z":"c9512783.9493c8","name":"","property":"topic","propertyType":"msg","rules":[{"t":"cont","v":"-1","vt":"str"},{"t":"cont","v":"-2","vt":"str"},{"t":"cont","v":"-3","vt":"str"},{"t":"cont","v":"-4","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":590,"y":420,"wires":[["6e7f9496.dad8ec"],["dad0e90b.c06558"],["3c44289f.6f7a58"],["38fd87bd.996d48"]]},{"id":"6e7f9496.dad8ec","type":"debug","z":"c9512783.9493c8","name":"D - 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":400,"wires":[]},{"id":"dad0e90b.c06558","type":"debug","z":"c9512783.9493c8","name":"D - 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":440,"wires":[]},{"id":"3c44289f.6f7a58","type":"debug","z":"c9512783.9493c8","name":"D - 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":480,"wires":[]},{"id":"38fd87bd.996d48","type":"debug","z":"c9512783.9493c8","name":"D - 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":520,"wires":[]}]

```

I configured the split node to copy the key of object to the msg.topic so the routing can be done more easily then.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/b/cbb02f4d3887904581ac696de1b3a1edbac7dbe3.png)

---

<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:** [29 April 2021 08:37 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/5 "2021-04-29T08:37:58Z")

</div>

> [@Wolf6660](#):
>
> yes it is an Object

No, your payload is a `string` - that is evident by the value starting with a `"` .

To be more precise, it is a JSON string.

If you set the mqtt node to parse that to an object you can easily access the values within...

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)

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [29 April 2021 08:45 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/6 "2021-04-29T08:45:03Z")

</div>

> [@Steve-Mcl](#):
>
> No, your payload is a `string`

Sorry, my mistake to not notice that.... 😳

---

<div class="post-metadata">

**Author:** ![Wolf6660](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wolf6660/32/40964_2.png) [@Wolf6660](https://discourse.nodered.org/u/Wolf6660)\
**Post date:** [29 April 2021 10:51 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/7 "2021-04-29T10:51:12Z")

</div>

I've got a solution:  
return {payload: msg.payload ["DS18B20-1"]. Temperatur};  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/5/a5bfdb1686b29f799cc90114b4c6b07194afae03.png)

Thanks

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [29 April 2021 12:38 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/8 "2021-04-29T12:38:40Z")

</div>

No it's a json string. as the text is all red in the image.

As said before set the mqtt node to output a js object.

> [@Wolf6660](#):
>
> I've got a solution:  
> return {payload: msg.payload ["DS18B20-1"]. Temperatur};  
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/5/a5bfdb1686b29f799cc90114b4c6b07194afae03.png)

Is that not what i said in post 2?

---

<div class="post-metadata">

**Author:** ![Wolf6660](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wolf6660/32/40964_2.png) [@Wolf6660](https://discourse.nodered.org/u/Wolf6660)\
**Post date:** [29 April 2021 12:51 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/9 "2021-04-29T12:51:20Z")

</div>

es funktioniert

thanks

---

<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:** [13 May 2021 12:51 UTC](https://discourse.nodered.org/t/accessing-temperature-property-in-payload-ds18b20-tasmota-mqtt/44913/10 "2021-05-13T12:51:22Z")

</div>

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