Display of formatted number in Widget

Hi all,

unfortunately another beginner question (openhab 3) which should be just easy to answer:

  • The item is defined as number only (no unit)
  • In the Item definition, the State definition → Pattern is defined as %.0f
  • In Model + Items, the real value shows absolute correctly with the desired formatting
  • In the widgets, as well as in the own definition of a widget, always all the decimals are shown.

How can the applied Pattern be used in widgets?

I know, I can get rid of it in the widget by rounding the value, however that is not a good solution since we have the item definition.
In my own widget yaml, I use

=items[props.item2].state

first I thought I use the wrong property, but since also the other widgets show the same behaviour I’m a bit confused.

One solution would be to define own widgets for everything, but thats not the reason I have choosen Openhab :slight_smile:

Any help is appreciated


Try

=items[props.item2].displayState

That and some more helpful hints are covered here:

Note especially at the bottom of that section that you can use a special shortcut for items[props.item2].displayState and just put @props.item2 instead (if you’re on at least OH 3.4).

Many thanks, that did the trick !