Item decimal places

Hi,

I am not able to set the count of the decimal places to 0.

In the item definition is [%.0f], in the items overview in the openhab settings is it ok, but when I use the item in a widget as Label, there a often a lot of numbers.

uid: my_energy_balance_widget
tags: []
props:
  parameters:
    - context: item
      description: Item für Leistung Erzeugung (z. B. Number:Power)
      label: Item Erzeugung
      name: itemGen
      required: true
      type: TEXT
    - context: item
      description: Item für Leistung Verbrauch (z. B. Number:Power)
      label: Item Verbrauch
      name: itemCons
      required: true
      type: TEXT
    - context: item
      description: Item für Leistung Zähler
      label: Item Zähler
      name: itemCnt
      required: true
      type: TEXT
timestamp: Jan 9, 2026, 12:45:42 PM
component: f7-card
config:
  style:
    border-radius: var(--f7-card-expandable-border-radius)
    box-shadow: 5px 5px 10px 1px rgba(0,0,0,0.1)
    height: 120px
    margin-left: 5px
    margin-right: 5px
    noShadow: false
slots:
  default:
    - component: f7-row
      config:
        no-gap: true
        style:
          align-items: center
          height: 15%
          justify-content: space-around
      slots:
        default:
          - component: f7-col
            config:
              style:
                align-items: center
                display: flex
                gap: 6px
                justify-content: center
                width: 50%
            slots:
              default:
                - component: oh-icon
                  config:
                    height: 20
                    icon: material:electrical_services
                    style: {}
                    width: 20
                - component: Label
                  config:
                    style:
                      color: "#f39c12"
                      font-size: 1em
                      font-weight: 600
                    text: Verbrauch
          - component: f7-col
            config:
              style:
                align-items: center
                display: flex
                gap: 6px
                justify-content: center
                width: 50%
            slots:
              default:
                - component: oh-icon
                  config:
                    height: 20
                    icon: material:wb_sunny
                    style: {}
                    width: 20
                - component: Label
                  config:
                    style:
                      color: "#2ecc71"
                      font-size: 1em
                      font-weight: 600
                    text: Erzeugung
    - component: f7-row
      config:
        no-gap: true
        style:
          align-items: center
          height: 65%
      slots:
        default:
          - component: f7-col
            config:
              style:
                align-items: center
                display: flex
                justify-content: center
                padding-left: 1px
                padding-right: 1px
                width: 50%
            slots:
              default:
                - component: oh-gauge
                  config:
                    bgColor: transparent
                    borderBgColor: rgb(224,224,224)
                    borderColor: "#f39c12"
                    borderWidth: 14
                    item: =props.itemCons
                    labelText: ""
                    labelTextColor: "#f39c12"
                    max: "2000"
                    min: "0"
                    size: 150
                    type: semicircle
                    unit: ""
                    valueTextColor: "#f39c12"
          - component: f7-col
            config:
              style:
                align-items: center
                display: flex
                justify-content: center
                padding-left: 2px
                padding-right: 2px
                width: 50%
            slots:
              default:
                - component: oh-gauge
                  config:
                    bgColor: transparent
                    borderBgColor: rgb(224,224,224)
                    borderColor: "#2ecc71"
                    borderWidth: 14
                    item: =props.itemGen
                    labelText: ""
                    labelTextColor: "#2ecc71"
                    max: "800"
                    min: "0"
                    size: 150
                    type: semicircle
                    unit: ""
                    valueText: ""
                    valueTextColor: "#2ecc71"
    - component: f7-row
      config:
        style:
          height: 10%
      slots:
        default:
          - component: f7-col
            config:
              width: 100
            slots:
              default:
                - component: Label
                  config:
                    style:
                      color: '=(items[props.itemCnt].state <= 0) ? "green" : "red"'
                      font-size: 1.2em
                      text-align: center
                    text: = 'Netzbezug ' + items.HouseActualCounter.state


items.item_name.state will always return the true state of the Item. You want the state that has already been transformed by your stateDescription. In widget expressions, this is accessed using .displayState instead of just plain .state.

There is an extra wrinkle where the displayState property doesn’t exist if it is equal to the state so you need to safely handle that case. Fortunately, in widget expressions this has been built in for you if you just use the shortcut @. So, you want:

text: = 'Netzbezug ' + @"HouseActualCounter"

It works with both solutions, thank you.

Last question according the @, is it possible to set the item from the properties with @ (items[props.itemCnt)?

The @ must be followed by a string of an item name. That’s why when you have a static item name as in your example, you have to put those characters inside quotes to indicate that is the exact string you want.

If you have a widget parameter with an item name that you access through the props object, then that item name is already in a string format so you don’t need the quotes, you would just do @props.itemCnt.