From daabae72e00a90d1733d42896e71220114d0f728 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Mon, 16 Dec 2024 23:27:21 +0100 Subject: [PATCH] Simplify DateTimeType handling for Meteo France Signed-off-by: Jacob Laursen --- .../meteofrance/internal/MeteoFranceHandlerFactory.java | 2 +- .../internal/handler/RainForecastHandler.java | 9 ++------- .../meteofrance/internal/handler/VigilanceHandler.java | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/MeteoFranceHandlerFactory.java b/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/MeteoFranceHandlerFactory.java index 90595b0af29..4899bdb37cc 100644 --- a/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/MeteoFranceHandlerFactory.java +++ b/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/MeteoFranceHandlerFactory.java @@ -68,6 +68,6 @@ public class MeteoFranceHandlerFactory extends BaseThingHandlerFactory { return BRIDGE_TYPE_API.equals(thingTypeUID) ? new MeteoFranceBridgeHandler((Bridge) thing, deserializer) : THING_TYPE_VIGILANCE.equals(thingTypeUID) ? new VigilanceHandler(thing, zoneId, iconProvider) - : THING_TYPE_RAIN_FORECAST.equals(thingTypeUID) ? new RainForecastHandler(thing, zoneId) : null; + : THING_TYPE_RAIN_FORECAST.equals(thingTypeUID) ? new RainForecastHandler(thing) : null; } } diff --git a/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/RainForecastHandler.java b/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/RainForecastHandler.java index c802c8dcd2f..4faab71a947 100644 --- a/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/RainForecastHandler.java +++ b/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/RainForecastHandler.java @@ -15,7 +15,6 @@ package org.openhab.binding.meteofrance.internal.handler; import static org.openhab.binding.meteofrance.internal.MeteoFranceBindingConstants.*; import static org.openhab.core.types.TimeSeries.Policy.REPLACE; -import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.List; @@ -58,15 +57,13 @@ import org.slf4j.LoggerFactory; public class RainForecastHandler extends BaseThingHandler implements MeteoFranceChildHandler { private final Logger logger = LoggerFactory.getLogger(RainForecastHandler.class); private final ChannelUID intensityChannelUID; - private final ZoneId systemZoneId; private Optional> refreshJob = Optional.empty(); private Optional location = Optional.empty(); - public RainForecastHandler(Thing thing, ZoneId zoneId) { + public RainForecastHandler(Thing thing) { super(thing); this.intensityChannelUID = new ChannelUID(getThing().getUID(), INTENSITY); - this.systemZoneId = zoneId; } @Override @@ -169,9 +166,7 @@ public class RainForecastHandler extends BaseThingHandler implements MeteoFrance private void updateDate(String channelId, @Nullable ZonedDateTime zonedDateTime) { if (isLinked(channelId)) { - updateState(channelId, - zonedDateTime != null ? new DateTimeType(zonedDateTime.withZoneSameInstant(systemZoneId)) - : UnDefType.NULL); + updateState(channelId, zonedDateTime != null ? new DateTimeType(zonedDateTime) : UnDefType.NULL); } } } diff --git a/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/VigilanceHandler.java b/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/VigilanceHandler.java index 297e4233d63..7355286f90f 100644 --- a/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/VigilanceHandler.java +++ b/bundles/org.openhab.binding.meteofrance/src/main/java/org/openhab/binding/meteofrance/internal/handler/VigilanceHandler.java @@ -183,7 +183,7 @@ public class VigilanceHandler extends BaseThingHandler implements MeteoFranceChi private void updateDate(String channelId, ZonedDateTime zonedDateTime) { if (isLinked(channelId)) { - updateState(channelId, new DateTimeType(zonedDateTime.withZoneSameInstant(systemZoneId))); + updateState(channelId, new DateTimeType(zonedDateTime)); } } }