MikeTheTux
(Mike The Tux)
November 6, 2021, 2:26pm
1
Hi,
I’m working on a new binding that requires several channels to be created dynamically, based on the feedback from the device.
I followed the example from updating-the-thing-structure and also the implementation from other bindings without success. Bundle loads without warning/exception, goes ONLINE but the channel list only shows the pre-defines static channels from thing-types.xml
.
My code:
New Bundle skeleton named “Test” created via script and constructor extended as follows:
@Override
public void initialize() {
config = getConfigAs(TestConfiguration.class);
updateStatus(ThingStatus.UNKNOWN);
ThingBuilder thingBuilder = editThing();
Channel channel = ChannelBuilder.create(new ChannelUID(thing.getUID(), "testChannel"), "String").build();
thingBuilder.withChannel(channel);
updateThing(thingBuilder.build());
updateStatus(ThingStatus.ONLINE);
}
I think you are missing the bindingID
as well as type
in your call:
Channel channel = ChannelBuilder.create(new ChannelUID(thing.getUID(), “testChannel”), “String”).build();
try something like this:
Channel channel = ChannelBuilder.create(new ChannelUID(“addbindingIDhere”+“String”+thing.getUID(), “testChannel”), “String”).build();
MikeTheTux
(Mike The Tux)
November 8, 2021, 4:32pm
3
Thx for the reply!
In the meanwhile I got it working:
logger.warn("Thing UID: {}", thing.getUID());
ChannelTypeUID channelTypeUID = new ChannelTypeUID("test:sample-channel");
Channel channel = ChannelBuilder.create(new ChannelUID(thing.getUID(), "testChannel"), "Number:Temperature")
.withType(channelTypeUID).withKind(ChannelKind.STATE).withLabel("label").build();
ThingBuilder thingBuilder = editThing();
thingBuilder.withoutChannel(channel.getUID());
logger.warn("Channel UID: {}", channel.getUID());
thingBuilder.withChannel(channel);
updateThing(thingBuilder.build());
I guess the missing (or invalid) ChannelType caused the problem. In the above example the ChannelType is defined via thing-types.xml.
system
(system)
Closed
December 20, 2021, 8:32am
4
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.