Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » How to get all handlers for certain thingtype
How to get all handlers for certain thingtype [message #1713111] Sat, 31 October 2015 16:16 Go to next message
Marcel Verpaalen is currently offline Marcel VerpaalenFriend
Messages: 59
Registered: September 2014
Member

I guess there is a simple, obvious way, but could not directly find it.

From my discovery service I need to inform all bridge handlers to refresh the results they provide to the discovery service, so the discovery service can submit them as discovery results.

Hence my though is that I would cycle through all the handlers for my thingtype and call the refresh().

Anyone suggestion on how to do this?
Re: How to get all handlers for certain thingtype [message #1713123 is a reply to message #1713111] Sat, 31 October 2015 23:34 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Actually, the dependencies should better be the other way round - discovery services should create results and if they are updated, thing handers can be informed. There should be no dependency from discovery->handler, only the other way round.
Re: How to get all handlers for certain thingtype [message #1713141 is a reply to message #1713123] Sun, 01 November 2015 10:55 Go to previous messageGo to next message
Marcel Verpaalen is currently offline Marcel VerpaalenFriend
Messages: 59
Registered: September 2014
Member
This is indeed how the binding works in the normal way.

For devices that are connected to a bridge, usually the bridge thing is actually controlling the discovery of the connected devices. Hence during the start of the bridge this discovery takes place, find the new connected things and informs the discovery service for the bridge connected things.

However, if at a later stage the user triggers a new scan, there is no way to inform the bridge that it needs to repeat a discovery. Hence my need for the bridgehandlers so discovery service can request resubmission to handler.
This is most useful if you delete a thing. As the bridge is unaware that the thing is deleted, it will not provide it again to the discovery service. The only way to trigger it again would be to restart the bridge/binding

Same problem you have in the hue binding
https://github.com/eclipse/smarthome/blob/master/extensions/binding/org.eclipse.smarthome.binding.hue/src/main/java/org/eclipse/smarthome/binding/hue/internal/discovery/HueLightDiscoveryService.java#L71

However, what I don't know is how this deals with the problem if you have multiple bridges running. Do you run multiple discovery services?
My idea was to cycle through the bridgehandlers and inform each of them.
What I can do is to maintain a list of bridgehandlers in the discoveryservice (somewhat similar to the hue way) but that does not seem like the best way to me.
Re: How to get all handlers for certain thingtype [message #1713798 is a reply to message #1713141] Fri, 06 November 2015 16:38 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
I think what you are missing is the fact that there can be indeed any number of DiscoveryServices for the same thing type. In the case of hue, we register an HueLightDiscoveryService instance per hue bridge (handler). That's why you also find exactly one reference to a handler in the code you referred to. The same should work in your case, I guess?
Re: How to get all handlers for certain thingtype [message #1713921 is a reply to message #1713798] Sun, 08 November 2015 13:07 Go to previous messageGo to next message
Karel Goderis is currently offline Karel GoderisFriend
Messages: 198
Registered: March 2014
Senior Member
Marcel,

I think the easiest way to solve your problem is indeed to follow what Kai suggested (e.g. DiscoveryResults), even if this implies you have some duplicate "discovery" code in both the BridgeHandler and the DiscoveryService. Also, I would refrain from have the Bridges talk to each other, you better make each one of them standalone. So, the DiscoveryService would discover devices, and the Bridges would do the same thing, maybe duplicating traffic and so forth. Partly deviating from this could be that you make your Bridges DiscoveryListeners, but then they will depend on the DiscoveryService to discover services, but maybe you do not want this.

Maybe not the most beautiful approach, but it will make your life far more easier
Re: How to get all handlers for certain thingtype [message #1714107 is a reply to message #1713921] Mon, 09 November 2015 22:52 Go to previous message
Marcel Verpaalen is currently offline Marcel VerpaalenFriend
Messages: 59
Registered: September 2014
Member
Okay, got it. So I register multiple discovery services, one for each bridge. Than indeed it could work.
Previous Topic:Linking an item to a thing
Next Topic:Mail Binding or IO for new rule engine
Goto Forum:
  


Current Time: Fri Apr 19 22:06:04 GMT 2024

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

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

Back to the top