Transform/Display item states on Pages

Tags: #<Tag:0x00007fc8fa379400> #<Tag:0x00007fc8fa379310>


How to transform and display an item state on pages?
I want to display the presence state as “Present/Not Present” instead of “ON/OFF”.

In Openhab 2 I would do the following:


Switch Presence_Ralf "Ralf [MAP(]"  { channel="XXX:online" }


Text item=Presence_Ralf

Over here in Chapter 8 “Expressions” are mentioned. How could expressions be used for this usecase?
I’m also interested how to achieve the same in the default auto-generated page “Home Page”. I do not see any option to change the item label. Is there an option to make this configuration on item level?

You can continue to use the Map by editing the State Description metadata on the Item. That will use the map to transform the state prior to display.

Or, if you want to use an expression it would look something like:

=(items.Presence_Ralf.state == "ON") ? "Present" : "Not Present"

You can put an expression like that in most of the fields I think.

I use it in lists to define a badge instead of just showing the Item’s state.

Anywhere an Item has a widget that is automatically shown, you can define everything about that default widget by editing the “default x widget” Item metadata on the Item.

That was the trick! Thank you.


As i searched here but (for me) it was “only” 90% of the final solution:

The expression


instead of


will show “Present” or “Not Present” instead of “ON” and “OFF” when you used State Description metadata on the Item.