use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class ThingRegistryOSGiTest method assertThatCreateThingDelegatesToRegisteredThingHandlerFactory.
@Test
public void assertThatCreateThingDelegatesToRegisteredThingHandlerFactory() {
ThingTypeUID expectedThingTypeUID = THING_TYPE_UID;
ThingUID expectedThingUID = new ThingUID(THING_TYPE_UID, THING1_ID);
Configuration expectedConfiguration = new Configuration();
ThingUID expectedBridgeUID = new ThingUID(THING_TYPE_UID, THING2_ID);
String expectedLabel = "Test Thing";
AsyncResultWrapper<Thing> thingResultWrapper = new AsyncResultWrapper<Thing>();
ThingRegistry thingRegistry = getService(ThingRegistry.class);
ThingHandlerFactory thingHandlerFactory = new BaseThingHandlerFactory() {
@Override
public boolean supportsThingType(@NonNull ThingTypeUID thingTypeUID) {
return true;
}
@Override
@Nullable
protected ThingHandler createHandler(@NonNull Thing thing) {
return null;
}
@Override
@Nullable
public Thing createThing(@NonNull ThingTypeUID thingTypeUID, @NonNull Configuration configuration, @Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID) {
assertThat(thingTypeUID, is(expectedThingTypeUID));
assertThat(configuration, is(expectedConfiguration));
assertThat(thingUID, is(expectedThingUID));
assertThat(bridgeUID, is(expectedBridgeUID));
Thing thing = ThingBuilder.create(thingTypeUID, thingUID.getId()).withBridge(bridgeUID).build();
thingResultWrapper.set(thing);
return thing;
}
};
registerThingHandlerFactory(thingHandlerFactory);
Thing thing = thingRegistry.createThingOfType(expectedThingTypeUID, expectedThingUID, expectedBridgeUID, expectedLabel, expectedConfiguration);
waitForAssert(() -> {
assertTrue(thingResultWrapper.isSet());
});
assertThat(thing, is(thingResultWrapper.getWrappedObject()));
}
use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class ThingRegistryOSGiTest method assertThatThingRegistryThrowsExceptionForConfigUpdateOfNonExistingThing.
@Test(expected = IllegalArgumentException.class)
public void assertThatThingRegistryThrowsExceptionForConfigUpdateOfNonExistingThing() {
ThingRegistry thingRegistry = getService(ThingRegistry.class);
ThingUID thingUID = new ThingUID(THING_TYPE_UID, "binding:type:thing");
Map<String, Object> parameters = new HashMap<>();
parameters.put("param", "value1");
thingRegistry.updateConfiguration(thingUID, parameters);
}
use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class ThingActionService method getThingStatusInfo.
public static ThingStatusInfo getThingStatusInfo(String thingUid) {
ThingUID uid = new ThingUID(thingUid);
Thing thing = thingRegistry.get(uid);
if (thing != null) {
return thing.getStatusInfo();
} else {
return null;
}
}
use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class MagicDiscoveryService method startScan.
@Override
protected void startScan() {
String serialNumber = createRandomSerialNumber();
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(new ThingUID(MagicBindingConstants.THING_TYPE_CONFIG_THING, serialNumber)).withRepresentationProperty(Thing.PROPERTY_SERIAL_NUMBER).withProperty(Thing.PROPERTY_SERIAL_NUMBER, serialNumber).withLabel("Magic Thing").build();
thingDiscovered(discoveryResult);
}
use of org.eclipse.smarthome.core.thing.ThingUID in project smarthome by eclipse.
the class DigitalSTROMHandlerFactory method createHandler.
@Override
protected ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (thingTypeUID == null) {
return null;
}
if (BridgeHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
BridgeHandler handler = new BridgeHandler((Bridge) thing);
if (bridgeHandlers == null) {
bridgeHandlers = new HashMap<ThingUID, BridgeHandler>();
}
bridgeHandlers.put(thing.getUID(), handler);
DiscoveryServiceManager discoveryServiceManager = new DiscoveryServiceManager(handler);
discoveryServiceManager.registerDiscoveryServices(bundleContext);
discoveryServiceManagers.put(handler.getThing().getUID().getAsString(), discoveryServiceManager);
return handler;
}
if (DeviceHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new DeviceHandler(thing);
}
if (CircuitHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new CircuitHandler(thing);
}
if (ZoneTemperatureControlHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new ZoneTemperatureControlHandler(thing);
}
if (SceneHandler.SUPPORTED_THING_TYPES.contains(thingTypeUID)) {
return new SceneHandler(thing);
}
return null;
}
Aggregations