From e3a1abd191c36edd026e984e33d5d9b84e575719 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Tue, 10 Dec 2024 21:09:35 +0100 Subject: [PATCH] Simplify DateTimeType handling for Air Quality Signed-off-by: Jacob Laursen --- .../airquality/internal/AirQualityHandlerFactory.java | 9 ++------- .../internal/handler/AirQualityStationHandler.java | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/AirQualityHandlerFactory.java b/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/AirQualityHandlerFactory.java index b6417fff778..63af4d867af 100644 --- a/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/AirQualityHandlerFactory.java +++ b/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/AirQualityHandlerFactory.java @@ -21,7 +21,6 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.airquality.internal.handler.AirQualityBridgeHandler; import org.openhab.binding.airquality.internal.handler.AirQualityStationHandler; import org.openhab.core.i18n.LocationProvider; -import org.openhab.core.i18n.TimeZoneProvider; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingTypeUID; @@ -43,13 +42,10 @@ import org.osgi.service.component.annotations.Reference; public class AirQualityHandlerFactory extends BaseThingHandlerFactory { private static final Set SUPPORTED_THING_TYPES = Set.of(BRIDGE_TYPE_API, THING_TYPE_STATION); - private final TimeZoneProvider timeZoneProvider; private final LocationProvider locationProvider; @Activate - public AirQualityHandlerFactory(final @Reference TimeZoneProvider timeZoneProvider, - final @Reference LocationProvider locationProvider) { - this.timeZoneProvider = timeZoneProvider; + public AirQualityHandlerFactory(final @Reference LocationProvider locationProvider) { this.locationProvider = locationProvider; } @@ -62,8 +58,7 @@ public class AirQualityHandlerFactory extends BaseThingHandlerFactory { protected @Nullable ThingHandler createHandler(Thing thing) { ThingTypeUID thingTypeUID = thing.getThingTypeUID(); - return THING_TYPE_STATION.equals(thingTypeUID) - ? new AirQualityStationHandler(thing, timeZoneProvider, locationProvider) + return THING_TYPE_STATION.equals(thingTypeUID) ? new AirQualityStationHandler(thing, locationProvider) : BRIDGE_TYPE_API.equals(thingTypeUID) ? new AirQualityBridgeHandler((Bridge) thing) : null; } } diff --git a/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/handler/AirQualityStationHandler.java b/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/handler/AirQualityStationHandler.java index f5fede8b12e..e7afd9812a6 100644 --- a/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/handler/AirQualityStationHandler.java +++ b/bundles/org.openhab.binding.airquality/src/main/java/org/openhab/binding/airquality/internal/handler/AirQualityStationHandler.java @@ -40,7 +40,6 @@ import org.openhab.binding.airquality.internal.config.AirQualityConfiguration; import org.openhab.binding.airquality.internal.config.SensitiveGroupConfiguration; import org.openhab.core.config.core.Configuration; import org.openhab.core.i18n.LocationProvider; -import org.openhab.core.i18n.TimeZoneProvider; import org.openhab.core.library.types.DateTimeType; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.OnOffType; @@ -78,14 +77,12 @@ import org.slf4j.LoggerFactory; public class AirQualityStationHandler extends BaseThingHandler { private final @NonNullByDefault({}) ClassLoader classLoader = AirQualityStationHandler.class.getClassLoader(); private final Logger logger = LoggerFactory.getLogger(AirQualityStationHandler.class); - private final TimeZoneProvider timeZoneProvider; private final LocationProvider locationProvider; private @Nullable ScheduledFuture refreshJob; - public AirQualityStationHandler(Thing thing, TimeZoneProvider timeZoneProvider, LocationProvider locationProvider) { + public AirQualityStationHandler(Thing thing, LocationProvider locationProvider) { super(thing); - this.timeZoneProvider = timeZoneProvider; this.locationProvider = locationProvider; } @@ -263,9 +260,7 @@ public class AirQualityStationHandler extends BaseThingHandler { return hum != -1 ? new QuantityType<>(hum, Units.PERCENT) : UnDefType.NULL; case TIMESTAMP: AirQualityTime time = data.getTime(); - return time != null - ? new DateTimeType(time.getObservationTime().withZoneSameLocal(timeZoneProvider.getTimeZone())) - : UnDefType.NULL; + return time != null ? new DateTimeType(time.getObservationTime()) : UnDefType.NULL; case DOMINENT: return new StringType(data.getDominentPol()); case DEW_POINT: