Simplify DateTimeType handling for OpenUV

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen 2024-11-18 20:28:19 +01:00 committed by lsiepel
parent a989208cc6
commit 541f8d4028

View File

@ -14,8 +14,7 @@ package org.openhab.binding.openuv.internal.handler;
import static org.openhab.binding.openuv.internal.OpenUVBindingConstants.*;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@ -100,8 +99,7 @@ public class OpenUVReportHandler extends BaseThingHandler {
if ((job == null || job.isCancelled())) {
State uvMaxTime = openUVData.getUVMaxTime();
if (uvMaxTime instanceof DateTimeType uvMaxDateTime) {
long timeDiff = ChronoUnit.MINUTES.between(ZonedDateTime.now(ZoneId.systemDefault()),
uvMaxDateTime.getZonedDateTime());
long timeDiff = ChronoUnit.MINUTES.between(Instant.now(), uvMaxDateTime.getInstant());
if (timeDiff > 0) {
logger.debug("Scheduling {} in {} minutes", UV_MAX_EVENT, timeDiff);
uvMaxJob = scheduler.schedule(() -> {