Channels created via ChannelBuilder do not show up in OH3 UI


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:

    public void initialize() {
        config = getConfigAs(TestConfiguration.class);

        ThingBuilder thingBuilder = editThing();
        Channel channel = ChannelBuilder.create(new ChannelUID(thing.getUID(), "testChannel"), "String").build();

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();

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")

        ThingBuilder thingBuilder = editThing();
        logger.warn("Channel UID: {}", channel.getUID());

I guess the missing (or invalid) ChannelType caused the problem. In the above example the ChannelType is defined via thing-types.xml.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.