From 86ec8a2fc2c897cc318347013934868b8e6d1d28 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Sun, 10 Nov 2024 21:33:52 +0100 Subject: [PATCH] Simplify DateTimeType handling for Video Disk Recorder Signed-off-by: Jacob Laursen --- .../binding/vdr/internal/VDRHandler.java | 20 +++++-------------- .../vdr/internal/VDRHandlerFactory.java | 12 +---------- 2 files changed, 6 insertions(+), 26 deletions(-) diff --git a/bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandler.java b/bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandler.java index 767842b58e37e..aabc5cf268505 100644 --- a/bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandler.java +++ b/bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandler.java @@ -12,8 +12,6 @@ */ package org.openhab.binding.vdr.internal; -import java.time.LocalDateTime; -import java.time.ZoneId; import java.util.Map; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -29,7 +27,6 @@ import org.openhab.binding.vdr.internal.svdrp.SVDRPException; import org.openhab.binding.vdr.internal.svdrp.SVDRPParseResponseException; import org.openhab.binding.vdr.internal.svdrp.SVDRPVolume; -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; @@ -60,15 +57,12 @@ public class VDRHandler extends BaseThingHandler { private final Logger logger = LoggerFactory.getLogger(VDRHandler.class); - private final TimeZoneProvider timeZoneProvider; - private VDRConfiguration config = new VDRConfiguration(); private @Nullable ScheduledFuture refreshThreadFuture = null; - public VDRHandler(Thing thing, TimeZoneProvider timeZoneProvider) { + public VDRHandler(Thing thing) { super(thing); - this.timeZoneProvider = timeZoneProvider; } /** @@ -229,13 +223,11 @@ private void onVDRRefresh() { break; case VDRBindingConstants.CHANNEL_UID_CURRENT_EVENT_BEGIN: entry = con.getEpgEvent(SVDRPEpgEvent.TYPE.NOW); - result = new DateTimeType(LocalDateTime.ofInstant(entry.getBegin(), ZoneId.systemDefault()) - .atZone(timeZoneProvider.getTimeZone())); + result = new DateTimeType(entry.getBegin()); break; case VDRBindingConstants.CHANNEL_UID_CURRENT_EVENT_END: entry = con.getEpgEvent(SVDRPEpgEvent.TYPE.NOW); - result = new DateTimeType(LocalDateTime.ofInstant(entry.getEnd(), ZoneId.systemDefault()) - .atZone(timeZoneProvider.getTimeZone())); + result = new DateTimeType(entry.getEnd()); break; case VDRBindingConstants.CHANNEL_UID_NEXT_EVENT_TITLE: entry = con.getEpgEvent(SVDRPEpgEvent.TYPE.NEXT); @@ -251,13 +243,11 @@ private void onVDRRefresh() { break; case VDRBindingConstants.CHANNEL_UID_NEXT_EVENT_BEGIN: entry = con.getEpgEvent(SVDRPEpgEvent.TYPE.NEXT); - result = new DateTimeType(LocalDateTime.ofInstant(entry.getBegin(), ZoneId.systemDefault()) - .atZone(timeZoneProvider.getTimeZone())); + result = new DateTimeType(entry.getBegin()); break; case VDRBindingConstants.CHANNEL_UID_NEXT_EVENT_END: entry = con.getEpgEvent(SVDRPEpgEvent.TYPE.NEXT); - result = new DateTimeType(LocalDateTime.ofInstant(entry.getEnd(), ZoneId.systemDefault()) - .atZone(timeZoneProvider.getTimeZone())); + result = new DateTimeType(entry.getEnd()); break; } diff --git a/bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandlerFactory.java b/bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandlerFactory.java index e2f8730efbee2..a52143efdb7ba 100644 --- a/bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandlerFactory.java +++ b/bundles/org.openhab.binding.vdr/src/main/java/org/openhab/binding/vdr/internal/VDRHandlerFactory.java @@ -18,15 +18,12 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.openhab.core.i18n.TimeZoneProvider; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.binding.BaseThingHandlerFactory; import org.openhab.core.thing.binding.ThingHandler; import org.openhab.core.thing.binding.ThingHandlerFactory; -import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; /** * The {@link VDRHandlerFactory} is responsible for creating things and thing @@ -40,13 +37,6 @@ public class VDRHandlerFactory extends BaseThingHandlerFactory { private static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_VDR); - private final TimeZoneProvider timeZoneProvider; - - @Activate - public VDRHandlerFactory(final @Reference TimeZoneProvider timeZoneProvider) { - this.timeZoneProvider = timeZoneProvider; - } - @Override public boolean supportsThingType(ThingTypeUID thingTypeUID) { return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); @@ -57,7 +47,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { ThingTypeUID thingTypeUID = thing.getThingTypeUID(); if (THING_TYPE_VDR.equals(thingTypeUID)) { - return new VDRHandler(thing, timeZoneProvider); + return new VDRHandler(thing); } return null;