Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Adding Dynamic channels to a thing type
Adding Dynamic channels to a thing type [message #1710480] Wed, 07 October 2015 06:03 Go to next message
Jayaraj Esvar is currently offline Jayaraj EsvarFriend
Messages: 3
Registered: July 2015
Junior Member
Hi,
I would like to add channels to my existing thing type, Where my set of channels will vary for each thing that is created.

For example if I have a thing type.xml without any channels defined

<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="elnetty"
xmlns:xsi=...........>

<!-- switch Thing Type -->
<thing-type id="alljoyn">
<label>AlljoynThing</label>
<description>An Alljoyn Device</description>

</thing-type>

</thing:thing-descriptions>


and channel types defined on seperate xml like

<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="elnetty"
............>

<!-- Alarm Channel -->
<channel-type id="Alarm">
<item-type>Switch</item-type>
<label>Alarm</label>
<description>Alarm.</description>
<category>Alarm</category>
</channel-type>

</thing:thing-descriptions>


Is it possible to add channels dynamically to a thing type While creating it.

public Thing createThing(ThingTypeUID thingTypeUID, Configuration configuration, ThingUID thingUID,
ThingUID bridgeUID) {

List<Channel> channels = new CopyOnWriteArrayList<>();
ChannelUID channelUID = new ChannelUID("elnetty:alljoyn:" + getDeviceId()
+ ":" + id);
Channel channel = ChannelBuilder.create(channelUID, type).build();

channels.add(channel);

return ThingBuilder.create(thingUID).withChannels(channels) .withProperties(getThingTypeByUID(thingTypeUID).getProperties()).build();
}


or how do i register these channels types to channelprovider. The set channels will vary for each instance of the the thing.

here the variable "id" is not known before so i can't add them to thing type like

<channels>
<channel id="0" typeId="Alarm" />
<channels>


Right now In class ThingSetupManager , addThing()
this.thingTypeRegistry.getChannelType(channel.getUID()); is not getting populated without definitions of channels for Thing-Type in XML file
Re: Adding Dynamic channels to a thing type [message #1711365 is a reply to message #1710480] Thu, 15 October 2015 11:22 Go to previous message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Quote:
I would like to add channels to my existing thing type, Where my set of channels will vary for each thing that is created.


If it varies for each thing, you should not add them to the thing type. Simply only define the channels that are available on ALL things of this type. Then when creating the thing within the ThingHandlerFactory, add the according channels to the thing that you need.
Channel types can be declared by either XML files in ESH-INF or by implementing your own ChannelTypeProvider.
Previous Topic:Overriding channel labels
Next Topic:Base Item / Function of Group item
Goto Forum:
  


Current Time: Wed Sep 25 22:56:52 GMT 2024

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

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

Back to the top