]> git.basschouten.com Git - openhab-addons.git/commitdiff
[opensprinkler] fix nextDuration UoM transformation (#8727)
authorHoLLe <760240+HerzScheisse@users.noreply.github.com>
Wed, 14 Oct 2020 17:08:57 +0000 (19:08 +0200)
committerGitHub <noreply@github.com>
Wed, 14 Oct 2020 17:08:57 +0000 (19:08 +0200)
Fixes #8541

Signed-off-by: Holger Eisold <kugelsicha@gmail.com>
bundles/org.openhab.binding.opensprinkler/src/main/java/org/openhab/binding/opensprinkler/internal/handler/OpenSprinklerStationHandler.java
bundles/org.openhab.binding.opensprinkler/src/main/resources/OH-INF/thing/thing-types.xml

index f0b5718760e797a91c43760df66c8a950deb7a77..2ce7230f17cf8155b2552c84fb0470c6d3979b00 100644 (file)
@@ -25,7 +25,6 @@ import org.openhab.binding.opensprinkler.internal.api.OpenSprinklerApi;
 import org.openhab.binding.opensprinkler.internal.api.exception.CommunicationApiException;
 import org.openhab.binding.opensprinkler.internal.api.exception.GeneralApiException;
 import org.openhab.binding.opensprinkler.internal.config.OpenSprinklerStationConfig;
-import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.QuantityType;
 import org.openhab.core.thing.Channel;
@@ -85,13 +84,14 @@ public class OpenSprinklerStationHandler extends OpenSprinklerBaseHandler {
         updateChannels();
     }
 
+    @SuppressWarnings("null")
     private void handleNextDurationCommand(ChannelUID channelUID, Command command) {
         if (!(command instanceof QuantityType<?>)) {
             logger.info("Ignoring implausible non-QuantityType command for NEXT_DURATION");
             return;
         }
         QuantityType<?> quantity = (QuantityType<?>) command;
-        this.nextDurationTime = quantity.toBigDecimal();
+        this.nextDurationTime = quantity.toUnit(Units.SECOND).toBigDecimal();
         updateState(channelUID, quantity);
     }
 
@@ -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:
index 22afafaef1d52037fc3b2e928b9d05aca951722b..bea478715c365d5f472a3d968f18982fe3bb5d3a 100644 (file)
                <item-type>Number:Time</item-type>
                <label>Next Open Duration</label>
                <description>The duration the station will be opened the next time it is switched on.</description>
-               <state readOnly="false" pattern="%.0f s"/>
+               <state readOnly="false" pattern="%.0f min"/>
        </channel-type>
 </thing:thing-descriptions>