Search in sources :

Example 1 with HueBridgeHandler

use of org.eclipse.smarthome.binding.hue.handler.HueBridgeHandler in project smarthome by eclipse.

the class HueLightDiscoveryServiceOSGiTest method setUp.

@Before
public void setUp() {
    registerVolatileStorageService();
    thingRegistry = getService(ThingRegistry.class, ThingRegistry.class);
    assertThat(thingRegistry, is(notNullValue()));
    Configuration configuration = new Configuration();
    configuration.put(HOST, "1.2.3.4");
    configuration.put(USER_NAME, "testUserName");
    configuration.put(SERIAL_NUMBER, "testSerialNumber");
    hueBridge = (Bridge) thingRegistry.createThingOfType(BRIDGE_THING_TYPE_UID, BRIDGE_THING_UID, null, "Bridge", configuration);
    assertThat(hueBridge, is(notNullValue()));
    thingRegistry.add(hueBridge);
    hueBridgeHandler = getThingHandler(hueBridge, HueBridgeHandler.class);
    assertThat(hueBridgeHandler, is(notNullValue()));
    discoveryService = getService(DiscoveryService.class, HueLightDiscoveryService.class);
    assertThat(discoveryService, is(notNullValue()));
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration) HueLightDiscoveryService(org.eclipse.smarthome.binding.hue.internal.discovery.HueLightDiscoveryService) HueBridgeHandler(org.eclipse.smarthome.binding.hue.handler.HueBridgeHandler) DiscoveryService(org.eclipse.smarthome.config.discovery.DiscoveryService) HueLightDiscoveryService(org.eclipse.smarthome.binding.hue.internal.discovery.HueLightDiscoveryService) ThingRegistry(org.eclipse.smarthome.core.thing.ThingRegistry) Before(org.junit.Before)

Example 2 with HueBridgeHandler

use of org.eclipse.smarthome.binding.hue.handler.HueBridgeHandler in project smarthome by eclipse.

the class HueThingHandlerFactory method createHandler.

@Override
@Nullable
protected ThingHandler createHandler(Thing thing) {
    if (HueBridgeHandler.SUPPORTED_THING_TYPES.contains(thing.getThingTypeUID())) {
        HueBridgeHandler handler = new HueBridgeHandler((Bridge) thing);
        registerLightDiscoveryService(handler);
        return handler;
    } else if (HueLightHandler.SUPPORTED_THING_TYPES.contains(thing.getThingTypeUID())) {
        return new HueLightHandler(thing);
    } else {
        return null;
    }
}
Also used : HueLightHandler(org.eclipse.smarthome.binding.hue.handler.HueLightHandler) HueBridgeHandler(org.eclipse.smarthome.binding.hue.handler.HueBridgeHandler) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 3 with HueBridgeHandler

use of org.eclipse.smarthome.binding.hue.handler.HueBridgeHandler 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)

Aggregations

HueBridgeHandler (org.eclipse.smarthome.binding.hue.handler.HueBridgeHandler)3 HueLightDiscoveryService (org.eclipse.smarthome.binding.hue.internal.discovery.HueLightDiscoveryService)2 Nullable (org.eclipse.jdt.annotation.Nullable)1 HueLightHandler (org.eclipse.smarthome.binding.hue.handler.HueLightHandler)1 Configuration (org.eclipse.smarthome.config.core.Configuration)1 DiscoveryService (org.eclipse.smarthome.config.discovery.DiscoveryService)1 ThingRegistry (org.eclipse.smarthome.core.thing.ThingRegistry)1 Before (org.junit.Before)1