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()));
}
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;
}
}
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());
}
}
}
Aggregations