Main UI cuts x.0 values to x


I want to see a number:temperature value always with 1 comma…e.g. 17.1 °C.
Works, but not if the value is 17.0, then I see 17 °C.

Played around with state description pattern %.1f, but main ui cuts always the .0 part.

This is my label-card yaml:

component: oh-label-card
  action: options
  actionItem: heizungZimmerLaraVentil_Set_Temperature
  actionOptions: 15,16,17,18,19,20,21,22,23,24
  fontSize: "12"
  icon: oh:temperature
  item: heizungZimmerLaraVentil_Actual_Temperature
  label: '=("Lara Ist: " + items.heizungZimmerLaraVentil_Actual_Temperature.state
    + " / Soll: " + items.heizungZimmerLaraVentil_Set_Temperature.state)  '
  stylesheet: |
    .item-content {
       padding: 0;

And this I see:

Thx and br

If you have an item with a state description metadata and you want to see the formatted state in a widget then you have to use item.displayState instead of item.state. Even better, because of the way the UI gets data from the server displayState will occasionally be empty if it is the same as the state so there’s a short cut to make sure you get the display state with a fall back to the regular state: the @ sign.


That seems like a bug? Is this intentional and is there a reasoning to make it behave this way?

This is neat, but “esoteric” to a casual observer. It wouldn’t have been necessary if displayState didn’t have the “strange” behaviour above.

No, it’s very much an intentional choice to optimize the UI performance. There’s no need to send completely redundant between the server and client when a perfectly reasonable client-side solution exists.

Shouldn’t be too esoteric…it’s right in the docs in the introduction to widget expressions:

The @ symbol can be used in front of an item name string as a shortcut to the displayState from the items dictionary with a fallback to the raw state:

footer: =@'Switch1'

is the same as

footer: =items['Switch1'].displayState || items['Switch1'].state

Similarly, @@ can be used as a shortcut for just the item state.