|Re: NoClassDefFoundError when using ManagedItemProvider.add in custom binding [message #1768092 is a reply to message #1768063]
||Thu, 13 July 2017 14:12
| Thomas Biacsics
Registered: June 2016
That's right, but I was not able to find the real root cause. I can only say that when I make a call to "ManagedItemProvider.add()", the whole binding can not be initialised.|
I know that the intention of an item is not that as I want to use them. I want to implement the following features in order to the users don't have to add items manually and assign ids or create links --> the binding should do that tasks for the user and sets up the items automatically.
My binding implements a DiscoveryService which searches for wireless irrigation devices . When a device was found, one bridge (Irrigation Device) and 5 Things (Irrigation Valves) are created.
Then I want to create also the "User Interface" automatically for the user. In order to accomplish that I created a few fixed GroupItems, for example "gAllDevices", and added them to the Sitemap. So when the bridge and the things are added, I want to create within this process also nested Items which then automatically build the user interface for the newly added bridge and things.
In short, I want to build a user interface (forms for creating database entries (for example a schedule entry for an irrigation valve, or forms for starting a manual irrigation task) with the use of items and GroupItems.
A sample structure would look like this:
gAllDevices --> gDevice1, gDevice2, ...
gDevice1 --> gValve1, gValve2, ...
gValve1 --> gManualIrrigation, gAddScheduleEntry, some statusItems, gShowAllScheduleEntries
gManualIrrigation --> durationItem, starttimeItem, submitButtonItem, ...
gAddScheduleEntry --> monday, tuesday, ... , starttime, endtime, ... , saveButton
If I can not achieve this programatically with the usage of items, the whole discovery and thing adding process will not take effect on the user interface. The main purpose is, that the user only has to search for things, add the things and afterwards the sitemap and items are already created and the user don't has to care about creating and linking items manually in order to have an useful user interface within the sitemap.
Maybe openHAB or ESH is the wrong tool for implementing such an application scenario but I wanted to use it because of other useful bindings and the good infrastructure.
So what do you think? :)
|Re: NoClassDefFoundError when using ManagedItemProvider.add in custom binding [message #1768180 is a reply to message #1768092]
||Fri, 14 July 2017 11:50
| Simon Kaufmann
Registered: January 2011
No, ESH and openHAB are perfectly fine for implementing such a scenario. I know at least one other big commercial solution built on top of ESH that also hides the items/sitemap hassle from its users and creates manages them auto-magically. So it's perfectly fine to manage them automatically. The only thing that irritated me was that your binding is doing it. If you want to keep your binding to yourself, you are of course free to do whatever you like in there. If you however decide to contribute this to any of the open source projects, you should rather keep these concerns separate, in a different bundle. And I would recommend doing it anyway.|
By the way: What ESH (and also openHAB) has is a so called "simple mode" a.k.a. "auto-linking". If enabled, the ThingLinkManager will automatically create links for all channels automatically and subsequently items for all links pointing to items which don't exist otherwise. So you will get the item/link creation (and removal!) part "for free" from the framework if your like. Your can enable/disable it in the PaperUI (Configuration -> System -> Item Linking -> Simple Mode) or via a config file "conf/services/org.eclipse.smarthome.links.cfg" with a "autoLinks=true" content. Then you will only need to take care of your group items in order to add those items as children automatically. I would suppose the easiest way of doing it is registering your own service component to the ItemRegistry as a RegistryChangeListener so you will get notified whenever an item gets added or removed. I have to admit that ESH currently at this point is a little weak, because you cannot provide sitemaps independently from the *.sitemap files, e.g. via java code. There have been thoughts on this here, but the discussion ceased and so far wasn't picked up again.
If you don't want to use the auto linking, you could still fall back to registering your component to the ThingRegistry, again as a RegistryChangeListener. Then you can handle item/link creation/deletion whenever one of your relevant things show up or disappear. You then have to ways to go: add the items/links that you maintain to the corresponding managed providers (i.e. rely on the database backed one), or make your service component implement the ItemProvider/ItemChannelLinkProvider interfaces so that the registries pick them up. The latter is probably more work on your side, but on the other hand you are by yourself there and have no users messing around with your entities.
Hope that helps?
Powered by FUDForum
. Page generated in 0.01751 seconds