Number formatting in main UI differs from item config

Hi,

I guess, this might have been solved somewhere, but I did not find it yet.

Main UI is not formatting the numbers as I thought it would based on my item configuration.

Number:Temperature      WP_Measured_DomesticWaterTemp                       "Warmwassertemperatur [%.1f %unit%]"    <temperature>   (p_rrd4j)   {channel="modbus:data:Waterkotte:r913:reg913:number", unit="°C"}

If I get this right, I would expect numbers to be formatted with one decimal place potentially including rounding. So, from a number like 54.76839, it would expect it to be displayed as 54.8.

However, it gets displayed with all its decimal places:

image

In the developer sidebar, when displaying =items.WP_Measured_DomesticWaterTemp, it shows

{ "state": "54.76839 °C", "numericState": 54.76839, "unit": "°C", "type": "Quantity" } 

There is no displayState as with some other items.

How can I have the formatting rule from the item configuration apply to the display in main UI? Did I miss something?

Best regards

Marco

EDIT:

NOT using %unit% to dynamically add the items unit, but hard code in the item config like the following results in Main UI displaying the value as I desire

Number:Temperature      WP_Measured_DomesticWaterTemp                       "Warmwassertemperatur [%.1f °C]"    <temperature>   (p_rrd4j)   {channel="modbus:data:Waterkotte:r913:reg913:number", unit="°C"}

Also, this populates the item object with the displayState property:

{ "state": "54.63889 °C", "displayState": "54.6 °C", "numericState": 54.63889, "unit": "°C", "type": "Quantity" } 

Is this a bug in parsing the item configuration or does it work as designed and I should refrain from using %unit% in the first place? I took that %unit% idea from here and thought that this was a smart idea.

Best regards

Marco

I think if you’re using Quantity/UoM-Format (Temperature) in your Item-Description, you don’t need the “unit=°C”, as this should be “Standard”.

Have you tried this way of formatting ?

Number:Temperature          airquality_02_temperature       "LQ Sensor Nr.02 Temperatur "              <snzb02>                (gairquality_02,gRtIstI)   ["Temperature","Measurement"]        { channel="mqtt:topic:danny:airqual02:temperature", stateDescription="pattern" [pattern="%.1f %unit%"] }         

Then try the following in the Developers-Sidebar

=items.WP_Measured_DomesticWaterTemp.displayState

again.

Hi @fibu-freak ,
yes, that did the trick. Thanks!

Marco