Simplify DateTimeType handling for VeSync

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Jacob Laursen 2024-11-25 22:34:22 +01:00 committed by Ciprian Pascu
parent 6cf955e8b1
commit f4b6be7b27

View File

@ -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.VeSyncConstants.*;
import static org.openhab.binding.vesync.internal.dto.requests.VeSyncProtocolConstants.*; import static org.openhab.binding.vesync.internal.dto.requests.VeSyncProtocolConstants.*;
import java.time.LocalDateTime; import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -527,8 +526,8 @@ public class VeSyncDeviceAirPurifierHandler extends VeSyncBaseDeviceHandler {
// Only 400S appears to have this JSON extension object // Only 400S appears to have this JSON extension object
if (purifierStatus.result.result.extension != null) { if (purifierStatus.result.result.extension != null) {
if (purifierStatus.result.result.extension.timerRemain > 0) { if (purifierStatus.result.result.extension.timerRemain > 0) {
updateState(DEVICE_CHANNEL_AF_AUTO_OFF_CALC_TIME, new DateTimeType(LocalDateTime.now() updateState(DEVICE_CHANNEL_AF_AUTO_OFF_CALC_TIME, new DateTimeType(
.plus(purifierStatus.result.result.extension.timerRemain, ChronoUnit.SECONDS).toString())); Instant.now().plusSeconds(purifierStatus.result.result.extension.timerRemain)));
} else { } else {
updateState(DEVICE_CHANNEL_AF_AUTO_OFF_CALC_TIME, new DateTimeItem("nullEnforcements").getState()); updateState(DEVICE_CHANNEL_AF_AUTO_OFF_CALC_TIME, new DateTimeItem("nullEnforcements").getState());
} }