How to read metadata in widget

Hello openHAB Community :wave:,

as an openHAB newbie I tried to read an item’s metadata in a Label Card Widget.

I tried the following:

component: oh-label-card
  item: NewItem
  label: =items['NewItem'].metadata.example
slots: null

I’ve created the custom metadata namespace example with the value of test. It also does work with the JavaScript Binding via items.getItem('NewItem').getMetadata('example').value.

The above snippet results in the following error:

TypeError: Cannot read properties of undefined (reading ‘example’)

Am I missing something? Any ideas?

Metadata is not directly accessible, you can retrieve it from a oh-repeater.

1 Like

Thanks, that works.