use of org.eclipse.smarthome.core.thing.Channel in project smarthome by eclipse.
the class ItemChannelLinkConfigDescriptionProvider method getConfigDescription.
@Override
public ConfigDescription getConfigDescription(URI uri, Locale locale) {
if (SCHEME.equals(uri.getScheme())) {
ItemChannelLink link = itemChannelLinkRegistry.get(uri.getSchemeSpecificPart());
if (link == null) {
return null;
}
Item item = itemRegistry.get(link.getItemName());
if (item == null) {
return null;
}
Thing thing = thingRegistry.get(link.getLinkedUID().getThingUID());
if (thing == null) {
return null;
}
Channel channel = thing.getChannel(link.getLinkedUID().getId());
if (channel == null) {
return null;
}
ConfigDescriptionParameter paramProfile = ConfigDescriptionParameterBuilder.create(PARAM_PROFILE, Type.TEXT).withLabel("Profile").withDescription("the profile to use").withRequired(false).withLimitToOptions(true).withOptions(getOptions(link, item, channel, locale)).build();
return new ConfigDescription(uri, Collections.singletonList(paramProfile));
}
return null;
}
use of org.eclipse.smarthome.core.thing.Channel in project smarthome by eclipse.
the class ChannelItemProvider method createItemForLink.
private void createItemForLink(ItemChannelLink link) {
if (!enabled) {
return;
}
if (itemRegistry.get(link.getItemName()) != null) {
// there is already an item, we do not need to create one
return;
}
Channel channel = thingRegistry.getChannel(link.getLinkedUID());
if (channel != null) {
Item item = null;
// Only create an item for state channels
if (channel.getKind() == ChannelKind.STATE) {
for (ItemFactory itemFactory : itemFactories) {
item = itemFactory.createItem(channel.getAcceptedItemType(), link.getItemName());
if (item != null) {
break;
}
}
}
if (item instanceof GenericItem) {
GenericItem gItem = (GenericItem) item;
gItem.setLabel(getLabel(channel));
gItem.setCategory(getCategory(channel));
gItem.addTags(channel.getDefaultTags());
}
if (item != null) {
items.put(item.getName(), item);
for (ProviderChangeListener<Item> listener : listeners) {
listener.added(this, item);
}
}
}
}
use of org.eclipse.smarthome.core.thing.Channel in project smarthome by eclipse.
the class BridgeBuilder method create.
public static BridgeBuilder create(ThingTypeUID thingTypeUID, String bridgeId) {
BridgeImpl bridge = new BridgeImpl(thingTypeUID, bridgeId);
bridge.setChannels(new ArrayList<Channel>());
return new BridgeBuilder(bridge);
}
use of org.eclipse.smarthome.core.thing.Channel in project smarthome by eclipse.
the class EnrichedThingDTOMapperTest method mockChannels.
private List<Channel> mockChannels() {
List<Channel> channels = new ArrayList<>();
channels.add(ChannelBuilder.create(new ChannelUID(THING_TYPE_UID + ":" + UID + ":1"), ITEM_TYPE).build());
channels.add(ChannelBuilder.create(new ChannelUID(THING_TYPE_UID + ":" + UID + ":2"), ITEM_TYPE).build());
return channels;
}
use of org.eclipse.smarthome.core.thing.Channel in project smarthome by eclipse.
the class LifxLightHandler method addRemoveZoneChannels.
private void addRemoveZoneChannels(int zones) {
List<Channel> newChannels = new ArrayList<>();
// retain non-zone channels
for (Channel channel : getThing().getChannels()) {
String channelId = channel.getUID().getId();
if (!channelId.startsWith(CHANNEL_COLOR_ZONE) && !channelId.startsWith(CHANNEL_TEMPERATURE_ZONE)) {
newChannels.add(channel);
}
}
// add zone channels
for (int i = 0; i < zones; i++) {
newChannels.add(channelFactory.createColorZoneChannel(getThing().getUID(), i));
newChannels.add(channelFactory.createTemperatureZoneChannel(getThing().getUID(), i));
}
updateThing(editThing().withChannels(newChannels).build());
Map<String, String> properties = editProperties();
properties.put(LifxBindingConstants.PROPERTY_ZONES, Integer.toString(zones));
updateProperties(properties);
}
Aggregations