|Item and Channel Label is not set in UI [message #1734180]
||Sun, 05 June 2016 17:47
| Thomas Biacsics
Registered: June 2016
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"/>
<description>Current temperature in degrees celsius</description>
<state readOnly="true" pattern="%.1f °C" />
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());
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!
[Updated on: Wed, 08 June 2016 22:30]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02053 seconds