use of org.openhab.binding.tellstick.internal.device.SupportedMethodsException in project openhab1-addons by openhab.
the class TellstickGenericBindingProvider method processBindingConfiguration.
/**
* {@inheritDoc}
*/
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
TellstickBindingConfig config = new TellstickBindingConfig();
config.setItemName(item.getName());
String[] configParts = bindingConfig.trim().split(":");
if (configParts.length < 1) {
throw new BindingConfigParseException("Tellstick binding must contain two parts separated by ':'");
}
TellstickDevice device;
try {
device = findDevice(configParts[0].trim());
} catch (SupportedMethodsException e) {
throw new BindingConfigParseException(e.getMessage());
}
validateBinding(item, configParts, device);
if (device == null) {
config.setId(Integer.valueOf(configParts[0].trim()));
} else {
config.setId(device.getId());
}
config.setValueSelector(TellstickValueSelector.getValueSelector(configParts[1].trim()));
if (configParts.length > 2 && configParts[2].trim().length() > 0) {
config.setUsageSelector(TellstickValueSelector.getValueSelector(configParts[2].trim()));
}
if (configParts.length > 3) {
if (isIntegerRegex(configParts[3])) {
config.setResend(Integer.parseInt(configParts[3]));
} else if (configParts[3].matches("^([0-9]+)/([0-9]+)$")) {
// Parse ie '3/300' into resend=3 and resendInterval=300
String[] resendParts = configParts[3].split("/");
config.setResend(Integer.parseInt(resendParts[0]));
config.setResendInterval(Long.parseLong(resendParts[1]));
} else {
config.setProtocol(configParts[3]);
}
}
logger.debug("Context:" + context + " Item " + item + " Conf:" + config);
addBindingConfig(item, config);
}
Aggregations