OH3 - Formatting label values in pages

Tags: #<Tag:0x00007efedadf0e78> #<Tag:0x00007efedadf0c98>

I’m trying to format values in the label widget, but strugging to understand how to do it or what syntax to use.

I have an oh-label-card defined as follows

image

Item is defined as

When the item value is a date it displays correctly (although I don’t fully understand why the tag shows the formatted date but not the rest of the text?).

image

When the value is UNDEF, I get that as the vallue in the label

image

How (and where) do I put in a formatting rule to catch the UNDEF and display blank (or anything else) instead?

is the item tag the corect place to format the date, or should that be done in the page label as well?

I’m competent with scripting etc., it’s the mechanics of what I need to put where, to control this formatting.

Thanks.

Jim

Please don’t post screenshots of text.

You can put in a transformation or an expression in the State Description Metadata of the Item. Or you can set the Label field with an expression on the Card configuration.

You can put in a transformation or an expression in the State Description Metadata of the Item. Or you can set the Label field with an expression on the Card configuration.

Thanks, but what is the transformation / expresison syntax?

I can’t find anything in the documentation which referrs to the syntax of this? Is there a compresensive summary anywhere of all the functions and syntax?

Jim

Please don’t post screenshots of text.

Wasn’t aware that was banned, I’ve seen it often used so was just following what I thought was best practice from others.

Noted :+1:

It’s not banned but it’s basically useless. It can’t be read without opening the image. It can’t be read on a phone at all. It can’t be found in a search. If it’s text, post the text in code fences and everyone will be happy.

1 Like

Further, it frequently can’t be read WITH opening the image.

Where can I find the function syntax? I can’t find anything in the documentation which refers to this.

Is there a comprehensive summary anywhere of all the functions and syntax, as all I’m finding is lists of the Java formatting strings (%…) and occasional mention of being able to put inline functions (e.g. for IF statements etc.) but no workable examples for explanation.

My background is in commercial applications development so I understand how these things work, I just need the summary documentation on how to get going with it.

Thanks

Jim

Scroll down to the “expressions” section.

For transformations (which you would use in the State Description metadata) see Transformations | openHAB and pay attention to and follow the link to Item and Sitemap labels.

Beyond that no docs exist. The UI stuff is based on the F7 framework so a lot of stuff can be found documented there.

Many thanks @rlkoshak

I’ve been able to work out a bit more of the syntax using those documents and have a very basic fuction working, although not quite sure how!

Work in progress and another challenge for the weekend :slight_smile:

Jim