use of org.openhab.binding.homematic.internal.model.HmRssiInfo in project openhab1-addons by openhab.
the class BinRpcClient method getRssiInfo.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Map<String, HmRssiInfo> getRssiInfo(HmInterface hmInterface) throws HomematicClientException {
BinRpcRequest request = new BinRpcRequest("rssiInfo");
Map<String, HmRssiInfo> rssiList = new HashMap<String, HmRssiInfo>();
Object[] result = sendMessage(hmInterface, request);
if (result != null && result.length > 0 && result[0] instanceof Map) {
Map<String, ?> devices = (Map<String, ?>) result[0];
for (String sourceDevice : devices.keySet()) {
Map<String, Object[]> targetDevices = (Map<String, Object[]>) devices.get(sourceDevice);
for (String targetDevice : targetDevices.keySet()) {
if (targetDevice.equals(context.getServerId().getAddress())) {
Integer rssiDevice = (Integer) targetDevices.get(targetDevice)[0];
Integer rssiPeer = (Integer) targetDevices.get(targetDevice)[1];
HmRssiInfo rssiInfo = new HmRssiInfo(sourceDevice, rssiDevice, rssiPeer);
rssiList.put(rssiInfo.getAddress(), rssiInfo);
}
}
}
}
return rssiList;
}
use of org.openhab.binding.homematic.internal.model.HmRssiInfo in project openhab1-addons by openhab.
the class CcuClient method iterateAllDatapoints.
/**
* {@inheritDoc}
*/
@Override
public void iterateAllDatapoints(HmValueItemIteratorCallback callback) throws HomematicClientException {
List<HmDevice> devices = sendScriptByName("getAllDevices", HmDeviceList.class).getDevices();
Map<String, HmRssiInfo> rssiList = rpcClient.getRssiInfo(HmInterface.RF);
for (HmDevice device : devices) {
addBatteryInfo(device);
boolean deviceHasRssiDatapoint = false;
for (HmChannel channel : device.getChannels()) {
boolean isChannelZero = "0".equals(channel.getNumber());
for (HmDatapoint dp : channel.getDatapoints()) {
DatapointConfig bindingConfig = new DatapointConfig(device.getAddress(), channel.getNumber(), dp.getName());
HmRssiInfo rssiInfo = rssiList.get(bindingConfig.getAddress());
if (rssiInfo != null) {
if ("RSSI_DEVICE".equals(bindingConfig.getParameter())) {
dp.setValue(rssiInfo.getDevice());
deviceHasRssiDatapoint = true;
} else if ("RSSI_PEER".equals(bindingConfig.getParameter())) {
dp.setValue(rssiInfo.getPeer());
deviceHasRssiDatapoint = true;
}
}
callback.iterate(bindingConfig, dp);
}
if (isChannelZero && !deviceHasRssiDatapoint) {
HmRssiInfo rssiInfo = rssiList.get(device.getAddress());
if (rssiInfo != null) {
logger.debug("Adding missing RSSI datapoints to device {} with address {}", device.getType(), device.getAddress());
addRssiDatapoint(channel, "RSSI_DEVICE", rssiInfo.getDevice(), callback);
addRssiDatapoint(channel, "RSSI_PEER", rssiInfo.getPeer(), callback);
}
}
}
}
}
Aggregations