Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » How to add things dynamically in the binding
How to add things dynamically in the binding [message #1770375] Thu, 10 August 2017 13:26 Go to next message
markus petke is currently offline markus petkeFriend
Messages: 6
Registered: August 2017
Junior Member
Hello,

we are currently developing a binding for ESH and are wondering how to add things to the web-ui.

We have a configurationfile were all of our devices and their properties are defined. Our first thought was to parse this file into a .things-file. But the problem here was to get the correct path to store the file for the different platforms...

Now we want to add the things directly. We want to avoid the inbox and need to connect every thing with our bridge.

We already tried the DiscoveryService but this only adds the thing to the inbox without the connection to our bridge.

Could anyone help us with either one of the ways? Or just point us to the right documents?

Regards
Markus
Re: How to add things dynamically in the binding [message #1770423 is a reply to message #1770375] Fri, 11 August 2017 07:24 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Hi Markus,

To answer you correctly, I will have to understand your use case a bit better.
Note that a binding is not allowed to decide on its own that certain devices should be used by the installation - this is intentionally left to the user/admin of the system by means of the Inbox.

If you are not implementing a binding, but rather want to build a custom ESH-based runtime that out-of-the-box supports your devices, you can implement your own ThingProvider. This implementation can read your custom config files and dynamically create Things from it. Note that a binding must not implement this interface, so for such a solution you would build a proprietary extension.

A middle path could be to implement a binding with a DiscoveryService, which puts the stuff in the inbox and then use an auto-approve feature (currently only available in openHAB, see https://github.com/openhab/openhab-distro/blob/master/distributions/openhab/src/main/resources/conf/services/runtime.cfg#L51-L54, but I plan to move that to ESH).

Hope this helps,
Kai
Re: How to add things dynamically in the binding [message #1770425 is a reply to message #1770423] Fri, 11 August 2017 08:32 Go to previous messageGo to next message
markus petke is currently offline markus petkeFriend
Messages: 6
Registered: August 2017
Junior Member
Hello Kai,

thanks for the fast reply.
We are really new to ESH and OpenHAB. So at the beginning we just wanted to develope a binding. We can already create things from PaperUi and use their channels and so on.

The problem is that in our case we can have many devices/things and we wanted to automatically add them to the interface. All of these devices are defined in an configuration-file. Parsing this file into a .things-file is really easy and we have already done that. With this method the things are added directly with the right configuration and the required bridge.

After testing, we encountered the problem that we couldn´t get the correct path to store the file. One possibility would be to let the user define the path per property of the bridge but we wanted to avoid the user from to much configuration. So he should just give us the configurationfile and everything else should happen automatically.

After that we tried the DiscoveryService. That also worked with a concrete path to the configfile but we could not see any possibility to let the user decide were to look for the file. Furthermore all of the things are at the inbox and have to be confirmed by hand. That is not a problem for 2 or 3 devices but in our case there are up to a few hundred things. Afterwards the user also have to set the bridge for every thing. This can be really annoying...

So to understand your answer. The auto-approve feature could be used, but the required bridge still has to be set by hand?

Developing a complete new extension would be the prefered way but we also want the users to have the ability to add several bindings also for openhab by their own. I don´t know if it is possible to add OpenHab-Bindings to an extension only based on ESH?

Regards
Markus

[Updated on: Fri, 11 August 2017 08:45]

Report message to a moderator

Re: How to add things dynamically in the binding [message #1770721 is a reply to message #1770425] Wed, 16 August 2017 13:09 Go to previous message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
> Afterwards the user also have to set the bridge for every thing. This can be really annoying...
> The auto-approve feature could be used, but the required bridge still has to be set by hand?

Not sure why the user has to set the bridge by hand - if you have implemented a discovery service, you can use DiscoveryResultBuilder.withBridge(ThingUID bridgeUID) to set the correct bridge for the inbox entry - and yet, if the auto-approve is used, this will directly result in a Thing and there would be no need for any kind of manual action for the users.

> I don´t know if it is possible to add OpenHab-Bindings to an extension only based on ESH?

Do you mean "to a solution only based on ESH"? Well, almost everything in openhab2-addons merely uses the ESH APIs and have no dependency on openHAB-specific code - so yes, in general that is possible with a few exceptions.
Previous Topic:Use org.openhab.persistence.mapdb binding in eclipse smart home.
Next Topic:extending ExpiringCache with IsChanged
Goto Forum:
  


Current Time: Fri Apr 26 21:25:33 GMT 2024

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

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

Back to the top