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