Search in sources :

Example 6 with HmDatapoint

use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint 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 7 with HmDatapoint

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

the class StateContactVirtualDatapointHandler method handleEvent.

@Override
public void handleEvent(VirtualGateway gateway, HmDatapoint dp) {
    Object value = convertState(dp.getValue());
    HmDatapoint vdp = getVirtualDatapoint(dp.getChannel());
    vdp.setValue(value);
}
Also used : HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 8 with HmDatapoint

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

the class DisplayTextVirtualDatapoint method handleCommand.

@Override
public void handleCommand(VirtualGateway gateway, HmDatapoint dp, HmDatapointConfig dpConfig, Object value) throws IOException, HomematicClientException {
    dp.setValue(value);
    if (DATAPOINT_NAME_DISPLAY_SUBMIT.equals(dp.getName()) && MiscUtils.isTrueValue(dp.getValue())) {
        HmChannel channel = dp.getChannel();
        boolean isEp = isEpDisplay(channel.getDevice());
        List<String> message = new ArrayList<String>();
        message.add(START);
        if (isEp) {
            message.add(LF);
        }
        for (int i = 1; i <= getLineCount(channel.getDevice()); i++) {
            String line = ObjectUtils.toString(channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_DISPLAY_LINE + i).getValue());
            if (StringUtils.isEmpty(line)) {
                line = " ";
            }
            message.add(LINE);
            message.add(encodeText(line));
            if (!isEp) {
                String color = channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_DISPLAY_COLOR + i).getOptionValue();
                message.add(COLOR);
                String colorCode = Color.getCode(color);
                message.add(StringUtils.isBlank(colorCode) ? Color.WHITE.getCode() : colorCode);
            }
            String icon = channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_DISPLAY_ICON + i).getOptionValue();
            String iconCode = Icon.getCode(icon);
            if (StringUtils.isNotBlank(iconCode)) {
                message.add(ICON);
                message.add(iconCode);
            }
            message.add(LF);
        }
        if (isEp) {
            String beeper = channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_DISPLAY_BEEPER).getOptionValue();
            message.add(BEEPER_START);
            message.add(Beeper.getCode(beeper));
            message.add(BEEPER_END);
            // set number of beeps
            message.add(encodeBeepCount(channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_DISPLAY_BEEPCOUNT)));
            message.add(BEEPCOUNT_END);
            // set interval between two beeps
            message.add(encodeBeepInterval(channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_DISPLAY_BEEPINTERVAL)));
            message.add(BEEPINTERVAL_END);
            // LED value must always set (same as beeps)
            String led = channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_DISPLAY_LED).getOptionValue();
            message.add(Led.getCode(led));
        }
        message.add(STOP);
        gateway.sendDatapoint(channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_SUBMIT), new HmDatapointConfig(), StringUtils.join(message, ","), null);
    }
}
Also used : HmDatapointConfig(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig) ArrayList(java.util.ArrayList) HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 9 with HmDatapoint

use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint 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 10 with HmDatapoint

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

the class CcuParamsetDescriptionParser method parse.

@Override
public Void parse(TclScriptDataList resultList) throws IOException {
    if (resultList.getEntries() != null) {
        for (TclScriptDataEntry entry : resultList.getEntries()) {
            HmDatapoint dp = assembleDatapoint(entry.name, entry.unit, entry.valueType, this.toOptionList(entry.options), convertToType(entry.minValue), convertToType(entry.maxValue), toInteger(entry.operations), convertToType(entry.value), paramsetType, isHmIpDevice);
            channel.addDatapoint(dp);
        }
    }
    return null;
}
Also used : TclScriptDataEntry(org.eclipse.smarthome.binding.homematic.internal.model.TclScriptDataEntry) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Aggregations

HmDatapoint (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)55 HmChannel (org.eclipse.smarthome.binding.homematic.internal.model.HmChannel)21 HmDatapointInfo (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo)12 HmDatapointConfig (org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig)7 HmDevice (org.eclipse.smarthome.binding.homematic.internal.model.HmDevice)7 Test (org.junit.Test)6 IOException (java.io.IOException)5 HomematicClientException (org.eclipse.smarthome.binding.homematic.internal.misc.HomematicClientException)5 ArrayList (java.util.ArrayList)4 HomematicGateway (org.eclipse.smarthome.binding.homematic.internal.communicator.HomematicGateway)4 Channel (org.eclipse.smarthome.core.thing.Channel)4 JavaTest (org.eclipse.smarthome.test.java.JavaTest)4 Map (java.util.Map)3 TclScriptDataEntry (org.eclipse.smarthome.binding.homematic.internal.model.TclScriptDataEntry)3 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)3 HashMap (java.util.HashMap)2 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