-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[evcc] Fix missing grid readings after evcc breaking change in 0.133.0 #18199
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2010-2025 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.evcc.internal.api.dto; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
/** | ||
* This class represents the grid response (/api/state). | ||
* This DTO was written for evcc version 0.133.0 | ||
* | ||
* @author Daniel Kötting - Initial contribution | ||
*/ | ||
public class Grid { | ||
// Data types from https://github.com/evcc-io/evcc/blob/master/api/api.go | ||
// and from https://docs.evcc.io/docs/reference/configuration/messaging/#msg | ||
|
||
@SerializedName("currents") | ||
private float[] currents; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this also work if no currenty are provided in the JSON response? |
||
|
||
@SerializedName("energy") | ||
private float energy; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the evcc demo, it might be possible that this value is not available, which would make deserialization fail. Can you please switch to |
||
|
||
@SerializedName("power") | ||
private Float power; | ||
|
||
/** | ||
* @return grid's currents | ||
*/ | ||
public float[] getCurrents() { | ||
return currents; | ||
} | ||
|
||
/** | ||
* @return grid's energy | ||
*/ | ||
public float getEnergy() { | ||
return energy; | ||
} | ||
|
||
/** | ||
* @return grid's power or {@code null} if not available | ||
*/ | ||
public Float getPower() { | ||
return power; | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming my comments are correct (can you please verify?), I would add some API compatibility notes to the changed values. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -49,15 +49,15 @@ public class Result { | |||||
@SerializedName("batteryMode") | ||||||
private String batteryMode; | ||||||
|
||||||
@SerializedName("gridCurrents") | ||||||
private float[] gridCurrents; | ||||||
|
||||||
@SerializedName("gridEnergy") | ||||||
private float gridEnergy; | ||||||
|
||||||
@SerializedName("gridPower") | ||||||
private Float gridPower; | ||||||
|
||||||
@SerializedName("grid") | ||||||
private Grid grid; | ||||||
|
||||||
@SerializedName("gridConfigured") | ||||||
private boolean gridConfigured; | ||||||
|
||||||
@SerializedName("homePower") | ||||||
private float homePower; | ||||||
|
||||||
|
@@ -165,24 +165,24 @@ public String getBatteryMode() { | |||||
} | ||||||
|
||||||
/** | ||||||
* @return grid's currents | ||||||
* @return gridPower (before evcc version 0.133.0) | ||||||
*/ | ||||||
public float[] getGridCurrents() { | ||||||
return gridCurrents; | ||||||
public Float getGridPower() { | ||||||
return gridPower; | ||||||
} | ||||||
|
||||||
/** | ||||||
* @return grid's energy | ||||||
* @return all grid related values | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*/ | ||||||
public float getGridEnergy() { | ||||||
return gridEnergy; | ||||||
public Grid getGrid() { | ||||||
return grid; | ||||||
} | ||||||
|
||||||
/** | ||||||
* @return grid's power or {@code null} if not available | ||||||
* @return is grid configured | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*/ | ||||||
public Float getGridPower() { | ||||||
return gridPower; | ||||||
public boolean getGridConfigured() { | ||||||
return gridConfigured; | ||||||
} | ||||||
|
||||||
/** | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.