]> git.basschouten.com Git - openhab-addons.git/blob
4b8b1dfb17348c1a7a2fc2039699a387e9bd5554
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.openuv.internal.json;
14
15 import java.math.BigInteger;
16
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.openhab.core.library.types.QuantityType;
19 import org.openhab.core.library.unit.SmartHomeUnits;
20 import org.openhab.core.types.State;
21 import org.openhab.core.types.UnDefType;
22
23 /**
24  * Wrapper type around values reported by OpenUV safe exposure time.
25  *
26  * @author GaĆ«l L'hopital - Initial contribution
27  */
28 public class SafeExposureTime {
29     public @Nullable BigInteger st1;
30     public @Nullable BigInteger st2;
31     public @Nullable BigInteger st3;
32     public @Nullable BigInteger st4;
33     public @Nullable BigInteger st5;
34     public @Nullable BigInteger st6;
35
36     public State getSafeExposure(int index) {
37         BigInteger result;
38         switch (index) {
39             case 1:
40                 result = st1;
41                 break;
42             case 2:
43                 result = st2;
44                 break;
45             case 3:
46                 result = st3;
47                 break;
48             case 4:
49                 result = st4;
50                 break;
51             case 5:
52                 result = st5;
53                 break;
54             case 6:
55                 result = st6;
56                 break;
57             default:
58                 result = null;
59         }
60         return (result != null) ? new QuantityType<>(result, SmartHomeUnits.MINUTE) : UnDefType.NULL;
61     }
62 }