Search in sources :

Example 11 with Configuration

use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.

the class WemoCoffeeHandler method initialize.

@Override
public void initialize() {
    Configuration configuration = getConfig();
    if (configuration.get("udn") != null) {
        logger.debug("Initializing WemoCoffeeHandler for UDN '{}'", configuration.get("udn"));
        onSubscription();
        onUpdate();
        updateStatus(ThingStatus.ONLINE);
    } else {
        logger.debug("Cannot initalize WemoCoffeeHandler. UDN not set.");
    }
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration)

Example 12 with Configuration

use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.

the class WemoHandler method onUpdate.

private synchronized void onUpdate() {
    if (refreshJob == null || refreshJob.isCancelled()) {
        Configuration config = getThing().getConfiguration();
        int refreshInterval = DEFAULT_REFRESH_INTERVAL;
        Object refreshConfig = config.get("refresh");
        if (refreshConfig != null) {
            refreshInterval = ((BigDecimal) refreshConfig).intValue();
        }
        refreshJob = scheduler.scheduleWithFixedDelay(refreshRunnable, 0, refreshInterval, TimeUnit.SECONDS);
    }
}
Also used : Configuration(org.eclipse.smarthome.config.core.Configuration)

Example 13 with Configuration

use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.

the class RuleEngineTest method createTriggers.

private List<Trigger> createTriggers(String type) {
    List<Trigger> triggers = new ArrayList<Trigger>();
    Configuration configurations = new Configuration();
    configurations.put("a", "x");
    configurations.put("b", "y");
    configurations.put("c", "z");
    triggers.add(new Trigger("triggerId", type, configurations));
    return triggers;
}
Also used : Trigger(org.eclipse.smarthome.automation.Trigger) Configuration(org.eclipse.smarthome.config.core.Configuration) ArrayList(java.util.ArrayList)

Example 14 with Configuration

use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.

the class RuleEngineTest method createConditions.

private List<Condition> createConditions(String type) {
    List<Condition> conditions = new ArrayList<Condition>();
    Configuration configurations = new Configuration();
    configurations.put("a", "x");
    configurations.put("b", "y");
    configurations.put("c", "z");
    Map<String, String> inputs = new HashMap<String, String>(11);
    String ouputModuleId = "triggerId";
    String outputName = "triggerOutput";
    String inputName = "conditionInput";
    inputs.put(inputName, ouputModuleId + "." + outputName);
    conditions.add(new Condition("conditionId", type, configurations, inputs));
    return conditions;
}
Also used : Condition(org.eclipse.smarthome.automation.Condition) Configuration(org.eclipse.smarthome.config.core.Configuration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 15 with Configuration

use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.

the class RuleTemplateRegistry method copyTriggers.

private List<Trigger> copyTriggers(List<Trigger> triggers) {
    List<Trigger> res = new ArrayList<Trigger>(11);
    if (triggers != null) {
        for (Trigger t : triggers) {
            Configuration c = new Configuration();
            c.setProperties(t.getConfiguration().getProperties());
            Trigger trigger = new Trigger(t.getId(), t.getTypeUID(), c);
            trigger.setLabel(t.getLabel());
            trigger.setDescription(t.getDescription());
            res.add(trigger);
        }
    }
    return res;
}
Also used : Trigger(org.eclipse.smarthome.automation.Trigger) Configuration(org.eclipse.smarthome.config.core.Configuration) ArrayList(java.util.ArrayList)

Aggregations

Configuration (org.eclipse.smarthome.config.core.Configuration)119 Test (org.junit.Test)27 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)19 ArrayList (java.util.ArrayList)18 Thing (org.eclipse.smarthome.core.thing.Thing)18 Action (org.eclipse.smarthome.automation.Action)16 Trigger (org.eclipse.smarthome.automation.Trigger)16 Rule (org.eclipse.smarthome.automation.Rule)15 Before (org.junit.Before)14 Condition (org.eclipse.smarthome.automation.Condition)10 Bridge (org.eclipse.smarthome.core.thing.Bridge)9 ApiOperation (io.swagger.annotations.ApiOperation)8 ApiResponses (io.swagger.annotations.ApiResponses)8 HashMap (java.util.HashMap)8 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)8 Path (javax.ws.rs.Path)7 IOException (java.io.IOException)6 BigDecimal (java.math.BigDecimal)6 Consumes (javax.ws.rs.Consumes)6 RuleRegistry (org.eclipse.smarthome.automation.RuleRegistry)6