State description pattern issue

hello to all!
after some days of tries with different solutions reported on the forum, i’ve decided to write here because i can’t understand what’s happening.
i have an item created in UI with its energy consumption value calculated from a rule.
i’ve set metadata/state description/pattern as:

%.3f kWh

to show only 3 decimal digits, and enabled “Readonly” button.
the result is this one:

why?!

then i’ve added the same item in UI label card, and also there is shown in this way:

i just would like to see the value for this item cut with 3 or 4 decimals, because when i see the UI from mobile, this number takes 2 lines :frowning:

the strange thing is, that another item based on month calculation instead of the day, when i set the pattern, seems to work (but ONLY in items menu view and NOT in UI).

my goal is just to have those values shown correcly in UI…

thanks to all!

What are you using to display the state? item.displayState should show the formatted value while item.state should show the full value as I understand it.

thanks for the reply!
where can i set the displayState option?

You would have to edit the YAML code of your UI Label Card.

oh yes got it! many thanks! i’ve been on this from 2 weeks! :rage:

really really thanks! and also today learnt another thing!!

The Item you have shown us is a Number:ElectricCurrent type. Current has units of Amps, A ,not kWh

This is quite likely to mess up with displays, calculations, charting etc. and may be half your troubles.

Number:Energy can be measured in kWh

noted, and corrected everywhere.

thanks a lot @rossko57 !

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.