Extract temperature from an MQTT string

Sorry not tried that

But found it on here,does it work?

I think it may be as simple to circumvent as
transformationPattern="JSONPATH:$.\"DS18B20-1\".Temperature"
i.e. quote the string containing the hyphen for JSONPATH, but escape the quotes to hide them from parser.

Dumb question I know but how do I format text in a post to appear as your things, items and sitemaps do here?

Not a dumb question, because it’s not obvious unfortunately!

This post has all the details, but the big issue is that the code fence icons don’t actually show up. The buttons are still there - you can hover over them and a tooltip will appear.

In short, type three backticks, then enter your code on a newline, then end with three more backticks on a new line.

Thanks to helpful people on this forum I now have my multiple parallel DS18B20s working.
As a relative new comer I know how helpful it is to view some working code so I thought I would post my working code for anyone searching and coming across this thread.
I’ve changed the JSON transformation from that above by adding the id of each sensor rather than the DS18B20_n because I had a problem when fitting by pcb into it’s case. One sensor stopped working due to a broken wire but it was hard to determine which one because if 1 or 2 of 3 fail the other sensors are renumbered but the id is unique to each device.

thing file

Thing mqtt:topic:nodemcu1 "nodemcu1" @ "myHome/Water_Heater" {
		Channels:
			Type number : temperature "Temperature" [
				stateTopic="tele/nodemcu1/SENSOR",
				transformationPattern="JSONPATH:$.3C01A8160EFB.Temperature"
				]
				Type number : temperature2 "Temperature2" [
				stateTopic="tele/nodemcu1/SENSOR",
				transformationPattern="JSONPATH:$.3C01A8162221.Temperature"
				]
				Type number : temperature3 "Temperature3" [
				stateTopic="tele/nodemcu1/SENSOR",
				transformationPattern="JSONPATH:$.51D7FD1D64FF.Temperature"
				]
	}

item file

Number nodemcu1Temperature "nodemcu1 Temperature" { channel="mqtt:topic:nodemcu1:temperature" }
Number nodemcu1Temperature2 "nodemcu1 Temperature2" { channel="mqtt:topic:nodemcu1:temperature2" }
Number nodemcu1Temperature3 "nodemcu1 Temperature3" { channel="mqtt:topic:nodemcu1:temperature3" }

sitemap file

Frame label="Water Heater" { 
             Text       item=nodemcu1Temperature3 label="Top Temp [%.1f °C]" icon="temperature"
             Text       item=nodemcu1Temperature label="Centre Temp [%.1f °C]" icon="temperature"
             Text       item=nodemcu1Temperature2 label="Bottom Temp [%.1f °C]" icon="temperature"
                        }

This is my ClassicUI.

2 Likes

I’m curious on that change, did the received JSON string change from what you have posted above?

See post 11. Now that I know how to do it I’ve edited it to format the included code better.
The JSON string was taken before I found out about the hyphen problem but it doesn’t matter when using the id.

Hi
Going to be trying with two DS18B20 soon on a D1mini so will be trying your method ,thanks for posting the solution on here.

I am running D1 mini’s and would like to add a temperature sensor. Then send the data to OH3 via MQTT. I have a PIR attached to the D1 which I pull the input up however we are only dealing with a boolean value.

I am interested how you solved the problem, personally I would define an item for it and then push a value into mosquito and see if it is read correctly in OH3. Maybe that is a good project for to do this afternoon.

My test thing/item worked as I will only be sending one value however I can see I have a lot to learn from this post.