Round number in page view (oh-cell)

Is it possible to round numbers in oh-cells or should it be done on the item before inserting it into the cell? I want to the items in the log-snippet below, but it would be nice if I could round it to less digits before presenting it in the oh-cell.

2024-02-06 19:00:00.067 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item ‘Energi_Data_Service’ changed from 1.283440002 DEF/kWh to 1.277470001 DEF/kWh through Energi_Data_Service_Spot_Price

2024-02-06 19:00:00.085 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item ‘Energi_Data_Service’ changed from 1.283440002 DEF/kWh to 1.277470001 DEF/kWh through Energi_Data_Service_Grid_Tariff

This. That’s what the State Description Item metadata is for. See Items | openHAB for how to format the state. You’ll put what you see inside the for the State Description Pattern.

But…

Yes it is. You can use expressions to manipulate the state of the Item before it’s shown in a custom widget.

“State description” was the keyword i needed. I am not sure that I did it how you suggested, but I have added “State description” metadata to the items I was working with. Now I am able to control the rounding and the unit type of the items I am using in OH-cells. It works how I was hoping, so now I just hope I did what you suggested me to do. :slight_smile:

Thanks for your help.

If the state description is working that’s how it should work.

But if you you ever run into a situation where you want one widget to show more than one Item’s state, or show the combination of an Item’s state, or radically transform an Item’s state you have expressions.

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