]> git.basschouten.com Git - openhab-addons.git/blob
e27ed283f7b808fd89a1e16565b76e5b53e2d4a6
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.ecowatt.internal.restapi;
14
15 import java.time.ZonedDateTime;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 import com.google.gson.annotations.SerializedName;
22
23 /**
24  * The {@link EcowattDaySignals} class contains fields mapping the content of each value of JSON table "signals" inside
25  * the API response
26  *
27  * @author Laurent Garnier - Initial contribution
28  */
29 @NonNullByDefault
30 public class EcowattDaySignals {
31     @SerializedName("GenerationFichier")
32     public @Nullable ZonedDateTime fileTimestamp;
33     @SerializedName("jour")
34     public @Nullable ZonedDateTime day;
35     @SerializedName("dvalue")
36     public int value;
37     public @Nullable String message;
38     public @Nullable List<EcowattHourSignal> values;
39
40     public @Nullable ZonedDateTime getDay() {
41         return day;
42     }
43
44     public int getDaySignal() {
45         return value;
46     }
47
48     public @Nullable String getDayMessage() {
49         return message;
50     }
51
52     public int getHourSignal(int hour) {
53         List<EcowattHourSignal> localValues = values;
54         if (localValues != null) {
55             for (EcowattHourSignal hourSignal : localValues) {
56                 if (hourSignal.hour == hour) {
57                     return hourSignal.value;
58                 }
59             }
60         }
61         return -1;
62     }
63 }