use of org.openhab.binding.sapp.internal.model.SappAddressType in project openhab1-addons by openhab.
the class SappBindingConfigNumberItem method parseSappAddressStatus.
private SappAddressDecimal parseSappAddressStatus(String bindingStringAddress) throws BindingConfigParseException {
String pnmasId;
SappAddressType addressType;
int address;
String subAddress;
int minScale;
int maxScale;
String[] bindingAddress = bindingStringAddress.split(":");
if (bindingAddress.length != 4 && bindingAddress.length != 6) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
// pnmasId
pnmasId = bindingAddress[0];
if (pnmasId.length() == 0) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
// addressType
addressType = SappAddressType.fromString(bindingAddress[1].toUpperCase());
if (!validAddresses.keySet().contains(addressType)) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
// address
try {
address = Integer.parseInt(bindingAddress[2]);
if (address < validAddresses.get(addressType).getLoRange() || address > validAddresses.get(addressType).getHiRange()) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
} catch (NumberFormatException e) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
// subaddress
subAddress = bindingAddress[3].toUpperCase();
if (!ArrayUtils.contains(validSubAddresses, subAddress)) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
if (bindingAddress.length == 6) {
try {
minScale = Integer.parseInt(bindingAddress[4]);
maxScale = Integer.parseInt(bindingAddress[5]);
} catch (NumberFormatException e) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
return new SappAddressDecimal(pnmasId, addressType, address, subAddress, minScale, maxScale);
} else {
return new SappAddressDecimal(pnmasId, addressType, address, subAddress);
}
}
use of org.openhab.binding.sapp.internal.model.SappAddressType in project openhab1-addons by openhab.
the class SappBindingConfigSwitchItem method parseSappAddressControl.
private SappAddressOnOffControl parseSappAddressControl(String bindingStringAddress) throws BindingConfigParseException {
String pnmasId;
SappAddressType addressType;
int address;
String subAddress;
int onValue = 1;
int offValue = 0;
String[] bindingAddress = bindingStringAddress.split(":");
if (bindingAddress.length != 4 && bindingAddress.length != 6) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
// pnmasId
pnmasId = bindingAddress[0];
if (pnmasId.length() == 0) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
// addressType
addressType = SappAddressType.fromString(bindingAddress[1].toUpperCase());
if (!validAddresses.keySet().contains(addressType)) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
if (addressType != SappAddressType.VIRTUAL) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
// address
try {
address = Integer.parseInt(bindingAddress[2]);
if (address < validAddresses.get(addressType).getLoRange() || address > validAddresses.get(addressType).getHiRange()) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
} catch (NumberFormatException e) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
// subaddress
subAddress = bindingAddress[3].toUpperCase();
if (!ArrayUtils.contains(validSubAddresses, subAddress)) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
// onvalue, offvalue
if (bindingAddress.length == 6) {
try {
onValue = Integer.parseInt(bindingAddress[4]);
offValue = Integer.parseInt(bindingAddress[5]);
} catch (NumberFormatException e) {
throw new BindingConfigParseException(errorMessage(bindingStringAddress));
}
}
return new SappAddressOnOffControl(pnmasId, addressType, address, subAddress, onValue, offValue);
}
Aggregations