use of org.openhab.core.thing.link.ItemChannelLink in project openhab-core by openhab.
the class ChannelLinkNotifierOSGiTest method updateLinks.
private void updateLinks(Thing thing, String itemSuffix) {
forEachThingChannelUID(thing, channelUID -> {
String itemName = getItemName(thing, channelUID, itemSuffix);
managedItemChannelLinkProvider.update(new ItemChannelLink(itemName, channelUID));
});
}
use of org.openhab.core.thing.link.ItemChannelLink in project openhab-addons by openhab.
the class FeedHandlerTest method initializeItem.
private void initializeItem(ChannelUID channelUID) {
// Create new item
ItemRegistry itemRegistry = getService(ItemRegistry.class);
assertThat(itemRegistry, is(notNullValue()));
StringItem newItem = new StringItem(ITEM_NAME);
// Add item state change listener
StateChangeListener updateListener = new StateChangeListener() {
@Override
public void stateChanged(Item item, State oldState, State newState) {
}
@Override
public void stateUpdated(Item item, State state) {
currentItemState = (StringType) state;
}
};
newItem.addStateChangeListener(updateListener);
itemRegistry.add(newItem);
// Add item channel link
ManagedItemChannelLinkProvider itemChannelLinkProvider = getService(ManagedItemChannelLinkProvider.class);
assertThat(itemChannelLinkProvider, is(notNullValue()));
itemChannelLinkProvider.add(new ItemChannelLink(ITEM_NAME, channelUID));
}
use of org.openhab.core.thing.link.ItemChannelLink in project openhab-addons by openhab.
the class AbstractModbusOSGiTest method linkItem.
protected void linkItem(String itemName, ChannelUID channelUID) {
logger.debug("Linking {} <-> {}", itemName, channelUID);
ItemChannelLink link = new ItemChannelLink(itemName, channelUID);
assertThat(addedLinks.contains(link), not(equalTo(true)));
itemChannelLinkProvider.add(link);
addedLinks.add(link);
}
use of org.openhab.core.thing.link.ItemChannelLink in project openhab-addons by openhab.
the class NtpOSGiTest method initialize.
private void initialize(Configuration configuration, String channelID, String acceptedItemType, Configuration channelConfiguration) {
configuration.put(NtpBindingConstants.PROPERTY_NTP_SERVER_PORT, TEST_PORT);
ThingUID ntpUid = new ThingUID(NtpBindingConstants.THING_TYPE_NTP, TEST_THING_ID);
ChannelUID channelUID = new ChannelUID(ntpUid, channelID);
Channel channel = ChannelBuilder.create(channelUID, acceptedItemType).withType(channelTypeUID).withConfiguration(channelConfiguration).withLabel("label").withKind(ChannelKind.STATE).build();
ntpThing = ThingBuilder.create(NtpBindingConstants.THING_TYPE_NTP, ntpUid).withConfiguration(configuration).withChannel(channel).build();
managedThingProvider.add(ntpThing);
// Wait for the NTP thing to be added to the ManagedThingProvider.
ntpHandler = waitForAssert(() -> {
final ThingHandler thingHandler = ntpThing.getHandler();
assertThat(thingHandler, is(instanceOf(NtpHandler.class)));
return (NtpHandler) thingHandler;
}, DFL_TIMEOUT * 3, DFL_SLEEP_TIME);
if (acceptedItemType.equals(ACCEPTED_ITEM_TYPE_STRING)) {
testItem = new StringItem(TEST_ITEM_NAME);
} else if (acceptedItemType.equals(ACCEPTED_ITEM_TYPE_DATE_TIME)) {
testItem = new DateTimeItem(TEST_ITEM_NAME);
}
itemRegistry.add(testItem);
// Wait for the item , linked to the NTP thing to be added to the
// ManagedThingProvider.
final ManagedItemChannelLinkProvider itemChannelLinkProvider = waitForAssert(() -> {
final ManagedItemChannelLinkProvider tmp = getService(ManagedItemChannelLinkProvider.class);
assertNotNull(tmp);
return tmp;
});
itemChannelLinkProvider.add(new ItemChannelLink(TEST_ITEM_NAME, channelUID));
}
Aggregations