use of org.openhab.binding.tinkerforge.internal.config.DeviceOptions in project openhab1-addons by openhab.
the class TinkerforgeGenericBindingProvider method processBindingConfiguration.
/**
* {@inheritDoc}
*/
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
// parse bindingconfig here ...
if (bindingConfig == null) {
logger.error("got bindingConfig null for item: {}", item.getName());
} else {
TinkerforgeBindingConfig config = new TinkerforgeBindingConfig();
DeviceOptions deviceOptions = new DeviceOptions();
String[] tokens = bindingConfig.trim().split(",");
for (String token : tokens) {
token = token.trim();
logger.debug("token: {}", token);
String[] confStatement = token.split("=");
if (confStatement.length != 2) {
throw new BindingConfigParseException("TinkerforgeGenericBindingProvider:processBindingConfiguration: invalid format, the entry must consist of key=value pair, but value was found." + token);
} else {
String key = confStatement[0];
String value = confStatement[1];
if (key.equals(ConfigKey.uid.name())) {
config.setUid(value);
} else if (key.equals(ConfigKey.subid.name())) {
config.setSubId(value);
} else if (key.equals(ConfigKey.name.name())) {
config.setName(value);
} else {
deviceOptions.put(key, value);
}
}
}
config.setDeviceOptions(deviceOptions);
config.setItem(item);
addBindingConfig(item, config);
}
}
Aggregations