Updating the Thing Structure HELP

Hi guy’s,

In the documentation is said that it is possible to change the structure of a thing by adding, or removing channels. I tried the example in the documentation

public void thingStructureChanged() {
    ThingBuilder thingBuilder = editThing();

    Channel channel = ChannelBuilder.create(new ChannelUID(getThing().getUID().toString() + ":test"), "Switch")
            .build();
    thingBuilder.withChannel(channel);
    updateThing(thingBuilder.build());
}

but I am getting the following error:

2015-09-11 18:19:54 [ERROR] [.c.thing.internal.ThingManager:300 ] - Exception occured while calling handler: java.lang.UnsupportedOperationExceptionjava.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:206)
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:157)
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:72)
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:56)
at org.eclipse.smarthome.core.thing.internal.ThingManager.receiveCommand(ThingManager.java:289)
at org.eclipse.smarthome.core.items.events.AbstractItemEventSubscriber.receive(AbstractItemEventSubscriber.java:46)
at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:168)
at org.eclipse.smarthome.core.internal.events.OSGiEventManager$1.call(OSGiEventManager.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
Caused by: java.lang.UnsupportedOperationException: null
at com.google.common.collect.ImmutableCollection.add(ImmutableCollection.java:91)
at org.eclipse.smarthome.core.thing.binding.builder.GenericThingBuilder.withChannel(GenericThingBuilder.java:31)
at org.openhab.binding.lirc.handler.lircHandler.thingStructureChanged(lircHandler.java:65)
at org.openhab.binding.lirc.handler.lircHandler.handleCommand(lircHandler.java:40)
at org.eclipse.smarthome.core.thing.internal.ThingManager$2.call(ThingManager.java:292)
at org.eclipse.smarthome.core.thing.internal.ThingManager$2.call(ThingManager.java:1)
… 4 common frames omitted

Has anyone of you tried to add channels dynamically?

Best regards, Haris.

Hi Haris,

I general, I would suppose it to work…
As it is related to code from Eclipse SmartHome, may I ask you to post your problem there? https://www.eclipse.org/forums/index.php/f/271/

Thanks!
Kai

Hi,
Thanks Kai for fast reply. I posted the same problem in esh forum.

Best regards, Haris

FTR: https://www.eclipse.org/forums/index.php?t=msg&th=1067757&goto=1708007&#msg_1708007

1 Like