Search in sources :

Example 1 with ListBidcosInterfacesParser

use of org.eclipse.smarthome.binding.homematic.internal.communicator.parser.ListBidcosInterfacesParser in project smarthome by eclipse.

the class RpcClient method getGatewayInfo.

/**
 * Tries to identify the gateway and returns the GatewayInfo.
 */
public HmGatewayInfo getGatewayInfo(String id) throws IOException {
    boolean isHomegear = false;
    GetDeviceDescriptionParser ddParser;
    ListBidcosInterfacesParser biParser;
    try {
        ddParser = getDeviceDescription(HmInterface.RF);
        isHomegear = StringUtils.equalsIgnoreCase(ddParser.getType(), "Homegear");
    } catch (IOException ex) {
        // can't load gateway infos via RF interface
        ddParser = new GetDeviceDescriptionParser();
    }
    try {
        biParser = listBidcosInterfaces(HmInterface.RF);
    } catch (IOException ex) {
        biParser = listBidcosInterfaces(HmInterface.HMIP);
    }
    HmGatewayInfo gatewayInfo = new HmGatewayInfo();
    gatewayInfo.setAddress(biParser.getGatewayAddress());
    if (isHomegear) {
        gatewayInfo.setId(HmGatewayInfo.ID_HOMEGEAR);
        gatewayInfo.setType(ddParser.getType());
        gatewayInfo.setFirmware(ddParser.getFirmware());
    } else if ((StringUtils.startsWithIgnoreCase(biParser.getType(), "CCU") || StringUtils.startsWithIgnoreCase(biParser.getType(), "HMIP_CCU") || StringUtils.startsWithIgnoreCase(ddParser.getType(), "HM-RCV-50") || config.isCCUType()) && !config.isNoCCUType()) {
        gatewayInfo.setId(HmGatewayInfo.ID_CCU);
        String type = StringUtils.isBlank(biParser.getType()) ? "CCU" : biParser.getType();
        gatewayInfo.setType(type);
        gatewayInfo.setFirmware(ddParser.getFirmware() != null ? ddParser.getFirmware() : biParser.getFirmware());
    } else {
        gatewayInfo.setId(HmGatewayInfo.ID_DEFAULT);
        gatewayInfo.setType(biParser.getType());
        gatewayInfo.setFirmware(biParser.getFirmware());
    }
    if (gatewayInfo.isCCU() || config.hasRfPort()) {
        gatewayInfo.setRfInterface(hasInterface(HmInterface.RF, id));
    }
    if (gatewayInfo.isCCU() || config.hasWiredPort()) {
        gatewayInfo.setWiredInterface(hasInterface(HmInterface.WIRED, id));
    }
    if (gatewayInfo.isCCU() || config.hasHmIpPort()) {
        gatewayInfo.setHmipInterface(hasInterface(HmInterface.HMIP, id));
    }
    if (gatewayInfo.isCCU() || config.hasCuxdPort()) {
        gatewayInfo.setCuxdInterface(hasInterface(HmInterface.CUXD, id));
    }
    if (gatewayInfo.isCCU() || config.hasGroupPort()) {
        gatewayInfo.setGroupInterface(hasInterface(HmInterface.GROUP, id));
    }
    return gatewayInfo;
}
Also used : HmGatewayInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmGatewayInfo) GetDeviceDescriptionParser(org.eclipse.smarthome.binding.homematic.internal.communicator.parser.GetDeviceDescriptionParser) IOException(java.io.IOException) ListBidcosInterfacesParser(org.eclipse.smarthome.binding.homematic.internal.communicator.parser.ListBidcosInterfacesParser)

Aggregations

IOException (java.io.IOException)1 GetDeviceDescriptionParser (org.eclipse.smarthome.binding.homematic.internal.communicator.parser.GetDeviceDescriptionParser)1 ListBidcosInterfacesParser (org.eclipse.smarthome.binding.homematic.internal.communicator.parser.ListBidcosInterfacesParser)1 HmGatewayInfo (org.eclipse.smarthome.binding.homematic.internal.model.HmGatewayInfo)1