OH3 - How to get Label text of item instead of name

In a widget, how can I get the Label text of the item instead of the item Name? For example in a component like this:

- component: Label
        text: =props.myItem

shows the item Name. What property gives the Label text. I’ve tried


also tried


Any solution?

You can’t get the label in the traditional way it’s defined. But I think you can set a label by setting the “State representation” metadata on the Item. Then you can use =items[props.propItem].displayState. Note, if you don’t have the metadata defined that will generate an error. So it might be good to use a ternary operation to check if that is defined and if not fall back to just show state.

I’ve used the Label field in the Item definition page to set a friendly name for my items. Is there then no way to access this from the widget?

Your recommendation then is to set a metadata value on the item? Am I understanding correctly?




1 Like

thanks… I was struggling to get the same.

As this is a very obvious need to get the item names in the UI, (we don’t want to do double entry of the name, just to feed the OH beast) I may see if I can prepare some PR to have this more easy available.

1 Like

Exactly what I think. Why the f… there is no way to access the label of an item in a widget? :man_facepalming:

not sure if it helps (at least in some cases I guess) but oh-repeater and sourceType: itemsInGroup provides you with the item’s label name by loop.repeater-id.label

I need this too.

@marcel_verpaalen Have you created the PR?

nope… unfortunately this webUI programming is not so easy digest…