mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Simplify DateTimeType handling for OpenUV
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
parent
a989208cc6
commit
541f8d4028
@ -14,8 +14,7 @@ package org.openhab.binding.openuv.internal.handler;
|
|||||||
|
|
||||||
import static org.openhab.binding.openuv.internal.OpenUVBindingConstants.*;
|
import static org.openhab.binding.openuv.internal.OpenUVBindingConstants.*;
|
||||||
|
|
||||||
import java.time.ZoneId;
|
import java.time.Instant;
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -100,8 +99,7 @@ public class OpenUVReportHandler extends BaseThingHandler {
|
|||||||
if ((job == null || job.isCancelled())) {
|
if ((job == null || job.isCancelled())) {
|
||||||
State uvMaxTime = openUVData.getUVMaxTime();
|
State uvMaxTime = openUVData.getUVMaxTime();
|
||||||
if (uvMaxTime instanceof DateTimeType uvMaxDateTime) {
|
if (uvMaxTime instanceof DateTimeType uvMaxDateTime) {
|
||||||
long timeDiff = ChronoUnit.MINUTES.between(ZonedDateTime.now(ZoneId.systemDefault()),
|
long timeDiff = ChronoUnit.MINUTES.between(Instant.now(), uvMaxDateTime.getInstant());
|
||||||
uvMaxDateTime.getZonedDateTime());
|
|
||||||
if (timeDiff > 0) {
|
if (timeDiff > 0) {
|
||||||
logger.debug("Scheduling {} in {} minutes", UV_MAX_EVENT, timeDiff);
|
logger.debug("Scheduling {} in {} minutes", UV_MAX_EVENT, timeDiff);
|
||||||
uvMaxJob = scheduler.schedule(() -> {
|
uvMaxJob = scheduler.schedule(() -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user