MQTT JSONPath Transformation to extract values from multiple DS18B20

Hello Folks,

I am a silent reader sice few months.
My home automation is growing week by week. A lot of function I could implement by using this forum or other sources.
But now I am at a point where I need some support from an expert.

I am using a nodeMCU with tasmote FW and 3 DS18B20 Temp. Sensors.
All the sensors are connected to one GPIO.

So the MQTT topic contains all three sensors in it. All the have different temperatures to display.
An somehow I have to extract the right sensor and display it to the right value.

The topic looks like this:

{“Time”:“2019-11-04T17:35:16”,“DS18B20-1”:{“Id”:“011563F25DFF”,“Temperature”:13.8},“DS18B20-2”:{“Id”:“031674B309FF”,“Temperature”:34.6},“DS18B20-3”:{“Id”:“0416747EBDFF”,“Temperature”:43.9},“TempUnit”:“C”}

Question: How does the transformation look like that I can extract each temperature value?

Thanks a lot in advance.
BR, KarMa

First in the tasmota console do:
setoption64 1

See: https://github.com/arendst/Tasmota/wiki/Commands
This will change the - into an _ for the DS18B20s

Then the transormation is:
JSONPATH:$.DS18B20_1.Temperature
etc…

Make sure you install the JSONPATH transform!!

2 Likes

Thanks for the quick reply and the >setoption64 1
hint.
I looks like that I got also an issue with the connection from MQTT to Openhab.
Let me first solve this, than I continue witht the transformation.
Thank you!

Hi KarMa,
did you solve your issue and get it working with 3 x DS18B20.
I had it working with one sensor and the following;
transformationPattern=“JSONPATH:$.DS18B20.Temperature”
and it worked.
After vzorglub’s correction I did setoption64 1 and I now have underscores in stead of hyphens but the following only shows “-” on my sitemap.
transformationPattern=“JSONPATH:$.DS18B20_1.Temperature”

1 Like

Solved my problem. See my other thread on extracting temprature from mqtt string.
I used the sensor id rather than DS18B20_n as the numbers can change automatically if one is disconnected.