Having temperature only display 2 digits after the ,

Hello all,

I have a temperature sensor that post its value to a mqqtt topic but with 6 digits after the ,
How do i make openhab3 display the number with just 2 digits after the , ?


add a state description in the meta data of the item, use pattern:

%.2f %unit%

Thanks man, it is working now.


Jando, you beat me to posting this question!
I have been struggling for a bit trying to do the same thing, only display 2 decimal places.
However the solution is not working for me. I have set the State Description pattern to:

%.2f %°C%

But this is the result, it is not doing two decimal places. Same display if I call this item in a wiget I am working on it has many, many decimal places… Any suggestions?


On the page you posted a screenshot of.
Click on metadata>stateDescription then put the “%.2f %°C%” in Pattern.


Edit: sorry miss read, you already have that.
Edit2: you have “%.2f %°C%” but you need “%.2f %unit%”
I just treid it with just "%.2f "witch also works for me.

If you’re explicitly specifying the unit, try:

%.2f °C

The %unit% bit is only if you have explicitly given your number a Unit of Measurement.

I did use the “Unit of Measurement” in the channel, but if i use just “%.2f” on pattern, it also works


Sure, my post was a reply to @Craigers.

The following will work for any number:

%.2f °C

The following will work if your number has a unit of measurement:

%.2f %unit%

The following will never work

%.2f %°C%
1 Like

I appreciate the help from all of you, but still no luck.

I have tried both:


%.2f °C

However the decimal places does not change. I set my themostat up as “Create Equipment from Thing” using Settings->Model. Could this have anything to do with how the item is linked/set up?


Can you show us the State Description configuration for this Item?

And have you refreshed (F5) the page recently?

Note that state presentation means what it says, it does not modify the raw state of the Item (which you may continue to see in admin parts of MainUI) but should be used for your widgets display.

This is the StateDescription page:

And here is the value displayed on a very simple widget:


So… I deleted the item and recreated it using a manual item definition, and linked this to the Actual Temperature channel:

Number    EcobeeThermostat_ActualTemperature   "Temperature [%.1f °C]"

It now displays with 1 decimal place instead of many.
This works for now, but still does not resolve/explain why the StateDescription is not displaying with x number of decimal places.


And unrelated with one issue which is not part of this thread, the actual temperature is now displayed in Fahrenheit instead of Celcius.

Maybe you’ve linked a plain Number type Item to a number:temperature channel; you can force such mismatches with file based configuring, and it breaks the auto conversion from device data.

Perfect explanation @rossko57. I recreated again and it now reads shows the value as Celcius:

Number:Temperature    EcobeeThermostat_ActualTemperature   "Temperature [%.1f °C]"

Thanks for all your help.


And I was wrong, this manual configuration did not work. Since “fixing” it to be a Temperature number, the long trail of decimal places is still present…


I saw in another thread to use .displayState instead of .state.

Did a revert to the original item definition (not a manually defined item). But also schanged the semantic classifications to temperature realted.
This is displaying two decimal places on my widget now.


Thanks for explaining the working.