mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 13:21:53 +01:00
[automation] ActionInputsHelper: Set step size to 1 for datetime & time to enable seconds (#4436)
Refs https://github.com/openhab/openhab-webui/pull/2848. Discussion in https://github.com/openhab/openhab-webui/issues/2847#issuecomment-2446426478. Signed-off-by: Florian Hotze <dev@florianhotze.com>
This commit is contained in:
parent
591d8d956a
commit
a31e8376a4
@ -102,9 +102,11 @@ public class ActionInputsHelper {
|
||||
Unit<?> unit = null;
|
||||
boolean required = false;
|
||||
String context = null;
|
||||
BigDecimal step = null;
|
||||
Matcher matcher = QUANTITY_TYPE_PATTERN.matcher(input.getType());
|
||||
if (matcher.matches()) {
|
||||
parameterType = ConfigDescriptionParameter.Type.DECIMAL;
|
||||
step = BigDecimal.ZERO;
|
||||
try {
|
||||
unit = getDefaultUnit(matcher.group("dimension"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
@ -140,6 +142,7 @@ public class ActionInputsHelper {
|
||||
case "java.lang.Number":
|
||||
case "org.openhab.core.library.types.DecimalType":
|
||||
parameterType = ConfigDescriptionParameter.Type.DECIMAL;
|
||||
step = BigDecimal.ZERO;
|
||||
break;
|
||||
case "java.lang.String":
|
||||
break;
|
||||
@ -148,10 +151,12 @@ public class ActionInputsHelper {
|
||||
break;
|
||||
case "java.time.LocalTime":
|
||||
context = "time";
|
||||
step = BigDecimal.ONE;
|
||||
break;
|
||||
case "java.time.LocalDateTime":
|
||||
case "java.util.Date":
|
||||
context = "datetime";
|
||||
step = BigDecimal.ONE;
|
||||
break;
|
||||
case "java.time.ZonedDateTime":
|
||||
case "java.time.Instant":
|
||||
@ -178,8 +183,8 @@ public class ActionInputsHelper {
|
||||
if (unit != null) {
|
||||
builder = builder.withUnit(unit.getSymbol());
|
||||
}
|
||||
if (parameterType == ConfigDescriptionParameter.Type.DECIMAL) {
|
||||
builder = builder.withStepSize(BigDecimal.ZERO);
|
||||
if (step != null) {
|
||||
builder = builder.withStepSize(step);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
@ -152,19 +152,19 @@ public class ActionInputHelperTest {
|
||||
@Test
|
||||
public void testMapActionInputToConfigDescriptionParameterWhenLocalTime() {
|
||||
checkParameter(helper.mapActionInputToConfigDescriptionParameter(buildInput("java.time.LocalTime")),
|
||||
ConfigDescriptionParameter.Type.TEXT, false, null, "time", null, null);
|
||||
ConfigDescriptionParameter.Type.TEXT, false, null, "time", null, BigDecimal.ONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapActionInputToConfigDescriptionParameterWhenLocalDateTime() {
|
||||
checkParameter(helper.mapActionInputToConfigDescriptionParameter(buildInput("java.time.LocalDateTime")),
|
||||
ConfigDescriptionParameter.Type.TEXT, false, null, "datetime", null, null);
|
||||
ConfigDescriptionParameter.Type.TEXT, false, null, "datetime", null, BigDecimal.ONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapActionInputToConfigDescriptionParameterWhenDate() {
|
||||
checkParameter(helper.mapActionInputToConfigDescriptionParameter(buildInput("java.util.Date")),
|
||||
ConfigDescriptionParameter.Type.TEXT, false, null, "datetime", null, null);
|
||||
ConfigDescriptionParameter.Type.TEXT, false, null, "datetime", null, BigDecimal.ONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user