use of org.eclipse.smarthome.binding.homematic.internal.model.HmGatewayInfo in project smarthome by eclipse.
the class HomematicBridgeHandler method configureThingProperties.
private void configureThingProperties() {
final HmGatewayInfo info = config.getGatewayInfo();
final Map<String, String> properties = getThing().getProperties();
if (!properties.containsKey(PROPERTY_FIRMWARE_VERSION)) {
getThing().setProperty(PROPERTY_FIRMWARE_VERSION, info.getFirmware());
}
if (!properties.containsKey(PROPERTY_SERIAL_NUMBER)) {
getThing().setProperty(PROPERTY_SERIAL_NUMBER, info.getAddress());
}
if (!properties.containsKey(PROPERTY_MODEL_ID)) {
getThing().setProperty(PROPERTY_MODEL_ID, info.getType());
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmGatewayInfo in project smarthome by eclipse.
the class AbstractHomematicGateway method initialize.
@Override
public void initialize() throws IOException {
logger.debug("Initializing gateway with id '{}'", id);
HmGatewayInfo gatewayInfo = config.getGatewayInfo();
if (gatewayInfo.isHomegear()) {
// Homegear
availableInterfaces.put(HmInterface.RF, TransferMode.BIN_RPC);
} else if (gatewayInfo.isCCU()) {
// CCU
if (gatewayInfo.isRfInterface()) {
availableInterfaces.put(HmInterface.RF, TransferMode.XML_RPC);
}
if (gatewayInfo.isWiredInterface()) {
availableInterfaces.put(HmInterface.WIRED, TransferMode.XML_RPC);
}
if (gatewayInfo.isHmipInterface()) {
availableInterfaces.put(HmInterface.HMIP, TransferMode.XML_RPC);
}
if (gatewayInfo.isCuxdInterface()) {
availableInterfaces.put(HmInterface.CUXD, TransferMode.BIN_RPC);
}
if (gatewayInfo.isGroupInterface()) {
availableInterfaces.put(HmInterface.GROUP, TransferMode.XML_RPC);
}
} else {
// other
if (gatewayInfo.isRfInterface()) {
availableInterfaces.put(HmInterface.RF, TransferMode.XML_RPC);
}
if (gatewayInfo.isWiredInterface()) {
availableInterfaces.put(HmInterface.WIRED, TransferMode.XML_RPC);
}
if (gatewayInfo.isHmipInterface()) {
availableInterfaces.put(HmInterface.HMIP, TransferMode.XML_RPC);
}
}
logger.info("{}", config.getGatewayInfo());
StringBuilder sb = new StringBuilder();
for (Entry<HmInterface, TransferMode> entry : availableInterfaces.entrySet()) {
sb.append(entry.getKey()).append(":").append(entry.getValue()).append(", ");
}
if (sb.length() > 2) {
sb.setLength(sb.length() - 2);
}
logger.debug("Used Homematic transfer modes: {}", sb.toString());
startClients();
startServers();
if (!config.getGatewayInfo().isHomegear()) {
// delay the newDevice event handling at startup, reduces some API calls
long delay = config.getGatewayInfo().isCCU1() ? 10 : 3;
enableNewDeviceFuture = scheduler.schedule(() -> {
newDeviceEventsEnabled = true;
}, delay, TimeUnit.MINUTES);
} else {
newDeviceEventsEnabled = true;
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmGatewayInfo 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;
}
Aggregations