Search in sources :

Example 1 with SappAddressType

use of org.openhab.binding.sapp.internal.model.SappAddressType in project openhab1-addons by openhab.

the class SappBindingConfigDimmerItem method parseSappAddressStatus.

private SappAddressDimmer parseSappAddressStatus(String bindingStringAddress) throws BindingConfigParseException {
    String pnmasId;
    SappAddressType addressType;
    int address;
    String subAddress;
    int increment;
    String[] bindingAddress = bindingStringAddress.split(":");
    if (bindingAddress.length != 5) {
        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));
    }
    // increment
    try {
        increment = Integer.parseInt(bindingAddress[4]);
    } catch (NumberFormatException e) {
        throw new BindingConfigParseException(errorMessage(bindingStringAddress));
    }
    return new SappAddressDimmer(pnmasId, addressType, address, subAddress, 0, 100, increment);
}
Also used : SappAddressDimmer(org.openhab.binding.sapp.internal.model.SappAddressDimmer) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException) SappAddressType(org.openhab.binding.sapp.internal.model.SappAddressType)

Example 2 with SappAddressType

use of org.openhab.binding.sapp.internal.model.SappAddressType in project openhab1-addons by openhab.

the class SappBindingConfigRollershutterItem method parseSappAddressStatus.

private SappAddressRollershutterStatus parseSappAddressStatus(String bindingStringAddress) throws BindingConfigParseException {
    String pnmasId;
    SappAddressType addressType;
    int address;
    String subAddress;
    int openValue;
    int closedValue;
    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));
    }
    // openValue
    try {
        openValue = Integer.parseInt(bindingAddress[4]);
    } catch (NumberFormatException e) {
        throw new BindingConfigParseException(errorMessage(bindingStringAddress));
    }
    // closedValue
    try {
        closedValue = Integer.parseInt(bindingAddress[5]);
    } catch (NumberFormatException e) {
        throw new BindingConfigParseException(errorMessage(bindingStringAddress));
    }
    return new SappAddressRollershutterStatus(pnmasId, addressType, address, subAddress, openValue, closedValue);
}
Also used : SappAddressRollershutterStatus(org.openhab.binding.sapp.internal.model.SappAddressRollershutterStatus) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException) SappAddressType(org.openhab.binding.sapp.internal.model.SappAddressType)

Example 3 with SappAddressType

use of org.openhab.binding.sapp.internal.model.SappAddressType in project openhab1-addons by openhab.

the class SappBindingConfigRollershutterItem method parseSappAddressControl.

private SappAddressRollershutterControl parseSappAddressControl(String bindingStringAddress) throws BindingConfigParseException {
    String pnmasId;
    SappAddressType addressType;
    int address;
    String subAddress;
    int activateValue;
    String[] bindingAddress = bindingStringAddress.split(":");
    if (bindingAddress.length != 4 && bindingAddress.length != 5) {
        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));
    }
    // activateValue
    try {
        activateValue = Integer.parseInt(bindingAddress[4]);
    } catch (NumberFormatException e) {
        throw new BindingConfigParseException(errorMessage(bindingStringAddress));
    }
    return new SappAddressRollershutterControl(pnmasId, addressType, address, subAddress, activateValue);
}
Also used : BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException) SappAddressRollershutterControl(org.openhab.binding.sapp.internal.model.SappAddressRollershutterControl) SappAddressType(org.openhab.binding.sapp.internal.model.SappAddressType)

Example 4 with SappAddressType

use of org.openhab.binding.sapp.internal.model.SappAddressType in project openhab1-addons by openhab.

the class SappBindingConfigSwitchItem method parseSappAddressStatus.

private SappAddressOnOffStatus parseSappAddressStatus(String bindingStringAddress) throws BindingConfigParseException {
    String pnmasId;
    SappAddressType addressType;
    int address;
    String subAddress;
    int onValue = 1;
    String[] bindingAddress = bindingStringAddress.split(":");
    if (bindingAddress.length != 4 && bindingAddress.length != 5) {
        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));
    }
    // onvalue, offvalue
    if (bindingAddress.length == 5) {
        try {
            onValue = Integer.parseInt(bindingAddress[4]);
        } catch (NumberFormatException e) {
            throw new BindingConfigParseException(errorMessage(bindingStringAddress));
        }
    }
    return new SappAddressOnOffStatus(pnmasId, addressType, address, subAddress, onValue);
}
Also used : SappAddressOnOffStatus(org.openhab.binding.sapp.internal.model.SappAddressOnOffStatus) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException) SappAddressType(org.openhab.binding.sapp.internal.model.SappAddressType)

Example 5 with SappAddressType

use of org.openhab.binding.sapp.internal.model.SappAddressType in project openhab1-addons by openhab.

the class SappBindingConfigContactItem method parseSappAddressStatus.

private SappAddressOpenClosedStatus parseSappAddressStatus(String bindingStringAddress) throws BindingConfigParseException {
    String pnmasId;
    SappAddressType addressType;
    int address;
    String subAddress;
    int openValue = 1;
    String[] bindingAddress = bindingStringAddress.split(":");
    if (bindingAddress.length != 4 && bindingAddress.length != 5) {
        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));
    }
    // openvalue
    if (bindingAddress.length == 5) {
        try {
            openValue = Integer.parseInt(bindingAddress[4]);
        } catch (NumberFormatException e) {
            throw new BindingConfigParseException(errorMessage(bindingStringAddress));
        }
    }
    return new SappAddressOpenClosedStatus(pnmasId, addressType, address, subAddress, openValue);
}
Also used : SappAddressOpenClosedStatus(org.openhab.binding.sapp.internal.model.SappAddressOpenClosedStatus) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException) SappAddressType(org.openhab.binding.sapp.internal.model.SappAddressType)

Aggregations

SappAddressType (org.openhab.binding.sapp.internal.model.SappAddressType)7 BindingConfigParseException (org.openhab.model.item.binding.BindingConfigParseException)7 SappAddressDecimal (org.openhab.binding.sapp.internal.model.SappAddressDecimal)1 SappAddressDimmer (org.openhab.binding.sapp.internal.model.SappAddressDimmer)1 SappAddressOnOffControl (org.openhab.binding.sapp.internal.model.SappAddressOnOffControl)1 SappAddressOnOffStatus (org.openhab.binding.sapp.internal.model.SappAddressOnOffStatus)1 SappAddressOpenClosedStatus (org.openhab.binding.sapp.internal.model.SappAddressOpenClosedStatus)1 SappAddressRollershutterControl (org.openhab.binding.sapp.internal.model.SappAddressRollershutterControl)1 SappAddressRollershutterStatus (org.openhab.binding.sapp.internal.model.SappAddressRollershutterStatus)1