From 7c1892fd571ed5324609629e68fccae599f6b76a Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Mon, 25 Nov 2024 22:34:22 +0100 Subject: [PATCH] Simplify DateTimeType handling for VeSync Signed-off-by: Jacob Laursen --- .../internal/handlers/VeSyncDeviceAirPurifierHandler.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/handlers/VeSyncDeviceAirPurifierHandler.java b/bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/handlers/VeSyncDeviceAirPurifierHandler.java index 4441d4d18ef..152fc28d44f 100644 --- a/bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/handlers/VeSyncDeviceAirPurifierHandler.java +++ b/bundles/org.openhab.binding.vesync/src/main/java/org/openhab/binding/vesync/internal/handlers/VeSyncDeviceAirPurifierHandler.java @@ -15,8 +15,7 @@ package org.openhab.binding.vesync.internal.handlers; import static org.openhab.binding.vesync.internal.VeSyncConstants.*; import static org.openhab.binding.vesync.internal.dto.requests.VeSyncProtocolConstants.*; -import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -527,8 +526,8 @@ public class VeSyncDeviceAirPurifierHandler extends VeSyncBaseDeviceHandler { // Only 400S appears to have this JSON extension object if (purifierStatus.result.result.extension != null) { if (purifierStatus.result.result.extension.timerRemain > 0) { - updateState(DEVICE_CHANNEL_AF_AUTO_OFF_CALC_TIME, new DateTimeType(LocalDateTime.now() - .plus(purifierStatus.result.result.extension.timerRemain, ChronoUnit.SECONDS).toString())); + updateState(DEVICE_CHANNEL_AF_AUTO_OFF_CALC_TIME, new DateTimeType( + Instant.now().plusSeconds(purifierStatus.result.result.extension.timerRemain))); } else { updateState(DEVICE_CHANNEL_AF_AUTO_OFF_CALC_TIME, new DateTimeItem("nullEnforcements").getState()); }