Search in sources :

Example 1 with HmDatapointInfo

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

the class CcuValueParser method parse.

@Override
public Void parse(TclScriptDataList resultList) throws IOException {
    if (resultList.getEntries() != null) {
        for (TclScriptDataEntry entry : resultList.getEntries()) {
            HmDatapointInfo dpInfo = HmDatapointInfo.createValuesInfo(channel, entry.name);
            HmDatapoint dp = channel.getDatapoint(dpInfo);
            if (dp != null) {
                dp.setValue(convertToType(dp, entry.value));
                adjustRssiValue(dp);
            } else {
                // should never happen, but in case ...
                logger.warn("Can't set value for datapoint '{}'", dpInfo);
            }
        }
    }
    return null;
}
Also used : TclScriptDataEntry(org.eclipse.smarthome.binding.homematic.internal.model.TclScriptDataEntry) HmDatapointInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 2 with HmDatapointInfo

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

the class DisplayOptionsVirtualDatapointHandler method sendDatapoint.

private void sendDatapoint(VirtualGateway gateway, HmChannel channel, String dpName, Object newValue) throws IOException, HomematicClientException {
    HmDatapointInfo dpInfo = HmDatapointInfo.createValuesInfo(channel, dpName);
    HmDatapoint dp = gateway.getDatapoint(dpInfo);
    gateway.sendDatapoint(dp, new HmDatapointConfig(), newValue, null);
}
Also used : HmDatapointConfig(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig) HmDatapointInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 3 with HmDatapointInfo

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

the class OnTimeAutomaticVirtualDatapointHandler method initialize.

@Override
public void initialize(HmDevice device) {
    for (HmChannel channel : device.getChannels()) {
        HmDatapointInfo dpInfoOnTime = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_ON_TIME);
        if (channel.hasDatapoint(dpInfoOnTime)) {
            HmDatapointInfo dpInfoLevel = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_LEVEL);
            HmDatapointInfo dpInfoState = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_STATE);
            if (channel.hasDatapoint(dpInfoLevel) || channel.hasDatapoint(dpInfoState)) {
                HmDatapoint dpOnTime = channel.getDatapoint(dpInfoOnTime);
                HmDatapoint dpOnTimeAutomatic = dpOnTime.clone();
                dpOnTimeAutomatic.setName(getName());
                dpOnTimeAutomatic.setDescription(getName());
                addDatapoint(channel, dpOnTimeAutomatic);
            }
        }
    }
}
Also used : HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) HmDatapointInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 4 with HmDatapointInfo

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

the class DisplayOptionsParser method getAvailableOptions.

/**
 * Returns all possible options from the given datapoint.
 */
private String[] getAvailableOptions(HmChannel channel, String datapointName) {
    HmDatapointInfo dpInfo = HmDatapointInfo.createValuesInfo(channel, datapointName);
    HmDatapoint dp = channel.getDatapoint(dpInfo);
    if (dp != null) {
        String[] options = (String[]) ArrayUtils.remove(dp.getOptions(), 0);
        for (String onOffString : onOff) {
            int onIdx = ArrayUtils.indexOf(options, onOffString);
            if (onIdx != -1) {
                options[onIdx] = datapointName + "_" + onOffString;
            }
        }
        return options;
    }
    return new String[0];
}
Also used : HmDatapointInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 5 with HmDatapointInfo

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

the class HomematicThingHandler method handleConfigurationUpdate.

@Override
public void handleConfigurationUpdate(Map<String, Object> configurationParameters) throws ConfigValidationException {
    super.handleConfigurationUpdate(configurationParameters);
    try {
        HomematicGateway gateway = getHomematicGateway();
        HmDevice device = gateway.getDevice(UidUtils.getHomematicAddress(getThing()));
        for (Entry<String, Object> configurationParameter : configurationParameters.entrySet()) {
            String key = configurationParameter.getKey();
            Object newValue = configurationParameter.getValue();
            if (key.startsWith("HMP_")) {
                key = StringUtils.removeStart(key, "HMP_");
                Integer channelNumber = NumberUtils.toInt(StringUtils.substringBefore(key, "_"));
                String dpName = StringUtils.substringAfter(key, "_");
                HmDatapointInfo dpInfo = new HmDatapointInfo(device.getAddress(), HmParamsetType.MASTER, channelNumber, dpName);
                HmDatapoint dp = device.getChannel(channelNumber).getDatapoint(dpInfo);
                if (dp != null) {
                    try {
                        if (newValue != null) {
                            if (newValue instanceof BigDecimal) {
                                final BigDecimal decimal = (BigDecimal) newValue;
                                if (dp.isIntegerType()) {
                                    newValue = decimal.intValue();
                                } else if (dp.isFloatType()) {
                                    newValue = decimal.doubleValue();
                                }
                            }
                            if (ObjectUtils.notEqual(dp.isEnumType() ? dp.getOptionValue() : dp.getValue(), newValue)) {
                                sendDatapoint(dp, new HmDatapointConfig(), newValue);
                            }
                        }
                    } catch (IOException ex) {
                        logger.error("Error setting thing property {}: {}", dpInfo, ex.getMessage());
                    }
                } else {
                    logger.error("Can't find datapoint for thing property {}", dpInfo);
                }
            }
        }
        gateway.triggerDeviceValuesReload(device);
    } catch (HomematicClientException | GatewayNotAvailableException ex) {
        logger.error("Error setting thing properties: {}", ex.getMessage(), ex);
    }
}
Also used : HomematicClientException(org.eclipse.smarthome.binding.homematic.internal.misc.HomematicClientException) IOException(java.io.IOException) BigDecimal(java.math.BigDecimal) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint) HmDevice(org.eclipse.smarthome.binding.homematic.internal.model.HmDevice) HmDatapointConfig(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig) HomematicGateway(org.eclipse.smarthome.binding.homematic.internal.communicator.HomematicGateway) HmDatapointInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo)

Aggregations

HmDatapointInfo (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo)18 HmDatapoint (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)12 HmChannel (org.eclipse.smarthome.binding.homematic.internal.model.HmChannel)9 HomematicClientException (org.eclipse.smarthome.binding.homematic.internal.misc.HomematicClientException)6 IOException (java.io.IOException)4 HmDatapointConfig (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig)4 HomematicGateway (org.eclipse.smarthome.binding.homematic.internal.communicator.HomematicGateway)3 Channel (org.eclipse.smarthome.core.thing.Channel)3 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)3 BatteryTypeVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.BatteryTypeVirtualDatapointHandler)2 ButtonVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ButtonVirtualDatapointHandler)2 DeleteDeviceModeVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceModeVirtualDatapointHandler)2 DeleteDeviceVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DeleteDeviceVirtualDatapointHandler)2 DisplayOptionsVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.DisplayOptionsVirtualDatapointHandler)2 FirmwareVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.FirmwareVirtualDatapointHandler)2 HmwIoModuleVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.HmwIoModuleVirtualDatapointHandler)2 OnTimeAutomaticVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.OnTimeAutomaticVirtualDatapointHandler)2 ReloadAllFromGatewayVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ReloadAllFromGatewayVirtualDatapointHandler)2 ReloadFromGatewayVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ReloadFromGatewayVirtualDatapointHandler)2 ReloadRssiVirtualDatapointHandler (org.eclipse.smarthome.binding.homematic.internal.communicator.virtual.ReloadRssiVirtualDatapointHandler)2