Search in sources :

Example 31 with HmDatapoint

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

the class HmwIoModuleVirtualDatapointHandler method initialize.

@Override
public void initialize(HmDevice device) {
    if (device.getType().startsWith(DEVICE_TYPE_WIRED_IO_MODULE)) {
        for (HmChannel channel : device.getChannels()) {
            if (channel.getNumber() >= 7) {
                HmDatapointInfo dpInfoState = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_STATE);
                HmDatapointInfo dpInfoValue = HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_VALUE);
                boolean hasStateDatapoint = channel.hasDatapoint(dpInfoState);
                boolean hasValueDatapoint = channel.hasDatapoint(dpInfoValue);
                if (hasStateDatapoint && !hasValueDatapoint) {
                    HmDatapoint dp = addDatapoint(channel.getDevice(), channel.getNumber(), DATAPOINT_NAME_VALUE, HmValueType.FLOAT, 0.0, false);
                    dp.setMinValue(0.0);
                    dp.setMaxValue(1000.0);
                    dp.setVirtual(false);
                } else if (hasValueDatapoint && !hasStateDatapoint) {
                    HmDatapoint dp = addDatapoint(channel.getDevice(), channel.getNumber(), DATAPOINT_NAME_STATE, HmValueType.BOOL, false, false);
                    dp.setVirtual(false);
                }
            }
            if (channel.getNumber() >= 21) {
                HmDatapointInfo dpInfoCalibration = new HmDatapointInfo(HmParamsetType.MASTER, channel, DATAPOINT_NAME_CALIBRATION);
                if (!channel.hasDatapoint(dpInfoCalibration)) {
                    HmDatapoint dp = new HmDatapoint(DATAPOINT_NAME_CALIBRATION, DATAPOINT_NAME_CALIBRATION, HmValueType.INTEGER, 0, false, HmParamsetType.MASTER);
                    dp.setMinValue(-127);
                    dp.setMaxValue(127);
                    addDatapoint(channel, dp);
                    dp.setVirtual(false);
                }
            }
        }
    }
}
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 32 with HmDatapoint

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

the class InstallModeVirtualDatapoint method handleCommand.

@Override
public void handleCommand(VirtualGateway gateway, HmDatapoint dp, HmDatapointConfig dpConfig, Object value) throws IOException, HomematicClientException {
    dp.setValue(value);
    boolean enable = MiscUtils.isTrueValue(value);
    int duration = getDuration(dp.getChannel());
    if (enable) {
        gateway.disableDatapoint(dp, duration);
    }
    HmInterface hmInterface = dp.getChannel().getDevice().getHmInterface();
    gateway.getRpcClient(hmInterface).setInstallMode(hmInterface, enable, duration);
}
Also used : HmInterface(org.eclipse.smarthome.binding.homematic.internal.model.HmInterface) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 33 with HmDatapoint

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

the class ButtonVirtualDatapointHandler method handleEvent.

@Override
public void handleEvent(VirtualGateway gateway, HmDatapoint dp) {
    HmDatapoint vdp = getVirtualDatapoint(dp.getChannel());
    if (MiscUtils.isTrueValue(dp.getValue())) {
        String pressType = StringUtils.substringAfter(dp.getName(), "_");
        switch(pressType) {
            case "SHORT":
                if (dp.getValue() == null || !dp.getValue().equals(dp.getPreviousValue())) {
                    vdp.setValue(CommonTriggerEvents.SHORT_PRESSED);
                } else {
                    // two (or more) PRESS_SHORT events were received
                    // within AbstractHomematicGateway#DEFAULT_DISABLE_DELAY seconds
                    vdp.setValue(CommonTriggerEvents.DOUBLE_PRESSED);
                }
                break;
            case "LONG":
                vdp.setValue(CommonTriggerEvents.LONG_PRESSED);
                break;
            case "LONG_RELEASE":
            case "CONT":
                vdp.setValue(null);
                break;
            default:
                vdp.setValue(null);
                logger.warn("Unexpected vaule '{}' for PRESS virtual datapoint", pressType);
        }
    } else {
        vdp.setValue(null);
    }
}
Also used : HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 34 with HmDatapoint

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

the class ButtonVirtualDatapointHandler method initialize.

@Override
public void initialize(HmDevice device) {
    for (HmChannel channel : device.getChannels()) {
        if (channel.hasPressDatapoint()) {
            HmDatapoint dp = addDatapoint(device, channel.getNumber(), getName(), HmValueType.STRING, null, false);
            dp.setTrigger(true);
            dp.setOptions(new String[] { CommonTriggerEvents.SHORT_PRESSED, CommonTriggerEvents.LONG_PRESSED, CommonTriggerEvents.DOUBLE_PRESSED });
        }
    }
}
Also used : HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 35 with HmDatapoint

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

the class DeleteDeviceModeVirtualDatapointHandler method initialize.

@Override
public void initialize(HmDevice device) {
    if (!device.isGatewayExtras() && !(device.getHmInterface() == HmInterface.CUXD)) {
        HmDatapoint dp = addDatapoint(device, 0, getName(), HmValueType.ENUM, 0, false);
        dp.setOptions(new String[] { MODE_LOCKED, MODE_RESET, MODE_FORCE, MODE_DEFER });
        dp.setMinValue(0);
        dp.setMaxValue(dp.getOptions().length - 1);
    }
}
Also used : 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