Skip to main content



      Home
Home » Archived » Eclipse SmartHome » Item and Channel Label is not set in UI
Item and Channel Label is not set in UI [message #1734180] Sun, 05 June 2016 13:47 Go to next message
Eclipse UserFriend
Hi!

I have a problem when creating Items during runtime and linking them to Channels of a Thing. The label declared in the ChannelType definitions is not set as the Item's label. Therefore, the label is not set in the UI, instead the Item's Name is displayed.
I have a Thing und some ChannelType definitions in the same file:

...
<channel id="temperature" typeId="temperatureChannelType"/>
...
<channel-type id="temperatureChannelType">
        <item-type>Number</item-type>
        <label>Temperature</label>
        <description>Current temperature in degrees celsius</description>
        <category>temperature</category>
        <state readOnly="true" pattern="%.1f °C" />
</channel-type>
...


In the ThingHandler's initialize() method, I create Items and link them to the Thing's channel:

...
serviceReference = bundleContext.getServiceReference(ManagedItemProvider.class);
itemProvider = bundleContext.getService(serviceReference);
itemChannelLinkRegistry = bundleContext.getService(bundleContext.getServiceReference(ItemChannelLinkRegistry.class));
...
NumberItem temperatureNumberItem = new NumberItem(idFormatted + "_temperature");

Channel tempChannel = thing.getChannel("temperature");
link = new ItemChannelLink(temperatureNumberItem .getName(), tempChannel.getUID());
itemChannelLinkRegistry.add(link);
temperatureNumberItem.setLabel(tempChannel.getLabel());

itemProvider.add(temperatureNumberItem );



tempChannel.getLabel() returns null.
I already debugged the code and found out, that the label and description of the corresponding ChannelDefinition object is null when it is loaded from the XML files. Further analysis of the callstack brought me to the "ThingTypeXmlProvider.addingFinished()" method. While the "channelTypeRefs" contain label and description, however the "thingTypeRefs.ChannelTypeReferences" don't contain a label and describtion any more.
I noticed that this collection is of type ChannelXmlResult, so could there be a bug when assigning the label and description from the ChannelTypes (ChannelTypeXmlResult) ? Or should I retrieve the Label directly from the ChannelTypes? Is there something like a "ChannelTypeRegistry"?

Thanks in advance!
Thomas

[Updated on: Wed, 08 June 2016 18:30] by Moderator

Re: Item and Channel Label is not set in UI [message #1736976 is a reply to message #1734180] Mon, 04 July 2016 14:40 Go to previous message
Eclipse UserFriend
Do you think this could be a duplicate of https://github.com/eclipse/smarthome/issues/1550
Previous Topic:ItemRegistery(org.eclipse.smarthome.core.items.ItemRegistry) is empty when channel is linked?
Next Topic:Smarthome Building issue
Goto Forum:
  


Current Time: Wed Jul 23 16:36:29 EDT 2025

Powered by FUDForum. Page generated in 0.19191 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top