Items file


I have temperature readings coming in on a mqtt topic that have 2 digits of precision.

Can I easily drop 1 of those digits of precision? So if 15.24 is published on the topic, would like my Cellar_Temp item to update to 15.2.

e.g. item definition

Number Cellar_Temp "Cellar Temp [%.1f]" (TempSensors) {mqtt="<[hammy:sensors/basement/winecellar/temperature:state:default"}


Formatting :wink:

I got my item (please note I crated my item via PaperUI)

Number Workstation_temperature "Office Temperatur" <temperature> (All, Office_First_Floor)

and my sitemap

Text item=Workstation_temperature label="Temp is [%.3f]"

This tells the the sitemap to display 3 digits.

" Temp is [%.3f]"

Which looks like this

1 Like

Thanks, but I am looking for something which changes the actual value, not just format its value within a UI.

Could explain really short what you try to achieve ?

This sounds like you want to change the precision of the measurement?

Yes, the sensor sends measurements with more precision than I care. I would like to just intake the values with 1 digit of precision.

Why would you want to make it less precise, when you can trim the digits?


A “dirty” way to do this would be to use an Exec transformation and call an external script that modifies the value and returns it to the item’s state…

There must be a better way, but I am not aware of it.

I think that the RegEx xformation will not work here since the state value should be a number (not a string)


1 Like

As for why, more precision than I care about causes unnecessary activity/load within my openhab.

It causes more item change events than I desire, which causes more database activity than I need, and more rule triggering than is desirable.

Hi @craigh

Why not introducing a helper item with full precision; then a rule reduces the precision (some math :slight_smile: ) and updates the real thing (if really changed).

with kind regards,

1 Like

… which ultimately creates more “activity/load” than just staying with the higher precision. So @craigh I have to repeat the question:

“more item change events than I desire” - so what?
“more database activity than I need and more rule triggering” - fair point.

Hence I would go with @patrik_gfeller solution. Here’s an untested idea:

rule "reduce precision"
    Item Cellar_Temp_raw changed
    Callar_Temp = round(Cellar_Temp_raw.state, 1)