Format Item Values


I have an item which comes in seconds and I would like to display this in hours (2 decimal digits). I have googled and searched a bit and found that item transformations might be able to do that. I have therefore done a

Math.round(%d/60/60) h

in the Item Metadata (State description). When I use the value in a page, I can see that the rounding is not properly done (left part of the image). However, when I wait ~2 mins, the value is displayed as I intended (right part of the image):

I am wondering why the display switches after a few minutes and what I can do to always have the intended formatting.


  • Platform information:
    • Hardware: Raspberry Pi
    • OS:Raspian
    • Java Runtime Environment: openJre17
    • openHAB version: 4.0.3

Did this happen only once and the display is correct now?

I found that changes in the state description are only processed after the item receives another event. But then the format should stay correct.

@apas_csc is correct, the way the Item appears will not change after changing the state description until after the Item updates again.

If you use a Number:Time Item, you can use date time formatting to create HH:MM:SS formatting to format the value without a transformation.

For example, a Number:Time Item with a state of 1959 s with a State Description Pattern of %1$tH:%1$tM:%1$tS shows

There is a limitation though in it only really supports up to 31 days if you need to show days.

Wow, thanks - this works like a charm :slight_smile: Thanks for your timely responses.