use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class HueBridgeHandler method updateBridgeThingConfiguration.
private void updateBridgeThingConfiguration(String userName) {
Configuration config = editConfiguration();
config.put(USER_NAME, userName);
try {
updateConfiguration(config);
logger.debug("Updated configuration parameter {} to '{}'", USER_NAME, userName);
} catch (IllegalStateException e) {
logger.trace("Configuration update failed.", e);
logger.warn("Unable to update configuration of Hue bridge.");
logger.warn("Please configure the following user name manually: {}", userName);
}
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class ReferenceResolverUtilTest method testModuleConfigurationResolving.
@Test
public void testModuleConfigurationResolving() {
// test trigger configuration..
Module trigger = new Trigger(null, null, new Configuration(moduleConfiguration));
ReferenceResolverUtil.updateModuleConfiguration(trigger, context);
Assert.assertEquals(trigger.getConfiguration(), new Configuration(expectedModuleConfiguration));
// test condition configuration..
Module condition = new Condition(null, null, new Configuration(moduleConfiguration), null);
ReferenceResolverUtil.updateModuleConfiguration(condition, context);
Assert.assertEquals(condition.getConfiguration(), new Configuration(expectedModuleConfiguration));
// test action configuration..
Module action = new Action(null, null, new Configuration(moduleConfiguration), null);
ReferenceResolverUtil.updateModuleConfiguration(action, context);
Assert.assertEquals(action.getConfiguration(), new Configuration(expectedModuleConfiguration));
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class RuleEngineTest method createActions.
private List<Action> createActions(String type) {
List<Action> actions = new ArrayList<Action>();
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 = "actionInput";
inputs.put(inputName, ouputModuleId + "." + outputName);
inputs.put("in6", ouputModuleId + "." + outputName);
actions.add(new Action("actionId", type, configurations, inputs));
return actions;
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class RuleEngineTest method testRuleConfigValue.
/**
* test rule configurations with real values
*/
@Test
public void testRuleConfigValue() {
RuleEngine ruleEngine = createRuleEngine();
List<ConfigDescriptionParameter> configDescriptions = createConfigDescriptions();
Configuration configurations = new Configuration();
configurations.put("config1", 5);
Rule rule4 = new Rule("rule4");
rule4.setTriggers(createTriggers("typeUID"));
rule4.setConditions(createConditions("typeUID"));
rule4.setActions(createActions("typeUID"));
rule4.setConfigurationDescriptions(configDescriptions);
rule4.setConfiguration(configurations);
ruleEngine.addRule(rule4, true);
RuntimeRule rule4Get = ruleEngine.getRuntimeRule("rule4");
Configuration rule4cfg = rule4Get.getConfiguration();
List<ConfigDescriptionParameter> rule4cfgD = rule4Get.getConfigurationDescriptions();
Assert.assertNotNull("Rule configuration is null", rule4cfg);
Assert.assertTrue("Missing config property in rule copy", rule4cfg.containsKey("config1"));
Assert.assertEquals("Wrong config value", new BigDecimal(5), rule4cfg.get("config1"));
Assert.assertNotNull("Rule configuration description is null", rule4cfgD);
Assert.assertEquals("Missing config description in rule copy", 1, rule4cfgD.size());
ConfigDescriptionParameter rule4cfgDP = rule4cfgD.iterator().next();
Assert.assertEquals("Wrong default value in config description", "3", rule4cfgDP.getDefault());
Assert.assertEquals("Wrong context value in config description", "context1", rule4cfgDP.getContext());
Assert.assertNotNull("Null options in config description", rule4cfgDP.getOptions());
Assert.assertEquals("Wrong option value in config description", "1", rule4cfgDP.getOptions().get(0).getValue());
Assert.assertEquals("Wrong option label in config description", "one", rule4cfgDP.getOptions().get(0).getLabel());
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class RuleEngine method normalizeModuleConfigurations.
private <T extends Module> void normalizeModuleConfigurations(List<@NonNull T> modules) {
for (Module module : modules) {
Configuration config = module.getConfiguration();
if (config != null) {
String type = module.getTypeUID();
ModuleType mt = mtRegistry.get(type);
if (mt != null) {
List<ConfigDescriptionParameter> configDescriptions = mt.getConfigurationDescriptions();
Map<String, ConfigDescriptionParameter> mapConfigDescriptions = getConfigDescriptionMap(configDescriptions);
normalizeConfiguration(config, mapConfigDescriptions);
}
}
}
}
Aggregations