Search in sources :

Example 36 with HmDatapoint

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

the class OnTimeAutomaticVirtualDatapointHandler method handleCommand.

@Override
public void handleCommand(VirtualGateway gateway, HmDatapoint dp, HmDatapointConfig dpConfig, Object value) throws IOException, HomematicClientException {
    if (!getName().equals(dp.getName())) {
        HmChannel channel = dp.getChannel();
        HmDatapoint dpOnTime = channel.getDatapoint(HmDatapointInfo.createValuesInfo(channel, DATAPOINT_NAME_ON_TIME));
        if (dpOnTime != null) {
            gateway.sendDatapoint(dpOnTime, new HmDatapointConfig(), getVirtualDatapointValue(channel), null);
        } else {
            logger.warn("Can't find ON_TIME datapoint in channel '{}' in device '{}', ignoring virtual datapoint '{}'", channel.getNumber(), channel.getDevice().getAddress(), getName());
        }
        gateway.sendDatapointIgnoreVirtual(dp, dpConfig, value);
    } else {
        dp.setValue(value);
    }
}
Also used : HmDatapointConfig(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointConfig) HmChannel(org.eclipse.smarthome.binding.homematic.internal.model.HmChannel) HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 37 with HmDatapoint

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

the class RssiVirtualDatapointHandler method getRssiValue.

/**
 * Returns either the device or the peer rssi value.
 */
protected Integer getRssiValue(HmChannel channel) {
    HmDatapoint dpRssiDevice = channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_RSSI_DEVICE);
    HmDatapoint dpRssiPeer = channel.getDatapoint(HmParamsetType.VALUES, DATAPOINT_NAME_RSSI_PEER);
    Integer deviceValue = getDatapointValue(dpRssiDevice);
    Integer peerValue = getDatapointValue(dpRssiPeer);
    if ((deviceValue == null || deviceValue == 0) && peerValue != null) {
        return peerValue;
    }
    return deviceValue;
}
Also used : HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 38 with HmDatapoint

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

the class RssiVirtualDatapointHandler method handleEvent.

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

Example 39 with HmDatapoint

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

the class RssiVirtualDatapointHandler method initialize.

@Override
public void initialize(HmDevice device) {
    if (isWirelessDevice(device)) {
        HmDatapoint dp = addDatapoint(device, 0, getName(), HmValueType.INTEGER, getRssiValue(device.getChannel(0)), true);
        dp.setUnit("dBm");
        dp.setMinValue(Integer.MIN_VALUE);
        dp.setMaxValue(Integer.MAX_VALUE);
    }
}
Also used : HmDatapoint(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint)

Example 40 with HmDatapoint

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

the class GetParamsetParser method parse.

@Override
@SuppressWarnings("unchecked")
public Void parse(Object[] message) throws IOException {
    Map<String, ?> mapMessage = (Map<String, ?>) message[0];
    for (String dpName : mapMessage.keySet()) {
        HmDatapointInfo dpInfo = new HmDatapointInfo(paramsetType, channel, dpName);
        HmDatapoint dp = channel.getDatapoint(dpInfo);
        if (dp != null) {
            dp.setValue(convertToType(dp, mapMessage.get(dpName)));
            adjustRssiValue(dp);
        } else {
            // should never happen, but in case ...
            // suppress warning for this datapoint due wrong CCU metadata
            String deviceType = channel.getDevice().getType();
            boolean isHmSenMdirNextTrans = dpInfo.getName().equals("NEXT_TRANSMISSION") && (deviceType.startsWith("HM-Sen-MDIR-O") || deviceType.startsWith("HM-Sen-MDIR-WM55"));
            if (!isHmSenMdirNextTrans) {
                logger.warn("Can't set value for datapoint '{}'", dpInfo);
            }
        }
    }
    return null;
}
Also used : Map(java.util.Map) HmDatapointInfo(org.eclipse.smarthome.binding.homematic.internal.model.HmDatapointInfo) 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