How to get number from string mqtt tag?

Hi,
how can I get temperature data from string tag (temperature:100). I need temperature in celsius.
Thanks for the answer.
Zajeta slika

Just for clarification, you're able to get the value {"id":100, "tC":24.1, "tF":75.4}, but it's a string?

...or are you having trouble reading the tag itself?

That's right I get the value but it's string.

I put your displayed value into a string tag, and I was able to bind the desired value with the following expression:

jsonGet({[Sample_Tags]Writeable/temperature:100}, "tC")

Obviously, you'll have to replace {[Sample_Tags]Writeable/temperature:100} with your tag path, but otherwise jsonGet should work.
image

Result:
image
image

2 Likes

If you need this via script, I was able to get the Celsius value in the following way:

temperatureTagValue = system.tag.readBlocking(["[Sample_Tags]Writeable/temperature:100"])[0].value
temperatureData = system.util.jsonDecode(temperatureTagValue)
celsiusValue =  temperatureData["tC"]
3 Likes

Consider a derived tag with jsonGet and jsonSet if you want bidirectional support.

2 Likes