use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class GenericItemChannelLinkProviderJavaTest method testMultiLinkConfiguration.
@Test
public void testMultiLinkConfiguration() {
Collection<Thing> things = thingRegistry.getAll();
assertThat(things.size(), is(0));
String thingsModel = "Bridge hue:bridge:huebridge [ ipAddress = \"192.168.3.84\", userName = \"19fc3fa6fc870a4280a55f21315631f\" ] {" + //
"LCT001 bulb2 [ lightId = \"2\" ]" + //
"LCT001 bulb3 [ lightId = \"3\" ]" + //
"LCT001 bulb4 [ lightId = \"4\" ]" + "}";
modelRepository.addOrRefreshModel(THINGS_TESTMODEL_NAME, new ByteArrayInputStream(thingsModel.getBytes()));
String itemsModel = //
"Color Light3Color \"Light3 Color\" { " + //
"channel=\"hue:LCT001:huebridge:bulb2:color,hue:LCT001:huebridge:bulb3:color\" [ value=1 ]," + //
"channel=\"hue:LCT001:huebridge:bulb4:color\" [ value=2 ]" + "}";
modelRepository.addOrRefreshModel(ITEMS_TESTMODEL_NAME, new ByteArrayInputStream(itemsModel.getBytes()));
waitForAssert(() -> {
assertThat(thingRegistry.getAll().size(), is(4));
assertThat(itemRegistry.getItems().size(), is(1));
assertThat(itemChannelLinkRegistry.getAll().size(), is(3));
});
assertEquals(new BigDecimal(1), itemChannelLinkRegistry.get("Light3Color -> hue:LCT001:huebridge:bulb2:color").getConfiguration().get("value"));
assertEquals(new BigDecimal(1), itemChannelLinkRegistry.get("Light3Color -> hue:LCT001:huebridge:bulb3:color").getConfiguration().get("value"));
assertEquals(new BigDecimal(2), itemChannelLinkRegistry.get("Light3Color -> hue:LCT001:huebridge:bulb4:color").getConfiguration().get("value"));
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class BridgeHandler method setStatus.
private void setStatus(ThingStatus status) {
logger.debug("set status to: {}", status);
updateStatus(status);
for (Thing thing : getThing().getThings()) {
ThingHandler handler = thing.getHandler();
if (handler != null) {
handler.bridgeStatusChanged(getThing().getStatusInfo());
}
}
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class Job method scheduleEvent.
/**
* Schedules an {@link EventJob} instance
*
* @param thingUID the Thing UID
* @param astroHandler the {@link ThingHandler} instance
* @param eventAt the {@link Calendar} instance denoting scheduled instant
* @param events the event IDs to schedule
* @param channelId the channel ID
*/
public static void scheduleEvent(String thingUID, AstroThingHandler astroHandler, Calendar eventAt, List<String> events, String channelId, boolean configAlreadyApplied) {
boolean thingNull = checkNull(thingUID, "Thing UID is null");
boolean astroHandlerNull = checkNull(astroHandler, "AstroThingHandler is null");
boolean eventAtNull = checkNull(eventAt, "Scheduled Instant is null");
boolean eventsNull = checkNull(events, "Events list is null");
boolean channelIdNull = checkNull(channelId, "Channel ID is null");
if (thingNull || astroHandlerNull || eventAtNull || eventsNull || channelIdNull || events.isEmpty()) {
return;
}
final Calendar instant;
if (!configAlreadyApplied) {
final Channel channel = astroHandler.getThing().getChannel(channelId);
if (channel == null) {
LOGGER.warn("Cannot find channel '{}' for thing '{}'.", channelId, astroHandler.getThing().getUID());
return;
}
AstroChannelConfig config = channel.getConfiguration().as(AstroChannelConfig.class);
instant = applyConfig(eventAt, config);
} else {
instant = eventAt;
}
List<Job> jobs = events.stream().map(e -> new EventJob(thingUID, channelId, e)).collect(toList());
schedule(thingUID, astroHandler, new CompositeJob(thingUID, jobs), instant);
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class NtpOSGiTest method tearDown.
@After
public void tearDown() {
if (ntpThing != null) {
Thing removedThing = thingRegistry.forceRemove(ntpThing.getUID());
assertNotNull(removedThing);
}
if (testItem != null) {
itemRegistry.remove(TEST_ITEM_NAME);
}
}
use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.
the class TradfriGatewayHandler method thingUpdated.
@Override
public void thingUpdated(Thing thing) {
super.thingUpdated(thing);
logger.info("Bridge configuration updated. Updating paired things (if any).");
for (Thing t : getThing().getThings()) {
final ThingHandler thingHandler = t.getHandler();
if (thingHandler != null) {
thingHandler.thingUpdated(t);
}
}
}
Aggregations