From 9d728710181d12d41ce8e7db502d2378c243384b Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Tue, 17 Dec 2024 21:36:30 +0100 Subject: [PATCH] Simplify DateTimeType handling for WiZ Signed-off-by: Jacob Laursen --- .../openhab/binding/wiz/internal/WizHandlerFactory.java | 8 ++------ .../openhab/binding/wiz/internal/handler/WizHandler.java | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/WizHandlerFactory.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/WizHandlerFactory.java index d15abedfb00..b462a1cbdae 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/WizHandlerFactory.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/WizHandlerFactory.java @@ -18,7 +18,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.wiz.internal.handler.WizHandler; import org.openhab.binding.wiz.internal.handler.WizMediator; -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; @@ -43,15 +42,12 @@ public class WizHandlerFactory extends BaseThingHandlerFactory { private final WizMediator mediator; private final WizStateDescriptionProvider stateDescriptionProvider; - private final TimeZoneProvider timeZoneProvider; @Activate public WizHandlerFactory(@Reference WizMediator mediator, - @Reference WizStateDescriptionProvider stateDescriptionProvider, - @Reference TimeZoneProvider timeZoneProvider) { + @Reference WizStateDescriptionProvider stateDescriptionProvider) { this.mediator = mediator; this.stateDescriptionProvider = stateDescriptionProvider; - this.timeZoneProvider = timeZoneProvider; } @Override @@ -66,7 +62,7 @@ public class WizHandlerFactory extends BaseThingHandlerFactory { if (supportsThingType(thing.getThingTypeUID())) { WizHandler handler; - handler = new WizHandler(thing, mediator, stateDescriptionProvider, timeZoneProvider); + handler = new WizHandler(thing, mediator, stateDescriptionProvider); mediator.registerThingAndWizBulbHandler(thing, handler); return handler; diff --git a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizHandler.java b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizHandler.java index f6108051c2f..94796c1f765 100644 --- a/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizHandler.java +++ b/bundles/org.openhab.binding.wiz/src/main/java/org/openhab/binding/wiz/internal/handler/WizHandler.java @@ -21,7 +21,6 @@ import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; import java.net.SocketTimeoutException; -import java.time.ZonedDateTime; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -55,7 +54,6 @@ import org.openhab.binding.wiz.internal.enums.WizMethodType; import org.openhab.binding.wiz.internal.utils.ValidationUtils; import org.openhab.binding.wiz.internal.utils.WizPacketConverter; import org.openhab.core.config.core.Configuration; -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.HSBType; @@ -100,7 +98,6 @@ public class WizHandler extends BaseThingHandler { private final WizPacketConverter converter = new WizPacketConverter(); private final WizStateDescriptionProvider stateDescriptionProvider; - private final TimeZoneProvider timeZoneProvider; private final ChannelUID colorTempChannelUID; private @Nullable ScheduledFuture keepAliveJob; private long latestUpdate = -1; @@ -121,7 +118,7 @@ public class WizHandler extends BaseThingHandler { * @param stateDescriptionProvider A state description provider */ public WizHandler(final Thing thing, final WizMediator mediator, - WizStateDescriptionProvider stateDescriptionProvider, TimeZoneProvider timeZoneProvider) { + WizStateDescriptionProvider stateDescriptionProvider) { super(thing); try { registrationRequestParam = mediator.getRegistrationParams(); @@ -129,7 +126,6 @@ public class WizHandler extends BaseThingHandler { registrationRequestParam = null; } this.stateDescriptionProvider = stateDescriptionProvider; - this.timeZoneProvider = timeZoneProvider; this.mostRecentState = new WizSyncState(); this.isFan = thing.getThingTypeUID().equals(THING_TYPE_FAN) || thing.getThingTypeUID().equals(THING_TYPE_FAN_WITH_DIMMABLE_BULB); @@ -738,8 +734,7 @@ public class WizHandler extends BaseThingHandler { updateStatus(ThingStatus.ONLINE); latestUpdate = System.currentTimeMillis(); latestOfflineRefresh = System.currentTimeMillis(); - final ZonedDateTime zonedDateTime = ZonedDateTime.now(timeZoneProvider.getTimeZone()); - updateDeviceState(CHANNEL_LAST_UPDATE, new DateTimeType(zonedDateTime)); + updateDeviceState(CHANNEL_LAST_UPDATE, new DateTimeType()); } /**