Search in sources :

Example 1 with TradfriDiscoveryService

use of org.eclipse.smarthome.binding.tradfri.internal.discovery.TradfriDiscoveryService in project smarthome by eclipse.

the class TradfriHandlerFactory method unregisterDiscoveryService.

private void unregisterDiscoveryService(TradfriGatewayHandler bridgeHandler) {
    ServiceRegistration<?> serviceReg = this.discoveryServiceRegs.get(bridgeHandler.getThing().getUID());
    if (serviceReg != null) {
        TradfriDiscoveryService service = (TradfriDiscoveryService) getBundleContext().getService(serviceReg.getReference());
        if (service != null) {
            service.deactivate();
        }
        serviceReg.unregister();
        discoveryServiceRegs.remove(bridgeHandler.getThing().getUID());
    }
}
Also used : TradfriDiscoveryService(org.eclipse.smarthome.binding.tradfri.internal.discovery.TradfriDiscoveryService)

Example 2 with TradfriDiscoveryService

use of org.eclipse.smarthome.binding.tradfri.internal.discovery.TradfriDiscoveryService in project smarthome by eclipse.

the class TradfriDiscoveryServiceTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    when(handler.getThing()).thenReturn(BridgeBuilder.create(GATEWAY_TYPE_UID, "1").build());
    discovery = new TradfriDiscoveryService(handler);
    listener = new DiscoveryListener() {

        @Override
        public void thingRemoved(DiscoveryService source, ThingUID thingUID) {
        }

        @Override
        public void thingDiscovered(DiscoveryService source, DiscoveryResult result) {
            discoveryResult = result;
        }

        @Override
        public Collection<ThingUID> removeOlderResults(DiscoveryService source, long timestamp, Collection<ThingTypeUID> thingTypeUIDs, ThingUID bridgeUID) {
            return null;
        }
    };
    discovery.addDiscoveryListener(listener);
}
Also used : DiscoveryResult(org.eclipse.smarthome.config.discovery.DiscoveryResult) ThingUID(org.eclipse.smarthome.core.thing.ThingUID) Collection(java.util.Collection) ThingTypeUID(org.eclipse.smarthome.core.thing.ThingTypeUID) DiscoveryService(org.eclipse.smarthome.config.discovery.DiscoveryService) TradfriDiscoveryService(org.eclipse.smarthome.binding.tradfri.internal.discovery.TradfriDiscoveryService) DiscoveryListener(org.eclipse.smarthome.config.discovery.DiscoveryListener) TradfriDiscoveryService(org.eclipse.smarthome.binding.tradfri.internal.discovery.TradfriDiscoveryService) Before(org.junit.Before)

Example 3 with TradfriDiscoveryService

use of org.eclipse.smarthome.binding.tradfri.internal.discovery.TradfriDiscoveryService in project smarthome by eclipse.

the class TradfriHandlerFactory method registerDiscoveryService.

private void registerDiscoveryService(TradfriGatewayHandler bridgeHandler) {
    TradfriDiscoveryService discoveryService = new TradfriDiscoveryService(bridgeHandler);
    discoveryService.activate();
    this.discoveryServiceRegs.put(bridgeHandler.getThing().getUID(), getBundleContext().registerService(DiscoveryService.class.getName(), discoveryService, new Hashtable<String, Object>()));
}
Also used : Hashtable(java.util.Hashtable) TradfriDiscoveryService(org.eclipse.smarthome.binding.tradfri.internal.discovery.TradfriDiscoveryService)

Aggregations

TradfriDiscoveryService (org.eclipse.smarthome.binding.tradfri.internal.discovery.TradfriDiscoveryService)3 Collection (java.util.Collection)1 Hashtable (java.util.Hashtable)1 DiscoveryListener (org.eclipse.smarthome.config.discovery.DiscoveryListener)1 DiscoveryResult (org.eclipse.smarthome.config.discovery.DiscoveryResult)1 DiscoveryService (org.eclipse.smarthome.config.discovery.DiscoveryService)1 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)1 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)1 Before (org.junit.Before)1