Search in sources :

Example 1 with HmRssiInfo

use of org.eclipse.smarthome.binding.homematic.internal.model.HmRssiInfo in project smarthome by eclipse.

the class RssiInfoParser method parse.

@Override
@SuppressWarnings("unchecked")
public List<HmRssiInfo> parse(Object[] result) throws IOException {
    List<HmRssiInfo> rssiList = new ArrayList<HmRssiInfo>();
    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);
            if (targetDevices != null) {
                for (String targetDevice : targetDevices.keySet()) {
                    if (targetDevice.equals(config.getGatewayInfo().getAddress())) {
                        Integer rssiDevice = getAdjustedRssiValue((Integer) targetDevices.get(targetDevice)[0]);
                        Integer rssiPeer = getAdjustedRssiValue((Integer) targetDevices.get(targetDevice)[1]);
                        HmRssiInfo rssiInfo = new HmRssiInfo(sourceDevice, rssiDevice, rssiPeer);
                        rssiList.add(rssiInfo);
                    }
                }
            }
        }
    }
    return rssiList;
}
Also used : HmRssiInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmRssiInfo) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 2 with HmRssiInfo

use of org.eclipse.smarthome.binding.homematic.internal.model.HmRssiInfo 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());
            }
        }
    }
}
Also used : HmRssiInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmRssiInfo) HmInterface(org.eclipse.smarthome.binding.homematic.internal.model.HmInterface)

Aggregations

HmRssiInfo (org.eclipse.smarthome.binding.homematic.internal.model.HmRssiInfo)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 HmInterface (org.eclipse.smarthome.binding.homematic.internal.model.HmInterface)1