MQTT JSONPATH help with transformation to extract Temperature please

  • Platform information: PI3
    • openHAB version:2.5.7-1
  • Issue of the topic: Trying to extract temperature from MQTT using PaperUI interface and JSONPATH Transformation.

As per pic I can see the full SENSOR MQTT string being returned on control page of Paper UI, but can’t for the life of me figure out syntax to get just temperature reading presented. I did try mqtt.things file but no joy.Using a Wifi8266 with Tasmota and DHT11 sensor attached.

MQTT broker is mqtt:systemBroker:MQTT2Thingbroker

Wifi8266 is labeled Tasmota_87_26-2 mqtt:topic:9e5040d6 showing as online.
I created a channel called Temperature1 - mqtt:topic:9e504d6:9e50406:Temperature1 type is String
Incoming Transformation Value set to JSONPATH:$.temperature
I have tried numerous variants on this including “JSONPATH:$.tele/tasmota_0D354A/SENSOR.DHT11.temperature” etc etc

Temperature1 is linked to Temperature-N (Tasmota_87_26_Temperature) type is Number.
Also did try type as String which is when I get the full SENSOR output being displayed including Temperature.

Please someone put me out of my misery :slight_smile:

I’m assuming it is possible to do this all via PaperUI and I don’t have to use txt files, was going to move towards those once I got this working in any case.

Example JSONPATH (it doesn’t matter that it’s used for a different binding there)

What sensor do you have configured in Tasmota Module Configuration? I use a DHT22 with Tasmota, and extract the temperature with the following:


EDIT: Apologies, I can see the full string in the screenshot now. You would probably want:


Thanks for that, I have revised as suggested but still see full string of array;

Config shown here:

Any other idea’s or things I’m missing?

Legend thanks for clarity is was:

Setting in Incoming Value Transformations
exact code was:

Thanks again!

Well done on getting it working! For completeness, when/if you do move over to using files, the syntax I showed is the correct one for your eventual temperature channel.

Thanks, unfortunately in "tidying the Paper UI I’ve managed to kill in again…everytime I add the JSONPATH($.DHT11.Temperature) to the Thing it gives the
“Error - offline message” if I put “JSONPATH($.DHT11.Temperature)” I get the full string back with Temperature and everything…
One question, when you link a thing to an item I see there is a transformation code component there which has JSON path Transformation and a example with $.device.status.temperature is the what I should have in there and be using the JSON transformation or is this where I’ve messed up perhaps?

Is this in PaperUI, or do you mean the example I linked? I don’t use PaperUI, so couldn’t help in afraid!

In general, though, for this situation:

  1. Your Thing defines the device
  2. Your Thing Channel points to the temperature sensor, and does the JSONPATH transformation.
  3. Your Item points to the Thing Channel. No transformations required at the Item level.

Sorted just had used $.device.status.temperature as per the example however it needs to be a capital T in temperature so changing to $.device.Temperature did the trick. Thanks for the support!

Maybe interesting for others with similar problems for a tasmota device with a SI7021 sensor attached.
This is the working setup for MQTT.
I am just one step ahead and trying to include the same device using “setoption19 1” to get the automatic detection up and running. After setting this command this is shown and detected as a homeassistant device and of course I am struggling to get the sensors working:-)
I just opened another topic for this issue.

works now, for others maybe interesting when using a TH03 with a SI7021 sensor

Switch TH03 {channel=“mqtt:topic:5f4a663f:TH03”}
Number TH03TEMP {channel=“mqtt:topic:5f4a663f:TH03Temp”}
Number TH03HUM {channel=“mqtt:topic:5f4a663f:TH03Hum”}

Sitemap for the sensors:
Text item=TH03TEMP label=“TH03Temp [%.1f °C]” icon=“temperature”
Text item=TH03HUM label=“TH03Hum [%.1f %% ]” icon=“humidity”

and this is the example for the humidity channel: