Search in sources :

Example 1 with HueLightDiscoveryService

use of org.eclipse.smarthome.binding.hue.internal.discovery.HueLightDiscoveryService in project smarthome by eclipse.

the class HueThingHandlerFactory method removeHandler.

@Override
protected synchronized void removeHandler(ThingHandler thingHandler) {
    if (thingHandler instanceof HueBridgeHandler) {
        ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(thingHandler.getThing().getUID());
        if (serviceReg != null) {
            // remove discovery service, if bridge handler is removed
            HueLightDiscoveryService service = (HueLightDiscoveryService) bundleContext.getService(serviceReg.getReference());
            if (service != null) {
                service.deactivate();
            }
            serviceReg.unregister();
            discoveryServiceRegs.remove(thingHandler.getThing().getUID());
        }
    }
}
Also used : HueLightDiscoveryService(org.eclipse.smarthome.binding.hue.internal.discovery.HueLightDiscoveryService) HueBridgeHandler(org.eclipse.smarthome.binding.hue.handler.HueBridgeHandler)

Example 2 with HueLightDiscoveryService

use of org.eclipse.smarthome.binding.hue.internal.discovery.HueLightDiscoveryService in project smarthome by eclipse.

the class HueThingHandlerFactory method registerLightDiscoveryService.

private synchronized void registerLightDiscoveryService(HueBridgeHandler bridgeHandler) {
    HueLightDiscoveryService discoveryService = new HueLightDiscoveryService(bridgeHandler);
    discoveryService.activate();
    this.discoveryServiceRegs.put(bridgeHandler.getThing().getUID(), bundleContext.registerService(DiscoveryService.class.getName(), discoveryService, new Hashtable<String, Object>()));
}
Also used : Hashtable(java.util.Hashtable) HueLightDiscoveryService(org.eclipse.smarthome.binding.hue.internal.discovery.HueLightDiscoveryService)

Aggregations

HueLightDiscoveryService (org.eclipse.smarthome.binding.hue.internal.discovery.HueLightDiscoveryService)2 Hashtable (java.util.Hashtable)1 HueBridgeHandler (org.eclipse.smarthome.binding.hue.handler.HueBridgeHandler)1