]> git.basschouten.com Git - openhab-addons.git/blob
b6ed156029b650f1cc06cb4c4f5735e71501a88e
[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.linky.internal.model;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 /**
19  * The {@link LinkyConsumptionData} is responsible for holding values
20  * returned by API calls
21  *
22  * @author GaĆ«l L'hopital - Initial contribution
23  */
24 public class LinkyConsumptionData {
25     private Etat etat;
26     private Graphe graphe;
27
28     public Etat getEtat() {
29         return etat;
30     }
31
32     public boolean isInactive() {
33         return "nonActive".equalsIgnoreCase(etat.valeur);
34     }
35
36     public boolean success() {
37         return "termine".equalsIgnoreCase(etat.valeur);
38     }
39
40     public List<Data> getData() {
41         return graphe.data;
42     }
43
44     public int getDecalage() {
45         return graphe.decalage;
46     }
47
48     private static class Etat {
49         public String valeur;
50     }
51
52     public static class Graphe {
53         public int puissanceSouscrite;
54         public int decalage;
55         public Periode periode;
56         public List<Data> data = new ArrayList<>();
57     }
58
59     private static class Periode {
60         public String dateDebut;
61         public String dateFin;
62     }
63
64     public static class Data {
65         public double valeur;
66         public int ordre;
67
68         public boolean isPositive() {
69             return valeur > 0;
70         }
71     }
72 }