Commit 0de0566 Daniel Kötting
committed
1 parent dfea7a1 commit 0de0566 Copy full SHA for 0de0566
File tree 3 files changed +68
-22
lines changed
bundles/org.openhab.binding.evcc/src/main/java/org/openhab/binding/evcc/internal
3 files changed +68
-22
lines changed Original file line number Diff line number Diff line change @@ -420,7 +420,7 @@ private void refresh() {
420
420
updateStatus (ThingStatus .ONLINE );
421
421
Battery [] batteries = result .getBattery ();
422
422
batteryConfigured = ((batteries != null ) && (batteries .length > 0 ));
423
- gridConfigured = ( result .getGridPower () != null );
423
+ gridConfigured = result .getGridConfigured ( );
424
424
PV [] pvs = result .getPV ();
425
425
pvConfigured = ((pvs != null ) && (pvs .length > 0 ));
426
426
createChannelsGeneral ();
@@ -712,7 +712,7 @@ private void updateChannelsGeneral() {
712
712
}
713
713
boolean gridConfigured = this .gridConfigured ;
714
714
if (gridConfigured ) {
715
- float gridPower = ((result .getGridPower () == null ) ? 0.0f : result .getGridPower ());
715
+ float gridPower = ((result .getGrid (). getPower () == null ) ? 0.0f : result .getGrid (). getPower ());
716
716
channel = new ChannelUID (uid , CHANNEL_GROUP_ID_GENERAL , CHANNEL_GRID_POWER );
717
717
updateState (channel , new QuantityType <>(gridPower , Units .WATT ));
718
718
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2010-2025 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 .evcc .internal .api .dto ;
14
+
15
+ import com .google .gson .annotations .SerializedName ;
16
+
17
+ /**
18
+ * This class represents the grid response (/api/state).
19
+ * This DTO was written for evcc version 0.133.0
20
+ *
21
+ * @author Daniel Kötting - Initial contribution
22
+ */
23
+ public class Grid {
24
+ // Data types from https://github.com/evcc-io/evcc/blob/master/api/api.go
25
+ // and from https://docs.evcc.io/docs/reference/configuration/messaging/#msg
26
+
27
+ @ SerializedName ("currents" )
28
+ private float [] currents ;
29
+
30
+ @ SerializedName ("energy" )
31
+ private float energy ;
32
+
33
+ @ SerializedName ("power" )
34
+ private Float power ;
35
+
36
+ /**
37
+ * @return grid's currents
38
+ */
39
+ public float [] getCurrents () {
40
+ return currents ;
41
+ }
42
+
43
+ /**
44
+ * @return grid's energy
45
+ */
46
+ public float getEnergy () {
47
+ return energy ;
48
+ }
49
+
50
+ /**
51
+ * @return grid's power or {@code null} if not available
52
+ */
53
+ public Float getPower () {
54
+ return power ;
55
+ }
56
+ }
Original file line number Diff line number Diff line change @@ -49,14 +49,11 @@ public class Result {
49
49
@ SerializedName ("batteryMode" )
50
50
private String batteryMode ;
51
51
52
- @ SerializedName ("gridCurrents " )
53
- private float [] gridCurrents ;
52
+ @ SerializedName ("grid " )
53
+ private Grid grid ;
54
54
55
- @ SerializedName ("gridEnergy" )
56
- private float gridEnergy ;
57
-
58
- @ SerializedName ("gridPower" )
59
- private Float gridPower ;
55
+ @ SerializedName ("gridConfigured" )
56
+ private boolean gridConfigured ;
60
57
61
58
@ SerializedName ("homePower" )
62
59
private float homePower ;
@@ -165,24 +162,17 @@ public String getBatteryMode() {
165
162
}
166
163
167
164
/**
168
- * @return grid's currents
169
- */
170
- public float [] getGridCurrents () {
171
- return gridCurrents ;
172
- }
173
-
174
- /**
175
- * @return grid's energy
165
+ * @return all grid related values
176
166
*/
177
- public float getGridEnergy () {
178
- return gridEnergy ;
167
+ public Grid getGrid () {
168
+ return grid ;
179
169
}
180
170
181
171
/**
182
- * @return grid's power or {@code null} if not available
172
+ * @return is grid configured
183
173
*/
184
- public Float getGridPower () {
185
- return gridPower ;
174
+ public boolean getGridConfigured () {
175
+ return gridConfigured ;
186
176
}
187
177
188
178
/**
You can’t perform that action at this time.
0 commit comments