use of org.eclipse.smarthome.config.core.ConfigDescriptionParameterBuilder in project smarthome by eclipse.
the class MetadataConfigDescriptionProviderImpl method createValueConfigDescription.
private ConfigDescription createValueConfigDescription(MetadataConfigDescriptionProvider provider, @Nullable Locale locale) {
String namespace = provider.getNamespace();
String description = provider.getDescription(locale);
List<ParameterOption> options = provider.getParameterOptions(locale);
URI uri = URI.create(SCHEME + SEPARATOR + namespace);
ConfigDescriptionParameterBuilder builder = ConfigDescriptionParameterBuilder.create("value", Type.TEXT);
if (options != null && !options.isEmpty()) {
builder.withOptions(options);
builder.withLimitToOptions(true);
} else {
builder.withLimitToOptions(false);
}
builder.withDescription(description != null ? description : namespace);
ConfigDescriptionParameter parameter = builder.build();
return new ConfigDescription(uri, Collections.singletonList(parameter));
}
use of org.eclipse.smarthome.config.core.ConfigDescriptionParameterBuilder 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