OH3 Widget temperature rounding error

Hello together,

I am facing some issue in the widget that I found here in the forum with rounding the value of temperature:

item definition for the SetPoint looks like

Number:Temperature    SollTemp_Flur                   "Soll Flur EG [%.1f °C]"                   <temperature>      (gCorridorThermostat, gTemperature)           ["Setpoint", "Temperature"]        {channel="knx:device:MDT_IP:MDT_HS8:SollTemp_Flur"}

Any idea how to fix that?

Thanks in advance.

ceers!

This definition of the item only formats the number whenever that particular item label is used (which is not as much as it used to be). In order to get that same formatting in the widget there are several possible solutions. Perhaps one of the easiest is just these two simple steps:

  1. Add that formatting pattern to the stateDescription metadata of the item: Click on the add metadata link in the item page for this item and select State Description from the options menu that pops up.
    .
    Add the formatting pattern (or a different one if you prefer) to the pattern text box and save. This will also change the format of the number in the default pages where OH displays this item’s state.
  2. In the widget code change any of the instances of .state for your temperature item to .displayState

Thanks for the explanation.

I use VS Code for items definition, is there a possibility to add this metadata settings in the item definition in VS code?

In the widget is the following code used

text: =items[props.setPointItem].state.split(' ')[0]

If I change it to

text: =items[props.setPointItem].displayState.split(' ')[0]

It doesn´t work and I receive a syntax error.

This issue is only accrue when the temperature value change to something like xx,4 otherwise it looks fine…

Yes. See the State Description topic here.

Hi @snowy

it’s better you use the topic of the orginal widget.
There is a better place for your question.

By the way: You should use the newest version of the widget. -> v1.8.1

Look here:

Cheers,

Nico

Okay, thanks…

I have changed all my items an add the metadata, but did not solve the issue.

Number:Temperature    SollTemp_Bad                   "Soll Bad [%.1f °C]"                       <temperature>      (gBadOGThermostat, gTemperature)           ["Setpoint", "Temperature"]       {channel="knx:device:MDT_IP:MDT_HS4:SollTemp_Bad", stateDescription=""[pattern="%.1f °C"]}

Thanks a lot Nico :-)…
Very appreciate your great work!

I will have a look in the new version. I did some minor changes, due to I used this widget with (don`t know how to say it in English) “Sollwertverschiebung” over 1 Byte object in my KNX setup.

Solution: