Limit the number of decimal places of a temp or humidity value

I just tried around a bit with openhab3 and a Shelly HT by native binding, not MQTT.
So the thing gives me a channel for the temp and a channel for the humidity.
The channels have nothing that can be configured.
I startet with the temperature channel and linked it to a new item and configured it as:
Type - Number:Temperature
Semantic Class - Measurement
Semantic Property - Temperature

The value that is shown in the items view and also in a cell of a page has an insane high number of 6 decimal places followed by the unit “°C”.
The items overview and also the log file shows that the internal value has only 1 decimal place
I also tried to “fix” it with the JS transformation giving fixed values and using toFixed(2) but this also wont help.
log: Item ‘ShellyHTSHHT1_Temperatur’ changed from 50.0 °C to 52.0 °C

Same thing with the humidity value except I set the items type to Number:Dimensionless combined with Point>Measurement. Its displayed as a value with % as unit, but also with 6 decimal places.

Any clue how I could change this?

BTW: A third temperature item with same settings linked to an MQTT thing/channel shows dynamic decimal places (ether 1 or none) depending on if there is something behind the decimal point.

On your Item:

  • Add Metadata -> State Description
  • In the field with the word Pattern, enter

for two decimal places, or


for an integer

1 Like