use of org.openhab.binding.configadmin.ConfigAdminBindingProvider in project openhab1-addons by openhab.
the class ConfigAdminBinding method initializeBus.
/**
* Publishes the items with the configuration values.
*/
private void initializeBus() {
delayedExecutor.cancel();
delayedExecutor.schedule(new TimerTask() {
@Override
public void run() {
for (ConfigAdminBindingProvider provider : providers) {
for (String itemName : provider.getItemNames()) {
ConfigAdminBindingConfig bindingConfig = provider.getBindingConfig(itemName);
Configuration config = getConfiguration(bindingConfig);
postUpdate(config, bindingConfig);
}
}
}
}, 3000);
}
use of org.openhab.binding.configadmin.ConfigAdminBindingProvider in project openhab1-addons by openhab.
the class ConfigAdminBinding method internalReceiveCommand.
/**
* @{inheritDoc
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void internalReceiveCommand(String itemName, Command command) {
if (configAdmin != null) {
for (ConfigAdminBindingProvider provider : this.providers) {
ConfigAdminBindingConfig bindingConfig = provider.getBindingConfig(itemName);
Configuration config = getConfiguration(bindingConfig);
if (config != null) {
Dictionary props = config.getProperties();
props.put(bindingConfig.configParameter, command.toString());
try {
config.update(props);
} catch (IOException ioe) {
logger.error("updating Configuration '{}' with '{}' failed", bindingConfig.normalizedPid, command.toString());
}
logger.debug("successfully updated configuration (pid={}, value={})", bindingConfig.normalizedPid, command.toString());
} else {
logger.info("There is no configuration found for pid '{}'", bindingConfig.normalizedPid);
}
}
}
}
Aggregations