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