[SOLVED] Extact partial data from MQTT

I’m want to extract humidity data out form my Sonoff Tasmota mqtt message.
log shows that openhab received the data correctly:

2018-12-15 15:24:35.901 [vent.ItemStateChangedEvent] - Sonoff1 changed from {“Time”:“2018-12-15T14:21:52”,“SI7021”:{“Temperature”:13.2,“Humidity”:56.6},“TempUnit”:“C”} to ON

I’m only interested to get humidity out from that block. How is it done? Thanks.

Please post your item definition

String Sonoff1 "Sonoff1" {mqtt="<[broker:tele/sonoff/SENSOR/Temperature:state:default]"}

Here is the temperature part but the idea is the same

Use the JSON transformation like in the example below.

Number LivingRoom_Light_Temp "Living Room Temp [%.1f °F]" <temperature> ["CurrentTemperature"]
	{ mqtt="<[pibroker:tele/sonoff11/SENSOR:state:JSONPATH($.SI7021.Temperature)]" }

Also make sure you have the transformation service installed via PaperUI.

What your item should look like for temp.

Number Sonoff1 "Sonoff1 [%.1f °C]" { mqtt="<[broker:tele/sonoff/SENSOR:state:JSONPATH($.SI7021.Temperature)]" } 

For Humidity:

Number Sonoff1 "Sonoff1 [%.1f %%]" { mqtt="<[broker:tele/sonoff/SENSOR:state:JSONPATH($.SI7021.Humidity)]" } 
1 Like

Beat me to it!!

@vzorglub There’s a first for everything.:rofl:

I am trying to keep an eye on the forum whilst going through fractions homework with my 9 year old…
Can’t do everything

1 Like

Thanks guys, it’s working now- you saved me quite some googling time.
now I just need to figure out how to present those values in habpanel.

Glad you got it working.:+1:

Do a search on the forum, you’ll find plenty of good examples, for habpanel.

Please mark the post as solved by clicking the square box (lower right corner) on the post that provided the solution. Also edit your title to start with [Solved] this will help others with a similar issue find a quick solution.

Thanks

ok, it was easy to show it on habpanel. I had overlooked the dummy widget.
Cheers.