From 2f8e9adf167ee1a235ce0962ae978e778ad8a24a Mon Sep 17 00:00:00 2001 From: tl-photography Date: Sun, 21 Jul 2024 10:24:54 +0200 Subject: [PATCH] [aWATTar] fix counddown and remaining time (#17067) Signed-off-by: Thomas Leber --- .../awattar/internal/handler/AwattarBestPriceHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/handler/AwattarBestPriceHandler.java b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/handler/AwattarBestPriceHandler.java index ca0e911942b..7645308313e 100644 --- a/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/handler/AwattarBestPriceHandler.java +++ b/bundles/org.openhab.binding.awattar/src/main/java/org/openhab/binding/awattar/internal/handler/AwattarBestPriceHandler.java @@ -44,7 +44,9 @@ import org.openhab.binding.awattar.internal.AwattarNonConsecutiveBestPriceResult import org.openhab.binding.awattar.internal.AwattarPrice; import org.openhab.core.i18n.TimeZoneProvider; import org.openhab.core.library.types.OnOffType; +import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; +import org.openhab.core.library.unit.Units; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Channel; import org.openhab.core.thing.ChannelUID; @@ -195,12 +197,16 @@ public class AwattarBestPriceHandler extends BaseThingHandler { diff = result.getStart() - Instant.now().toEpochMilli(); if (diff >= 0) { state = getDuration(diff); + } else { + state = QuantityType.valueOf(0, Units.MINUTE); } break; case CHANNEL_REMAINING: - diff = result.getEnd() - Instant.now().toEpochMilli(); if (result.isActive()) { + diff = result.getEnd() - Instant.now().toEpochMilli(); state = getDuration(diff); + } else { + state = QuantityType.valueOf(0, Units.MINUTE); } break; case CHANNEL_HOURS: