MQTT decimal value

  • Platform information:
    • Hardware: Docker container on Synology
    • openHAB version:3.3.0

Hi,
I have a Raspberry pi with a temperure bricklet from Tinkerforge connected via USB.
I can send a mqtt string value ( {“temperature”: 2702} ) from the PI to the Synology mqtt brocker and to the generic mqtt OH3 binding.
Added a channel and linked it and add a JSONPath expression $.temperature to see only the 2702 value instead of {“temperature”: 2702}.

As you can see in the example i get the value 2702.

I would like to see 27,02 °C instead.

I tried to add %.2f °C in the state formatter without success.
I get {“temperature”: 2702} as a result…

What state formatter expression do i have to use to see 27,02 °C ?

Thanks

Patrick

Instead of using a profile in the channel link, you should use incoming value transformation in the Thing channel. Then you would chain JSONPATH to extract the json with a JS transform to divide by 100. Something like this JSONPATH:$.temperature∩JS:|parseFloat(input)/100

If you want to stick with how you’re doing it now, you can use a JS transformation with inline script. In the JS script filename, just use the inline syntax |JSON.parse(input).temperature / 100

In addition to what JimT has written I would use a numeric item for the numeric channel and not a string item.