Search in sources :

Example 76 with Item

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;
}
Also used : Item(org.eclipse.smarthome.core.items.Item) Channel(org.eclipse.smarthome.core.thing.Channel) ItemChannelLink(org.eclipse.smarthome.core.thing.link.ItemChannelLink) ConfigDescription(org.eclipse.smarthome.config.core.ConfigDescription) ConfigDescriptionParameter(org.eclipse.smarthome.config.core.ConfigDescriptionParameter) Thing(org.eclipse.smarthome.core.thing.Thing)

Example 77 with Item

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()));
}
Also used : Item(org.eclipse.smarthome.core.items.Item) State(org.eclipse.smarthome.core.types.State)

Example 78 with Item

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;
}
Also used : GenericItem(org.eclipse.smarthome.core.items.GenericItem) Item(org.eclipse.smarthome.core.items.Item) Deactivate(org.osgi.service.component.annotations.Deactivate)

Example 79 with Item

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();
}
Also used : GenericItem(org.eclipse.smarthome.core.items.GenericItem) Item(org.eclipse.smarthome.core.items.Item)

Example 80 with Item

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
        }
    }
}
Also used : GenericItem(org.eclipse.smarthome.core.items.GenericItem) Item(org.eclipse.smarthome.core.items.Item) Command(org.eclipse.smarthome.core.types.Command) Rule(org.eclipse.smarthome.model.rule.rules.Rule) ItemNotFoundException(org.eclipse.smarthome.core.items.ItemNotFoundException)

Aggregations

Item (org.eclipse.smarthome.core.items.Item)111 GroupItem (org.eclipse.smarthome.core.items.GroupItem)42 GenericItem (org.eclipse.smarthome.core.items.GenericItem)39 ItemNotFoundException (org.eclipse.smarthome.core.items.ItemNotFoundException)37 SwitchItem (org.eclipse.smarthome.core.library.items.SwitchItem)35 NumberItem (org.eclipse.smarthome.core.library.items.NumberItem)31 State (org.eclipse.smarthome.core.types.State)26 Test (org.junit.Test)26 ItemRegistry (org.eclipse.smarthome.core.items.ItemRegistry)14 RollershutterItem (org.eclipse.smarthome.core.library.items.RollershutterItem)14 StringItem (org.eclipse.smarthome.core.library.items.StringItem)14 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)13 DimmerItem (org.eclipse.smarthome.core.library.items.DimmerItem)12 ColorItem (org.eclipse.smarthome.core.library.items.ColorItem)10 IntentInterpretation (org.openhab.ui.habot.nlp.IntentInterpretation)10 EventPublisher (org.eclipse.smarthome.core.events.EventPublisher)9 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)9 Thing (org.eclipse.smarthome.core.thing.Thing)9 Set (java.util.Set)8 Widget (org.eclipse.smarthome.model.sitemap.Widget)8