From 3e82b5d6de0fb3647994346f96747d104c2b6be3 Mon Sep 17 00:00:00 2001 From: HoLLe <760240+HerzScheisse@users.noreply.github.com> Date: Thu, 15 Oct 2020 18:03:53 +0200 Subject: [PATCH] [opensprinkler] fix nextDuration UoM transformation (#8753) Fixes #8541 Signed-off-by: Holger Eisold --- .../internal/handler/OpenSprinklerStationHandler.java | 6 +++--- .../src/main/resources/ESH-INF/thing/thing-types.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/handler/OpenSprinklerStationHandler.java b/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/handler/OpenSprinklerStationHandler.java index 97d8311d11c..e7223421877 100644 --- a/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/handler/OpenSprinklerStationHandler.java +++ b/bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/handler/OpenSprinklerStationHandler.java @@ -21,7 +21,6 @@ import javax.measure.quantity.Time; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.smarthome.core.library.types.DecimalType; import org.eclipse.smarthome.core.library.types.OnOffType; import org.eclipse.smarthome.core.library.types.QuantityType; import org.eclipse.smarthome.core.thing.Channel; @@ -91,10 +90,11 @@ public class OpenSprinklerStationHandler extends OpenSprinklerBaseHandler { return; } QuantityType quantity = (QuantityType) command; - this.nextDurationTime = quantity.toBigDecimal(); + this.nextDurationTime = quantity.toUnit(Units.SECOND).toBigDecimal(); updateState(channelUID, quantity); } + @SuppressWarnings("null") private void handleStationStateCommand(OpenSprinklerApi api, Command command) { if (!(command instanceof OnOffType)) { logger.error("Received invalid command type for OpenSprinkler station ({}).", command); @@ -204,7 +204,7 @@ public class OpenSprinklerStationHandler extends OpenSprinklerBaseHandler { case NEXT_DURATION: BigDecimal duration = nextDurationValue(); if (duration != null) { - updateState(channel, new DecimalType(duration)); + updateState(channel, new QuantityType<>(duration, Units.SECOND)); } break; case STATION_QUEUED: diff --git a/bundles/org.openhab.binding.opensprinkler/src/main/resources/ESH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.opensprinkler/src/main/resources/ESH-INF/thing/thing-types.xml index 22afafaef1d..bea478715c3 100644 --- a/bundles/org.openhab.binding.opensprinkler/src/main/resources/ESH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.opensprinkler/src/main/resources/ESH-INF/thing/thing-types.xml @@ -120,6 +120,6 @@ Number:Time The duration the station will be opened the next time it is switched on. - +