use of org.eclipse.smarthome.core.items.Item 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.items.Item in project smarthome by eclipse.
the class ProfileCallbackImpl method sendUpdate.
@Override
public void sendUpdate(State state) {
Item item = itemProvider.apply(link.getItemName());
State acceptedState = itemStateConverter.convertToAcceptedState(state, item);
eventPublisher.post(ItemEventFactory.createStateEvent(link.getItemName(), acceptedState, link.getLinkedUID().toString()));
}
use of org.eclipse.smarthome.core.items.Item in project smarthome by eclipse.
the class RuleEngineImpl method deactivate.
@Deactivate
public void deactivate() {
// unregister listeners
for (Item item : itemRegistry.getItems()) {
internalItemRemoved(item);
}
modelRepository.removeModelRepositoryChangeListener(this);
itemRegistry.removeRegistryChangeListener(this);
// execute all scripts that were registered for system shutdown
executeRules(triggerManager.getRules(SHUTDOWN));
triggerManager.clearAll();
triggerManager = null;
}
use of org.eclipse.smarthome.core.items.Item in project smarthome by eclipse.
the class RuleEngineImpl method allItemsChanged.
@Override
public void allItemsChanged(Collection<String> oldItemNames) {
// add the current items again
Collection<Item> items = itemRegistry.getItems();
for (Item item : items) {
internalItemAdded(item);
}
scheduleStartupRules();
}
use of org.eclipse.smarthome.core.items.Item in project smarthome by eclipse.
the class RuleEngineImpl method receiveCommand.
private void receiveCommand(ItemCommandEvent commandEvent) {
if (!starting && triggerManager != null && itemRegistry != null) {
String itemName = commandEvent.getItemName();
Command command = commandEvent.getItemCommand();
try {
Item item = itemRegistry.getItem(itemName);
Iterable<Rule> rules = triggerManager.getRules(COMMAND, item, command);
executeRules(rules, item, command);
} catch (ItemNotFoundException e) {
// ignore commands for non-existent items
}
}
}
Aggregations