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);
}
}
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;
}
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);
}
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);
}
}
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;
}
Aggregations