Skip to content

Commit

Permalink
Allow default values that are lower than allowed minimum value (openh…
Browse files Browse the repository at this point in the history
…ab#13168)

Resolves openhab#13097

Signed-off-by: Martin Herbst <develop@mherbst.de>
  • Loading branch information
MHerbst authored and nemerdaud committed Feb 28, 2023
1 parent aa67ad8 commit ec0f219
Showing 1 changed file with 11 additions and 5 deletions.
Expand Up @@ -374,12 +374,18 @@ public ParameterOption createOption(String value, String description) {
if (dp.isNumberType()) {
Number defaultValue = (Number) dp.getDefaultValue();
Number maxValue = dp.getMaxValue();
// some datapoints can have a default value that is greater than the maximum value
if (defaultValue != null && maxValue != null
&& defaultValue.doubleValue() > maxValue.doubleValue()) {
maxValue = defaultValue;
Number minValue = dp.getMinValue();
if (defaultValue != null) {
// some datapoints can have a default value that is greater than the maximum value
if (maxValue != null && defaultValue.doubleValue() > maxValue.doubleValue()) {
maxValue = defaultValue;
}
// ... and there are also default values less than the minimum value
if (minValue != null && defaultValue.doubleValue() < minValue.doubleValue()) {
minValue = defaultValue;
}
}
builder.withMinimum(MetadataUtils.createBigDecimal(dp.getMinValue()));
builder.withMinimum(MetadataUtils.createBigDecimal(minValue));
builder.withMaximum(MetadataUtils.createBigDecimal(maxValue));
builder.withUnitLabel(MetadataUtils.getUnit(dp));
}
Expand Down

0 comments on commit ec0f219

Please sign in to comment.