Search in sources :

Example 6 with DatapointConfig

use of org.openhab.binding.homematic.internal.config.binding.DatapointConfig 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);
                }
            }
        }
    }
}
Also used : HmDevice(org.openhab.binding.homematic.internal.model.HmDevice) HmRssiInfo(org.openhab.binding.homematic.internal.model.HmRssiInfo) DatapointConfig(org.openhab.binding.homematic.internal.config.binding.DatapointConfig) HmDeviceList(org.openhab.binding.homematic.internal.model.HmDeviceList) HmChannel(org.openhab.binding.homematic.internal.model.HmChannel) HmDatapoint(org.openhab.binding.homematic.internal.model.HmDatapoint)

Example 7 with DatapointConfig

use of org.openhab.binding.homematic.internal.config.binding.DatapointConfig in project openhab1-addons by openhab.

the class HomegearClient method iterateAllDatapoints.

/**
     * {@inheritDoc}
     */
@Override
public void iterateAllDatapoints(HmValueItemIteratorCallback callback) throws HomematicClientException {
    Object[] result = rpcClient.getAllValues(getDefaultInterface());
    try {
        for (int i = 0; i < result.length; i++) {
            @SuppressWarnings("unchecked") Map<String, ?> entryMap = (Map<String, ?>) result[i];
            HmDevice device = parseDevice(entryMap);
            addBatteryInfo(device);
            logger.trace("{}", device);
            for (HmChannel channel : device.getChannels()) {
                for (HmDatapoint dp : channel.getDatapoints()) {
                    logger.trace("  {}", dp.toDumpString());
                    DatapointConfig bindingConfig = new DatapointConfig(device.getAddress(), channel.getNumber(), dp.getName());
                    callback.iterate(bindingConfig, dp);
                }
            }
        }
    } catch (Exception ex) {
        throw new HomematicClientException(ex.getMessage(), ex);
    }
}
Also used : HmDatapoint(org.openhab.binding.homematic.internal.model.HmDatapoint) HmDatapoint(org.openhab.binding.homematic.internal.model.HmDatapoint) HmDevice(org.openhab.binding.homematic.internal.model.HmDevice) DatapointConfig(org.openhab.binding.homematic.internal.config.binding.DatapointConfig) HashMap(java.util.HashMap) Map(java.util.Map) HmChannel(org.openhab.binding.homematic.internal.model.HmChannel)

Aggregations

DatapointConfig (org.openhab.binding.homematic.internal.config.binding.DatapointConfig)7 HmDatapoint (org.openhab.binding.homematic.internal.model.HmDatapoint)5 VariableConfig (org.openhab.binding.homematic.internal.config.binding.VariableConfig)2 HmChannel (org.openhab.binding.homematic.internal.model.HmChannel)2 HmDevice (org.openhab.binding.homematic.internal.model.HmDevice)2 HmValueItem (org.openhab.binding.homematic.internal.model.HmValueItem)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ProviderItemIteratorCallback (org.openhab.binding.homematic.internal.communicator.ProviderItemIterator.ProviderItemIteratorCallback)1 HomematicClientException (org.openhab.binding.homematic.internal.communicator.client.HomematicClientException)1 BindingAction (org.openhab.binding.homematic.internal.config.BindingAction)1 ActionConfig (org.openhab.binding.homematic.internal.config.binding.ActionConfig)1 HomematicBindingConfig (org.openhab.binding.homematic.internal.config.binding.HomematicBindingConfig)1 ProgramConfig (org.openhab.binding.homematic.internal.config.binding.ProgramConfig)1 HmDeviceList (org.openhab.binding.homematic.internal.model.HmDeviceList)1 HmRssiInfo (org.openhab.binding.homematic.internal.model.HmRssiInfo)1 Item (org.openhab.core.items.Item)1 State (org.openhab.core.types.State)1 BindingConfigParseException (org.openhab.model.item.binding.BindingConfigParseException)1