Reading the Label of a set item

Hi,
I just couldnt find the way how to read a item’s label, which was declared in the setting menu of the widget.
Just my simple test:

<style>
img.icon {
    height: 70px;
}
</style>
<div><h3>{{item.label}}</h3></div> config.item.label?? Here is my problem
<!--<div><h3>{{itemValue(config.item)}}</h3></div>-->
<div>
<img class="icon" ng-src="{{itemValue(config.item) == 'ON' && '/static/fotos/lampege.png' || '/static/fotos/lampewe.png'}}"/>
</div>

It might be a very simple thing, but I just couldnt find the answer in the web today. What is the way to read the items label or name, which is declared through the settings menu of the widget?
Thanks for your help in advance.

do this:

<pre>
{{config | json }}
</pre>

and you’ll be able to see all the exposed properties of the config object.

1 Like

@oeo like you I’ve been struggling to find out how to pickup the value of the Label variable using a custom widget and never found a good answer via Google or community.openhab; after stumbling onto a random post about someone asking about having the category shown on their custom widget did I finally piece together the way things need to be formatted for the item label to display on the custom widget!

       <div>{{getItem(config.myVARname).label}}</div> 
       <div>{{getItem(config.myVARname) | json}}</div>    

myVARname of course being the name you supply in the setting of the custom widget; hopefully anyone else looking for this info can save some time with their life! The second line is just to display the entire contents of the item in question and is more for troubleshooting purposes.

Forum posting that solved it for me - Access item category in custom widget

2 Likes

Very nice information. Thanks for completing this thread. :wink: