Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse SmartHome » Dynamic Creation and Disposal of Channels(Suggestions on efficient methods to dynamically create, remove and dispose channels)
Dynamic Creation and Disposal of Channels [message #1744112] Thu, 22 September 2016 12:37 Go to next message
Abin Mathew Abraham is currently offline Abin Mathew AbrahamFriend
Messages: 11
Registered: August 2016
Junior Member
Hi,
I created channels dynamically and linked it to the thing by using ThingBuilder.build() method. For removing the channels, I got the current list of channels using getChannels() method and made a mutable list from it. Then I iterated through the channels found the channelUID match and removed it from the mutable list i created and then again used ThingBuilder.build() using the list I modified. Is this the correct procedure to do this?

Regards,
Abin

[Updated on: Thu, 22 September 2016 12:45]

Report message to a moderator

Re: Dynamic Creation and Disposal of Channels [message #1744160 is a reply to message #1744112] Thu, 22 September 2016 22:49 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 657
Registered: December 2011
Senior Member
I'm afraid that this is currently the only way - it so far was really never a use case to remove channels, but it is a valid requirement of course.
Feel free to enter an issue about that, so that we might enhance the ThingBuilder to also allow removals.
Re: Dynamic Creation and Disposal of Channels [message #1744173 is a reply to message #1744160] Fri, 23 September 2016 07:16 Go to previous messageGo to next message
Abin Mathew Abraham is currently offline Abin Mathew AbrahamFriend
Messages: 11
Registered: August 2016
Junior Member
Thanks Kai for your response and time. I have a few queries on Thing being cached. Where is this implemented? The dynamic channels I created if not removed, is being shown up again when the server is restarted. How can I disable this behaviour? How to ensure the dispose() methods are called of the Things when the server is stopped? When is the handleRemoval() method and when is the dispose() method in thing handler called?

Regards,
Abin

[Updated on: Fri, 23 September 2016 07:24]

Report message to a moderator

Re: Dynamic Creation and Disposal of Channels [message #1744288 is a reply to message #1744173] Sat, 24 September 2016 04:54 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 657
Registered: December 2011
Senior Member
> I have a few queries on Thing being cached. Where is this implemented?

Well, this is the core functionality of the ManagedThingProvider that it persists the Things in a database.

> The dynamic channels I created if not removed, is being shown up again when the server is restarted. How can I disable this behaviour?

I think this is the same request as https://github.com/eclipse/smarthome/issues/588#issuecomment-226565087 - this indeed is currently not possible, but maybe it is a good idea to change this behavior to not persisting any change. Fancy to enter another issue?

> How to ensure the dispose() methods are called of the Things when the server is stopped?

You cannot, the server could also be powered off without you having a chance to do any clean up.

> When is the handleRemoval() method and when is the dispose() method in thing handler called?

handleRemoval: on a Thing removal (e.g. triggered by the user in the UI)
dispose: upon a bundle shutdown, when the services are stopped in an orderly fashion.

Re: Dynamic Creation and Disposal of Channels [message #1744347 is a reply to message #1744288] Mon, 26 September 2016 08:44 Go to previous messageGo to next message
Abin Mathew Abraham is currently offline Abin Mathew AbrahamFriend
Messages: 11
Registered: August 2016
Junior Member
Thank you so much Kai

Regards,
Abin
Re: Dynamic Creation and Disposal of Channels [message #1744499 is a reply to message #1744288] Tue, 27 September 2016 13:13 Go to previous messageGo to next message
Abin Mathew Abraham is currently offline Abin Mathew AbrahamFriend
Messages: 11
Registered: August 2016
Junior Member
Hi,
How do we get the current state of channel in framework? Are there some methods for the developers for fetching the current state of channels? Or should the binding handle this?

Regards,
Abin

[Updated on: Tue, 27 September 2016 13:22]

Report message to a moderator

Re: Dynamic Creation and Disposal of Channels [message #1745115 is a reply to message #1744499] Wed, 05 October 2016 10:49 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 657
Registered: December 2011
Senior Member
If you need to keep track of the lastest state, you should keep this value within your binding, yes.
Re: Dynamic Creation and Disposal of Channels [message #1745918 is a reply to message #1745115] Wed, 19 October 2016 10:21 Go to previous message
Abin Mathew Abraham is currently offline Abin Mathew AbrahamFriend
Messages: 11
Registered: August 2016
Junior Member
Hi,
If the Thing's property which is being exposed by a channel can be changed from an external entity, what do you suggest to keep the channel value in binding fresh? Is polling a good option?

Regards,
Abin
Previous Topic: Extra information in config XML files
Next Topic:LOG & EVENTS
Goto Forum:
  


Current Time: Fri Sep 21 18:12:54 GMT 2018

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

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

Back to the top