use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.
the class AbstractHomematicGateway method startServers.
/**
* Starts the Homematic RPC server.
*/
private synchronized void startServers() throws IOException {
for (TransferMode mode : availableInterfaces.values()) {
if (!rpcServers.containsKey(mode)) {
RpcServer rpcServer = mode == TransferMode.XML_RPC ? new XmlRpcServer(this, config) : new BinRpcServer(this, config);
rpcServers.put(mode, rpcServer);
rpcServer.start();
}
}
for (HmInterface hmInterface : availableInterfaces.keySet()) {
getRpcClient(hmInterface).init(hmInterface, hmInterface.toString() + "-" + id);
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.
the class AbstractHomematicGateway method setInstallMode.
@Override
public void setInstallMode(boolean enable, int seconds) throws IOException {
HmDevice gwExtrasHm = devices.get(HmDevice.ADDRESS_GATEWAY_EXTRAS);
if (gwExtrasHm != null) {
// since the homematic virtual device exist: try setting install mode via its dataPoints
HmDatapoint installModeDataPoint = null;
HmDatapoint installModeDurationDataPoint = null;
// collect virtual datapoints to be accessed
HmChannel hmChannel = gwExtrasHm.getChannel(HmChannel.CHANNEL_NUMBER_EXTRAS);
HmDatapointInfo installModeDurationDataPointInfo = new HmDatapointInfo(HmParamsetType.VALUES, hmChannel, HomematicConstants.VIRTUAL_DATAPOINT_NAME_INSTALL_MODE_DURATION);
if (enable) {
installModeDurationDataPoint = hmChannel.getDatapoint(installModeDurationDataPointInfo);
}
HmDatapointInfo installModeDataPointInfo = new HmDatapointInfo(HmParamsetType.VALUES, hmChannel, HomematicConstants.VIRTUAL_DATAPOINT_NAME_INSTALL_MODE);
installModeDataPoint = hmChannel.getDatapoint(installModeDataPointInfo);
// first set duration on the datapoint
if (installModeDurationDataPoint != null) {
try {
VirtualDatapointHandler handler = getVirtualDatapointHandler(installModeDurationDataPoint, null);
handler.handleCommand(this, installModeDurationDataPoint, new HmDatapointConfig(), seconds);
// notify thing if exists
gatewayAdapter.onStateUpdated(installModeDurationDataPoint);
} catch (HomematicClientException ex) {
logger.warn("Failed to send datapoint {}", installModeDurationDataPoint, ex);
}
}
// now that the duration is set, we can enable / disable
if (installModeDataPoint != null) {
try {
VirtualDatapointHandler handler = getVirtualDatapointHandler(installModeDataPoint, null);
handler.handleCommand(this, installModeDataPoint, new HmDatapointConfig(), enable);
// notify thing if exists
gatewayAdapter.onStateUpdated(installModeDataPoint);
return;
} catch (HomematicClientException ex) {
logger.warn("Failed to send datapoint {}", installModeDataPoint, ex);
}
}
}
// no gwExtrasHm available (or previous approach failed), therefore use rpc client directly
for (HmInterface hmInterface : availableInterfaces.keySet()) {
if (hmInterface == HmInterface.RF || hmInterface == HmInterface.CUXD) {
getRpcClient(hmInterface).setInstallMode(hmInterface, enable, seconds);
}
}
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.
the class AbstractHomematicGateway method getDeviceDescriptions.
/**
* Loads all device descriptions from the gateway.
*/
private List<HmDevice> getDeviceDescriptions() throws IOException {
List<HmDevice> deviceDescriptions = new ArrayList<HmDevice>();
for (HmInterface hmInterface : availableInterfaces.keySet()) {
deviceDescriptions.addAll(getRpcClient(hmInterface).listDevices(hmInterface));
}
if (!cancelLoadAllMetadata) {
deviceDescriptions.add(createGatewayDevice());
loadDeviceNames(deviceDescriptions);
}
return deviceDescriptions;
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.
the class InstallModeVirtualDatapoint method handleCommand.
@Override
public void handleCommand(VirtualGateway gateway, HmDatapoint dp, HmDatapointConfig dpConfig, Object value) throws IOException, HomematicClientException {
dp.setValue(value);
boolean enable = MiscUtils.isTrueValue(value);
int duration = getDuration(dp.getChannel());
if (enable) {
gateway.disableDatapoint(dp, duration);
}
HmInterface hmInterface = dp.getChannel().getDevice().getHmInterface();
gateway.getRpcClient(hmInterface).setInstallMode(hmInterface, enable, duration);
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmInterface in project smarthome by eclipse.
the class AbstractHomematicGateway method loadRssiValues.
@Override
public void loadRssiValues() throws IOException {
for (HmInterface hmInterface : availableInterfaces.keySet()) {
if (hmInterface == HmInterface.RF || hmInterface == HmInterface.CUXD) {
List<HmRssiInfo> rssiInfos = getRpcClient(hmInterface).loadRssiInfo(hmInterface);
for (HmRssiInfo hmRssiInfo : rssiInfos) {
updateRssiInfo(hmRssiInfo.getAddress(), DATAPOINT_NAME_RSSI_DEVICE, hmRssiInfo.getDevice());
updateRssiInfo(hmRssiInfo.getAddress(), DATAPOINT_NAME_RSSI_PEER, hmRssiInfo.getPeer());
}
}
}
}
Aggregations