]> git.basschouten.com Git - openhab-addons.git/blob
e73c8ecc87a02d340a919040520db8157b2c8ef0
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.homewizard.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 import com.google.gson.annotations.SerializedName;
18
19 /**
20  * Class that provides storage for the json object obtained from the P1 meter API
21  *
22  * @author DaniĆ«l van Os - Initial contribution
23  *
24  */
25 @NonNullByDefault
26 public class P1Payload {
27     private int smrVersion = 0;
28     private String meterModel = "";
29     private String wifiSsid = "";
30     private int wifiStrength = 0;
31
32     @SerializedName("total_power_import_t1_kwh")
33     private double totalEnergyImportT1Kwh;
34     @SerializedName("total_power_import_t2_kwh")
35     private double totalEnergyImportT2Kwh;
36     @SerializedName("total_power_export_t1_kwh")
37     private double totalEnergyExportT1Kwh;
38     @SerializedName("total_power_export_t2_kwh")
39     private double totalEnergyExportT2Kwh;
40
41     private double activePowerW;
42     private double activePowerL1W;
43     private double activePowerL2W;
44     private double activePowerL3W;
45     private double totalGasM3;
46     private long gasTimestamp = 0;
47
48     /**
49      * Getter for the smart meter version
50      *
51      * @return The most recent smart meter version obtained from the API
52      */
53     public int getSmrVersion() {
54         return smrVersion;
55     }
56
57     /**
58      * Setter for the smart meter version
59      *
60      * @param smrVersion The smart meter version to set
61      */
62     public void setSmrVersion(int smrVersion) {
63         this.smrVersion = smrVersion;
64     }
65
66     /**
67      * Getter for the meter model
68      *
69      * @return meter model
70      */
71     public String getMeterModel() {
72         return meterModel;
73     }
74
75     /**
76      * Setter for the meter model
77      *
78      * @param meterModel meter model
79      */
80     public void setMeterModel(String meterModel) {
81         this.meterModel = meterModel;
82     }
83
84     /**
85      * Getter for the meter's wifi ssid
86      *
87      * @return the meter's wifi sid
88      */
89     public String getWifiSsid() {
90         return wifiSsid;
91     }
92
93     /**
94      * Setter for the wifi ssid
95      *
96      * @param wifiSsid wifi ssid
97      */
98     public void setWifiSsid(String wifiSsid) {
99         this.wifiSsid = wifiSsid;
100     }
101
102     /**
103      * Getter for the wifi rssi
104      *
105      * @return wifi rssi
106      */
107     public int getWifiStrength() {
108         return wifiStrength;
109     }
110
111     /**
112      * Setter for the wifi rssi
113      *
114      * @param wifiStrength wifi rssi
115      */
116     public void setWifiStrength(int wifiStrength) {
117         this.wifiStrength = wifiStrength;
118     }
119
120     /**
121      * Getter for the total imported energy on counter 1
122      *
123      * @return total imported energy on counter 1
124      */
125     public double getTotalEnergyImportT1Kwh() {
126         return totalEnergyImportT1Kwh;
127     }
128
129     /**
130      * Setter for the total imported energy on counter 1
131      *
132      * @param totalEnergyImportT1Kwh total imported energy on counter 1
133      */
134     public void setTotalEnergyImportT1Kwh(double totalEnergyImportT1Kwh) {
135         this.totalEnergyImportT1Kwh = totalEnergyImportT1Kwh;
136     }
137
138     /**
139      * Getter for the total imported energy on counter 2
140      *
141      * @return total imported energy on counter 2
142      */
143     public double getTotalEnergyImportT2Kwh() {
144         return totalEnergyImportT2Kwh;
145     }
146
147     /**
148      * Setter for the total imported energy on counter 2
149      *
150      * @param totalEnergyImportT2Kwh
151      */
152     public void setTotalEnergyImportT2Kwh(double totalEnergyImportT2Kwh) {
153         this.totalEnergyImportT2Kwh = totalEnergyImportT2Kwh;
154     }
155
156     /**
157      * Getter for the total exported energy on counter 1
158      *
159      * @return total exported energy on counter 1
160      */
161     public double getTotalEnergyExportT1Kwh() {
162         return totalEnergyExportT1Kwh;
163     }
164
165     /**
166      * Setter for the total exported energy on counter 1
167      *
168      * @param totalEnergyExportT1Kwh
169      */
170     public void setTotalEnergyExportT1Kwh(double totalEnergyExportT1Kwh) {
171         this.totalEnergyExportT1Kwh = totalEnergyExportT1Kwh;
172     }
173
174     /**
175      * Getter for the total exported energy on counter 2
176      *
177      * @return total exported energy on counter 2
178      */
179     public double getTotalEnergyExportT2Kwh() {
180         return totalEnergyExportT2Kwh;
181     }
182
183     /**
184      * Setter for the total exported energy on counter 2
185      *
186      * @param totalEnergyExportT2Kwh
187      */
188     public void setTotalEnergyExportT2Kwh(double totalEnergyExportT2Kwh) {
189         this.totalEnergyExportT2Kwh = totalEnergyExportT2Kwh;
190     }
191
192     /**
193      * Getter for the current active total power
194      *
195      * @return current active total power
196      */
197     public double getActivePowerW() {
198         return activePowerW;
199     }
200
201     /**
202      * Setter for the current active total power
203      *
204      * @param activePowerW
205      */
206     public void setActivePowerW(double activePowerW) {
207         this.activePowerW = activePowerW;
208     }
209
210     /**
211      * Getter for the current active total power on phase 1
212      *
213      * @return current active total power on phase 1
214      */
215     public double getActivePowerL1W() {
216         return activePowerL1W;
217     }
218
219     /**
220      * Setter for the current active power on phase 1
221      *
222      * @param activePowerL1W current active total power on phase 1
223      */
224     public void setActivePowerL1W(double activePowerL1W) {
225         this.activePowerL1W = activePowerL1W;
226     }
227
228     /**
229      * Getter for the current active total power on phase 2
230      *
231      * @return current active total power on phase 2
232      */
233     public double getActivePowerL2W() {
234         return activePowerL2W;
235     }
236
237     /**
238      * Setter for the current active power on phase 2
239      *
240      * @param activePowerL2W current active total power on phase 2
241      */
242     public void setActivePowerL2W(double activePowerL2W) {
243         this.activePowerL2W = activePowerL2W;
244     }
245
246     /**
247      * Getter for the current active total power on phase 3
248      *
249      * @return current active total power on phase 3
250      */
251     public double getActivePowerL3W() {
252         return activePowerL3W;
253     }
254
255     /**
256      * Setter for the current active power on phase 3
257      *
258      * @param activePowerL3W current active total power on phase 3
259      */
260     public void setActivePowerL3W(double activePowerL3W) {
261         this.activePowerL3W = activePowerL3W;
262     }
263
264     /**
265      * Getter for the total imported gas volume
266      *
267      * @return total imported gas volume
268      */
269     public double getTotalGasM3() {
270         return totalGasM3;
271     }
272
273     /**
274      * Setter for the total imported gas volume
275      *
276      * @param totalGasM3 total imported gas volume
277      */
278     public void setTotalGasM3(double totalGasM3) {
279         this.totalGasM3 = totalGasM3;
280     }
281
282     /**
283      * Getter for the time stamp of the last gas update
284      *
285      * @return time stamp of the last gas update
286      */
287     public long getGasTimestamp() {
288         return gasTimestamp;
289     }
290
291     /**
292      * Setter for the time stamp of the last gas update
293      *
294      * @param gasTimestamp time stamp of the last gas update
295      */
296     public void setGasTimestamp(long gasTimestamp) {
297         this.gasTimestamp = gasTimestamp;
298     }
299
300     @Override
301     public String toString() {
302         return String.format(
303                 """
304                         P1 [version: %d model: %s ssid: %s signal: %d\
305                          imp1: %f imp2: %f exp1: %f exp2: %f active: %f active1: %f active2: %f active3: %f gas: %f timestamp: %.0f]\
306                         """,
307                 smrVersion, meterModel, wifiSsid, wifiStrength, totalEnergyImportT1Kwh, totalEnergyImportT2Kwh,
308                 totalEnergyExportT1Kwh, totalEnergyExportT2Kwh, activePowerW, activePowerL1W, activePowerL2W,
309                 activePowerL3W, totalGasM3, gasTimestamp);
310     }
311 }