Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse SmartHome » Bridge Handler adding discovered ChildThing.(Need help in creating a discovered child thing.)
Bridge Handler adding discovered ChildThing. [message #1792584] Thu, 19 July 2018 21:16 Go to next message
WeeMin Chan is currently offline WeeMin ChanFriend
Messages: 1
Registered: July 2018
Junior Member
So this is my situation, I have a bridge handler that discovered a few things that havent been configured. How do I add it to the "inbox?"


e.g:
public class PartitionBridgeHandler extends BaseBridgeHandler {

...
  private void receiveUpdateFromSource(int sourceID) {
    PartitionBridgeConfiguration config;
    for (Thing eachThing:  this.getBridge().getThings()) {
        config =  eachThing.getConfiguration().as(PartitionBridgeConfiguration.class);
        if (config.sourceID == sourceID) {
             // Found the thing
            eachThing.getHandler().updateState(...);
        } else {
            // not found suggest add to discovery... but how?
       }        
    }
  }
...  

}

Re: Bridge Handler adding discovered ChildThing. [message #1792749 is a reply to message #1792584] Mon, 23 July 2018 13:49 Go to previous message
Stefan Triller is currently offline Stefan TrillerFriend
Messages: 29
Registered: April 2017
Junior Member
A bridge or thinghandler should never add anything to the discovery. Instead you should write a service that implements DiscoveryService and that creates a DiscoveryResult which can be added to the inbox.

If you need access to the bridgeHandler from your discovery service implementation, create your service from the ThingHandlerFactory, just after you have created the bridgeHandler and pass the bridgeHandler to your service. But you should only use the handler to communication with the device.

For am example, have a look at the hue binding: https://github.com/eclipse/smarthome/blob/36a470bfceb32e1eee511142a298dd6608a0b85c/extensions/binding/org.eclipse.smarthome.binding.hue/src/main/java/org/eclipse/smarthome/binding/hue/internal/HueThingHandlerFactory.java#L104-L109
Previous Topic:Gather the data from channels
Next Topic:Unable to receive Events(itemCommandEvent,ItemStateEvent) from ESH
Goto Forum:
  


Current Time: Sat Apr 27 03:12:34 GMT 2024

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

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

Back to the top