2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.openuv.internal.json;
15 import java.time.LocalDateTime;
16 import java.time.ZoneId;
17 import java.time.ZonedDateTime;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.core.library.types.DateTimeType;
21 import org.openhab.core.library.types.DecimalType;
22 import org.openhab.core.types.State;
23 import org.openhab.core.types.UnDefType;
26 * The {@link OpenUVResult} is responsible for storing
27 * the "result" node from the OpenUV JSON response
29 * @author Gaƫl L'hopital - Initial contribution
32 public class OpenUVResult {
33 private final ZonedDateTime DEFAULT_ZDT = ZonedDateTime.of(LocalDateTime.MIN, ZoneId.systemDefault());
34 private DecimalType uv = new DecimalType(0);
35 private ZonedDateTime uvTime = DEFAULT_ZDT;
36 private DecimalType uvMax = new DecimalType(0);
37 private ZonedDateTime uvMaxTime = DEFAULT_ZDT;
38 private DecimalType ozone = new DecimalType(0);
39 private ZonedDateTime ozoneTime = DEFAULT_ZDT;
40 private SafeExposureTime safeExposureTime = new SafeExposureTime();
42 public DecimalType getUv() {
46 public DecimalType getUvMax() {
50 public DecimalType getOzone() {
54 public State getUVTime() {
55 return uvTime != DEFAULT_ZDT ? new DateTimeType(uvTime.withZoneSameInstant(ZoneId.systemDefault()))
59 public State getUVMaxTime() {
60 return uvMaxTime != DEFAULT_ZDT ? new DateTimeType(uvMaxTime.withZoneSameInstant(ZoneId.systemDefault()))
64 public State getOzoneTime() {
65 return ozoneTime != DEFAULT_ZDT ? new DateTimeType(ozoneTime.withZoneSameInstant(ZoneId.systemDefault()))
69 public SafeExposureTime getSafeExposureTime() {
70 return safeExposureTime;