Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

DanielSan85
Copy link

Fixes #18148

This PR fixes the new alignment of grid data comming from evccs /api/state endpoint.
The old and new structure can be seen in this conversation over at evcc evcc-io/evcc#18063

This change is not backwards compatible with older versions of evcc.

@MikeTheTux
Copy link
Contributor

Can we spend the extra effort and implement this change backward compatible? Allowing the old and the new location of the grid values?

@DanielSan85
Copy link
Author

DanielSan85 commented Jan 29, 2025 via email

@DanielSan85
Copy link
Author

I have added the workaround and testet with evcc 0.131.5 and 0.133.0.
Both worked fine when switching back and forth.

@DanielSan85 DanielSan85 deleted the apadt-to-new-grid-structure-from-api-result branch January 30, 2025 12:51
@DanielSan85 DanielSan85 restored the apadt-to-new-grid-structure-from-api-result branch January 30, 2025 12:53
@DanielSan85 DanielSan85 reopened this Jan 30, 2025
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, thanks!
I have added a few comments, please take a look at them.

}

/**
* @return grid's power or {@code null} if not available
* @return is grid configured
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return is grid configured
* @return whether grid is configured (since evcc version 0.133.0)

}

/**
* @return grid's energy
* @return all grid related values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return all grid related values
* @return all grid related values (since evcc version 0.133.0)

Copy link
Contributor

Choose a reason for hiding this comment

The 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.
Please also update the class JavaDoc for the evcc version compatibility.

float gridPower = ((result.getGridPower() == null) ? 0.0f : result.getGridPower());
Grid grid = result.getGrid();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Grid grid = result.getGrid();
// handling gridPower since evcc version 0.133.0
Grid grid = result.getGrid();

// and from https://docs.evcc.io/docs/reference/configuration/messaging/#msg

@SerializedName("currents")
private float[] currents;
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

private float[] currents;

@SerializedName("energy")
private float energy;
Copy link
Contributor

Choose a reason for hiding this comment

The 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 Float?

@florian-h05 florian-h05 added the bug An unexpected problem or unintended behavior of an add-on label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

evcc binding - gridPower is now grid.power
3 participants