Skip to content

Commit

Permalink
[homematic] Remove state description step size handling (openhab#12192)
Browse files Browse the repository at this point in the history
The RPC protocol doesn't provide this value, so it always was made up
more or less arbitrarily. Since the UI now uses this value for
validation purposes, there are cases where valid values can not be
entered due to this step size (particularly for datapoints with more
than 1 decimal digit).

Fixes openhab#12183

Signed-off-by: Danny Baumann <dannybaumann@web.de>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
  • Loading branch information
maniac103 authored and andrasU committed Nov 12, 2022
1 parent 026c364 commit e04ef75
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ public void initialize(HmDevice device) {
HmValueType.INTEGER, 1, false);
bd.setMinValue(10);
bd.setMaxValue(160);
bd.setStep(10);
addEnumDisplayDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_LED, Led.class);
}
addDatapoint(device, channel.getNumber(), DATAPOINT_NAME_DISPLAY_SUBMIT, HmValueType.BOOL, false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class HmDatapoint implements Cloneable {
private HmParamsetType paramsetType;
private Number minValue;
private Number maxValue;
private Number step;
private String[] options;
private boolean readOnly;
private boolean readable;
Expand Down Expand Up @@ -192,20 +191,6 @@ public void setMinValue(Number minValue) {
this.minValue = minValue;
}

/**
* Returns the step size.
*/
public Number getStep() {
return step;
}

/**
* Sets the step size.
*/
public void setStep(Number step) {
this.step = step;
}

/**
* Returns true, if the datapoint is readOnly.
*/
Expand Down Expand Up @@ -415,7 +400,6 @@ public HmDatapoint clone() {
dp.setChannel(channel);
dp.setMinValue(minValue);
dp.setMaxValue(maxValue);
dp.setStep(step);
dp.setOptions(options);
dp.setInfo(info);
dp.setUnit(unit);
Expand All @@ -428,9 +412,9 @@ public HmDatapoint clone() {

@Override
public String toString() {
return String.format("%s[name=%s,value=%s,defaultValue=%s,type=%s,minValue=%s,maxValue=%s,step=%s,options=%s,"
return String.format("%s[name=%s,value=%s,defaultValue=%s,type=%s,minValue=%s,maxValue=%s,options=%s,"
+ "readOnly=%b,readable=%b,unit=%s,description=%s,info=%s,paramsetType=%s,virtual=%b,trigger=%b]",
getClass().getSimpleName(), name, value, defaultValue, type, minValue, maxValue, step,
getClass().getSimpleName(), name, value, defaultValue, type, minValue, maxValue,
(options == null ? null : String.join(";", options)), readOnly, readable, unit, description, info,
paramsetType, virtual, trigger);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,14 @@ public StateOption createOption(String value, String description) {
if (dp.isNumberType()) {
BigDecimal min = MetadataUtils.createBigDecimal(dp.getMinValue());
BigDecimal max = MetadataUtils.createBigDecimal(dp.getMaxValue());
BigDecimal step = MetadataUtils.createBigDecimal(dp.getStep());
if (ITEM_TYPE_DIMMER.equals(itemType)
&& (max.compareTo(new BigDecimal("1.0")) == 0 || max.compareTo(new BigDecimal("1.01")) == 0)) {
// For dimmers with a max value of 1.01 or 1.0 the values must be corrected
min = MetadataUtils.createBigDecimal(0);
max = MetadataUtils.createBigDecimal(100);
step = MetadataUtils.createBigDecimal(1);
} else {
if (step == null) {
step = MetadataUtils
.createBigDecimal(dp.isFloatType() ? Float.valueOf(0.1f) : Long.valueOf(1L));
}
}
stateFragment.withMinimum(min).withMaximum(max).withStep(step)
.withPattern(MetadataUtils.getStatePattern(dp)).withReadOnly(dp.isReadOnly());
stateFragment.withMinimum(min).withMaximum(max).withPattern(MetadataUtils.getStatePattern(dp))
.withReadOnly(dp.isReadOnly());
} else {
stateFragment.withPattern(MetadataUtils.getStatePattern(dp)).withReadOnly(dp.isReadOnly());
}
Expand Down Expand Up @@ -361,8 +354,6 @@ public ParameterOption createOption(String value, String description) {
}
builder.withMinimum(MetadataUtils.createBigDecimal(dp.getMinValue()));
builder.withMaximum(MetadataUtils.createBigDecimal(maxValue));
builder.withStepSize(MetadataUtils
.createBigDecimal(dp.isFloatType() ? Float.valueOf(0.1f) : Long.valueOf(1L)));
builder.withUnitLabel(MetadataUtils.getUnit(dp));
}

Expand Down

0 comments on commit e04ef75

Please sign in to comment.