use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.
the class ButtonDatapointTest method testShortPress.
@Test
public void testShortPress() throws IOException, HomematicClientException {
HmDatapoint shortPressDp = createPressDatapoint("PRESS_SHORT", Boolean.TRUE);
HmDatapoint buttonVirtualDatapoint = getButtonVirtualDatapoint(shortPressDp);
mockEventReceiver.eventReceived(shortPressDp);
assertThat(buttonVirtualDatapoint.getValue(), is(CommonTriggerEvents.SHORT_PRESSED));
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.
the class ButtonDatapointTest method testUnsupportedEvents.
@Test
public void testUnsupportedEvents() throws IOException, HomematicClientException {
HmDatapoint contPressDp = createPressDatapoint("PRESS_CONT", Boolean.TRUE);
HmDatapoint contButtonVirtualDatapoint = getButtonVirtualDatapoint(contPressDp);
mockEventReceiver.eventReceived(contPressDp);
HmDatapoint releaseDp = createPressDatapoint("PRESS_LONG_RELEASE", Boolean.TRUE);
HmDatapoint releaseButtonVirtualDatapoint = getButtonVirtualDatapoint(releaseDp);
mockEventReceiver.eventReceived(releaseDp);
HmDatapoint crapDp = createPressDatapoint("CRAP", Boolean.TRUE);
HmDatapoint crapButtonVirtualDatapoint = getButtonVirtualDatapoint(releaseDp);
mockEventReceiver.eventReceived(crapDp);
assertThat(contButtonVirtualDatapoint.getValue(), nullValue());
assertThat(releaseButtonVirtualDatapoint.getValue(), nullValue());
assertThat(crapButtonVirtualDatapoint.getValue(), nullValue());
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.
the class CcuVariablesAndScriptsParser method parse.
@Override
public Void parse(TclScriptDataList resultList) throws IOException {
if (resultList.getEntries() != null) {
for (TclScriptDataEntry entry : resultList.getEntries()) {
HmDatapoint dp = channel.getDatapoint(HmParamsetType.VALUES, entry.name);
if (dp != null) {
dp.setValue(convertToType(entry.value));
} else {
dp = new HmDatapoint();
dp.setName(entry.name);
dp.setInfo(entry.name);
dp.setDescription(entry.description);
dp.setType(HmValueType.parse(entry.valueType));
dp.setValue(convertToType(entry.value));
if (dp.isIntegerType()) {
dp.setMinValue(toInteger(entry.minValue));
dp.setMaxValue(toInteger(entry.maxValue));
} else {
dp.setMinValue(toDouble(entry.minValue));
dp.setMaxValue(toDouble(entry.maxValue));
}
dp.setReadOnly(entry.readOnly);
dp.setUnit(entry.unit);
String[] result = StringUtils.splitByWholeSeparatorPreserveAllTokens(entry.options, ";");
dp.setOptions(result == null || result.length == 0 ? null : result);
if (dp.getOptions() != null) {
dp.setMinValue(0);
dp.setMaxValue(dp.getOptions().length - 1);
}
dp.setParamsetType(HmParamsetType.VALUES);
channel.addDatapoint(dp);
}
}
}
return null;
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.
the class MetadataUtils method generateOptions.
/**
* Creates channel and config description metadata options for the given Datapoint.
*/
public static <T> List<T> generateOptions(HmDatapoint dp, OptionsBuilder<T> optionsBuilder) {
List<T> options = null;
if (dp.getOptions() == null) {
logger.warn("No options for ENUM datapoint {}", dp);
} else {
options = new ArrayList<T>();
for (int i = 0; i < dp.getOptions().length; i++) {
String description = null;
if (!dp.isVariable() && !dp.isScript()) {
description = getDescription(dp.getChannel().getType(), dp.getName(), dp.getOptions()[i]);
}
if (description == null) {
description = dp.getOptions()[i];
}
options.add(optionsBuilder.createOption(dp.getOptions()[i], description));
}
}
return options;
}
use of org.eclipse.smarthome.binding.homematic.internal.model.HmDatapoint in project smarthome by eclipse.
the class HomematicTypeGeneratorImpl method generateConfigDescription.
private void generateConfigDescription(HmDevice device, URI configDescriptionURI) {
List<ConfigDescriptionParameter> parms = new ArrayList<ConfigDescriptionParameter>();
List<ConfigDescriptionParameterGroup> groups = new ArrayList<ConfigDescriptionParameterGroup>();
for (HmChannel channel : device.getChannels()) {
String groupName = "HMG_" + channel.getNumber();
String groupLabel = MetadataUtils.getDescription("CHANNEL_NAME") + " " + channel.getNumber();
groups.add(new ConfigDescriptionParameterGroup(groupName, null, false, groupLabel, null));
for (HmDatapoint dp : channel.getDatapoints()) {
if (dp.getParamsetType() == HmParamsetType.MASTER) {
ConfigDescriptionParameterBuilder builder = ConfigDescriptionParameterBuilder.create(MetadataUtils.getParameterName(dp), MetadataUtils.getConfigDescriptionParameterType(dp));
builder.withLabel(MetadataUtils.getLabel(dp));
builder.withDefault(ObjectUtils.toString(dp.getDefaultValue()));
builder.withDescription(MetadataUtils.getDatapointDescription(dp));
if (dp.isEnumType()) {
builder.withLimitToOptions(dp.isEnumType());
List<ParameterOption> options = MetadataUtils.generateOptions(dp, new OptionsBuilder<ParameterOption>() {
@Override
public ParameterOption createOption(String value, String description) {
return new ParameterOption(value, description);
}
});
builder.withOptions(options);
}
if (dp.isNumberType()) {
builder.withMinimum(MetadataUtils.createBigDecimal(dp.getMinValue()));
builder.withMaximum(MetadataUtils.createBigDecimal(dp.getMaxValue()));
builder.withStepSize(MetadataUtils.createBigDecimal(dp.isFloatType() ? new Float(0.1) : 1L));
builder.withUnitLabel(MetadataUtils.getUnit(dp));
}
builder.withGroupName(groupName);
parms.add(builder.build());
}
}
}
configDescriptionProvider.addConfigDescription(new ConfigDescription(configDescriptionURI, parms, groups));
}
Aggregations