]> git.basschouten.com Git - openhab-addons.git/blob
f3783598036a188b17f6e7caa780cedfab78a63a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.semsportal.internal.dto;
14
15 import java.time.ZoneId;
16 import java.time.ZonedDateTime;
17 import java.util.List;
18
19 import com.google.gson.annotations.SerializedName;
20
21 /**
22  * Facade for easy access to the SEMS portal data response. Data is distributed over different parts of the response
23  * object
24  *
25  * @author Iwan Bron - Initial contribution
26  */
27 public class StationStatus {
28     @SerializedName("kpi")
29     private KeyPerformanceIndicators keyPerformanceIndicators;
30     @SerializedName("inverter")
31     private List<Station> stations;
32
33     public Double getCurrentOutput() {
34         return keyPerformanceIndicators.getCurrentOutput();
35     }
36
37     public Double getDayTotal() {
38         return stations.isEmpty() ? null : stations.get(0).getDayTotal();
39     }
40
41     public Double getMonthTotal() {
42         return stations.isEmpty() ? null : stations.get(0).getMonthTotal();
43     }
44
45     public Double getOverallTotal() {
46         return stations.isEmpty() ? null : stations.get(0).getOverallTotal();
47     }
48
49     public Double getDayIncome() {
50         return keyPerformanceIndicators.getDayIncome();
51     }
52
53     public Double getTotalIncome() {
54         return keyPerformanceIndicators.getTotalIncome();
55     }
56
57     public boolean isOperational() {
58         return stations.isEmpty() ? false : stations.get(0).getStatus() == 1;
59     }
60
61     public ZonedDateTime getLastUpdate() {
62         if (stations.isEmpty()) {
63             return null;
64         }
65         return ZonedDateTime.ofInstant(stations.get(0).getDetails().getLastUpdate().toInstant(),
66                 ZoneId.systemDefault());
67     }
68 }