Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Thing compareTo()(Comparing things should go further than comparing ThingUID)
Thing compareTo() [message #1496757] Wed, 03 December 2014 08:43 Go to next message
Karel Goderis is currently offline Karel GoderisFriend
Messages: 198
Registered: March 2014
Senior Member
With the transition to openHAB2.0 I came across a real-life example of what I already suggested before: duplication of Things between Things defined in the DSL and Things found through Discovery.

In the case of the KNX binding for example, you would typically have a user define a lot of things in a DSL, andn then, from time to time, do a Discovery to find out about new KNX Group Addresses when a KNX actor is for example added to the KNX bus.

Today the KNX binding, when Discovery GA's, creates Things with ID's that end with x_y_z, where x y and z make up the x/y/z GA format. However, when Things are already defined through the DSL, using another nomenclatura than then one that it assumed by the Discovery service, one gets duplicates of the Thing (i.e. different UID but with some properties other than the name being equal) in the Inbox.

One could argue that it is up to the user to manually delete the Things from the Inbox, but with a technology like KNX you easily end up with 100's (in for example my case 1000's) of Things you do not need

Therefore, I think that a mechanism should be provided to check for duplicate Things that goes beyond the simple ThingUID, but that also takes into account attributes of the Things, a kind of a compareTo(). When a thing is discovered, or added through the DSL, a check needs to be done to see if the Thing already exists, and if it does, it's creation is either simply abandoned, or it's attributes are "updated". I might be wrong in this, but the GenericThingProvider and ThingFactory could use the same getUID() methods to solve this issue....

K
Re: Thing compareTo() [message #1496796 is a reply to message #1496757] Wed, 03 December 2014 09:21 Go to previous messageGo to next message
Dennis Nobel is currently offline Dennis NobelFriend
Messages: 166
Registered: September 2014
Senior Member
Hi Karel

how should a duplicate thing be identified? All configuration properties are equal? I´m not sure if this will work for all bindings. We defined the UID for identification of things and if the UID is different, there are different things by definition. Maybe the KNX binding can suggest the UID declaration in the DSL to have the same nomenclatura as through discovery.

But the general problem with static DSL configuration and runtime configuration together is not nothing we can solve at this point in my opinion. I still believe that is not possible to work with static DSL configuration and the configured things at runtime together - at least not with the actual approach. While developing the UI I came across a lot of problems. Just to name a few:

* It is not possible to assign groups or tags to Items, that are configured through a DSL
* Things and Items from DSL can not be removed.
* Configuration of things can not be changed at runtime
* Its hard to unterstand that a thing, which came into the system through discovery, is not present in the DSL

Therefore I suggest we should open a general discussion thread on this. We already had some initial thoughts. For example one solution could be to import the DSL at the startup, so that all things and items are stored in the database. Another solution could be that the DSL works as a database and allows to write changes back. But I´m not sure if this is more openHAB related or ESH related.

Regards

Dennis
Re: Thing compareTo() [message #1496808 is a reply to message #1496796] Wed, 03 December 2014 09:34 Go to previous message
Karel Goderis is currently offline Karel GoderisFriend
Messages: 198
Registered: March 2014
Senior Member
Indeed, I would not expect to do a comparison on all attributes of a Thing, but we could identify those attributes to compare in the things.xml definition, no? style <compare>true</compare> flag

Cf. your suggestion, another one would be to persist the inbox or the thing registry to a DSL file using the osgi console. At least that way you do not have to deal with keeping things in sync real-time ,eg. user would do discovery, export the inbox or registry to a DSL file, use a text editor to combine the generated DSL with the "custom" DSL, save the combined DSL to the configuration folders, ...

Making thingProvider and ThingHandlerFactory use the same getUID is not an option? that would already resolved part of the issue, no? For example, have thingProvider create a dummy instance of all registered factories so that it can call upon the getUID() method?

good idea to have general thread.

K

Previous Topic:Eclipse Smarthome runtime not building
Next Topic:Eclipse and OpenHAB
Goto Forum:
  


Current Time: Thu Apr 25 04:38:36 GMT 2024

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

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

Back to the top