Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » DiscoveryService registered but startScan not executed
DiscoveryService registered but startScan not executed [message #1773637] Mon, 02 October 2017 06:16 Go to next message
Nils Billing is currently offline Nils BillingFriend
Messages: 13
Registered: September 2017
Junior Member
Hello,

I've a little problem perhaps it's a comprehsension problem on my part.

I've implemented a HandlerFactory extending BaseThingHandlerFactory. My assumption was that when I start scan by pressing the button in the inbox that I get in popup for "Scan for Things" a new entry for my discovery service.

index.php/fa/30883/0/

that's my HandlerFactory extending BaseThingHandlerFactory:

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
   ThingTypeUID thingTypeUID = thing.getThingTypeUID();

   if (thingTypeUID.equals(THING_TYPE_STATION)) {
      MyBridgeHandler handler = new MyBridgeHandler((Bridge) thing);
      registerDeviceDiscoveryService(handler);
      return handler;
   }
   return null;
}

private void registerDeviceDiscoveryService(MyBridgeHandler bridgHandler) {

   MyDiscoveryService discoveryService = new MyDiscoveryService (bridgHandler);

   this.discoveryServiceRegs.put(bridgHandler.getThing().getUID(), bundleContext.registerService(DiscoveryService.class.getName(), discoveryService,
                new Hashtable<String, Object>()));
}


and a MyDiscoveryService extending AbstractDiscoveryService:

public MyDiscoveryServiceMyBridgeHandler bridgeHandler) throws IllegalArgumentException {
   super(SEARCH_TIME);
   this.bridgeHandler = bridgeHandler;
}

@Override
protected void startScan() {
   some code....
}



When I start debugging I see that my code is executed succefully.
But why is my service not listed?
  • Attachment: paperui.jpg
    (Size: 41.35KB, Downloaded 460 times)
Re: DiscoveryService registered but startScan not executed [message #1773881 is a reply to message #1773637] Fri, 06 October 2017 03:48 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Hi Nils,

If your DiscoveryService does not depend on a specific ThingHandler, but it can discovery Things without any preconditions, then all you need to do is to register an OSGi service through declarative services (DS), see e.g. this one: https://github.com/eclipse/smarthome/blob/master/extensions/binding/org.eclipse.smarthome.binding.lifx/src/main/java/org/eclipse/smarthome/binding/lifx/internal/LifxLightDiscovery.java#L67-L68

Re: DiscoveryService registered but startScan not executed [message #1773882 is a reply to message #1773881] Fri, 06 October 2017 03:54 Go to previous messageGo to next message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
If you really depend on an existing ThingHandler and thus you need to manually register it in the ThingHandlerFactory as you do, please check that you have implemented getSupportedThingTypes() in your DiscoveryService as this is used to determine, which bindings are offered for triggering a scan.
Re: DiscoveryService registered but startScan not executed [message #1773884 is a reply to message #1773882] Fri, 06 October 2017 06:05 Go to previous messageGo to next message
Nils Billing is currently offline Nils BillingFriend
Messages: 13
Registered: September 2017
Junior Member
hi Kai,

thank you for your support! I have implemented getSupportedThingTypes() in my DiscoveryService and now it works!!!

But after your response I'm not sure if I do it right anymore. So let me explain what I'm doing.

I've a bridgeHandler which connect to a http api with username and password to get a sessionid. After connecting to the http api the bridge requests the api with the sessionid to get a json list with devices: These devices are my new discovered things.
After all the http api is a gateway to communicate with the devices. Therefore I have come to the assumption to implement a bridgehandler for the api.

Is the bridgehandler in that case the right aproach for the implementation?


Re: DiscoveryService registered but startScan not executed [message #1773931 is a reply to message #1773884] Fri, 06 October 2017 16:35 Go to previous message
Kai Kreuzer is currently offline Kai KreuzerFriend
Messages: 673
Registered: December 2011
Senior Member
Yes, this is a perfect valid case for modelling the "web account" as a bridge with a handler and then discovering the devices as things on that bridge. So all fine as you have done it!
Previous Topic:Design question: searching for things (getThingByUID)
Next Topic:Error executing maven build and resolving targed-platform
Goto Forum:
  


Current Time: Sat Dec 07 20:47:46 GMT 2024

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

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

Back to the top