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] Adjust to breaking API change and add Battery Capacity channel #14245

Merged
merged 7 commits into from
Jan 23, 2023

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Jan 18, 2023

Fixes #14231.

evcc changed the API with version 0.111.0, see evcc-io/evcc#5522.
This API change breaks the binding:

  • all indexes become 1-based (instead of 0-based for REST and 1-based for MQTT)
  • SoC becomes Soc

I have also added a new channel for the home battery's capacity which is a new value available over the API.

Signed-off-by: Florian Hotze florianh_dev@icloud.com

@florian-h05 florian-h05 added the bug An unexpected problem or unintended behavior of an add-on label Jan 18, 2023
@florian-h05 florian-h05 requested a review from jlaur January 18, 2023 16:59
@mstormi
Copy link
Contributor

mstormi commented Jan 18, 2023

In the last, evcc numbered its loadpoints 0, 1, ...
Now it is 1, 2, ...

Seems this is only for writing. Reading via /api/state still exposes loadpoints[0].

Are you sure this is an intentional API change or rather an EVCC bug ? Did you ask over at their forum ?

@florian-h05
Copy link
Contributor Author

florian-h05 commented Jan 18, 2023

Reading though evcc-io/evcc#5522, it seems that this change was intentional. It explains as well why the SoCs aren’t working anymore.
See https://docs.evcc.io/docs/reference/api as well.

evcc changed all ids to start with 1 (loadpoints API!!), but I think we shouldn’t follow to „rename“ the channels to avoid user breaking changes.

@florian-h05 florian-h05 changed the title [evcc] Adjust to breaking API change [evcc] Adjust to breaking API change & Add new channel Jan 18, 2023
@florian-h05
Copy link
Contributor Author

evcc-io/evcc#5649 probably brings more breaking changes.

@florian-h05 florian-h05 added the enhancement An enhancement or new feature for an existing add-on label Jan 20, 2023
Fixes openhab#14231.

See evcc-io/evcc#5522.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05
Copy link
Contributor Author

@jlaur Since this has been verified to fix the issue, this is ready for merging from my side!

@jlaur jlaur removed the bug An unexpected problem or unintended behavior of an add-on label Jan 23, 2023
@@ -257,6 +258,7 @@ public void dispose() {
private void createChannelsGeneral() {
final String channelGroup = "general";
if (batteryConfigured) {
createChannel(CHANNEL_BATTERY_CAPACITY, channelGroup, CHANNEL_TYPE_UID_BATTERY_CAPACITY, "Number:Energy");
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a comment for future consideration: Instead of dynamically creating channels, they could be statically declared in XML and then removed when not needed. See for example #13275. The reason for doing so would be simplification.

Addresses review.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Addresses review.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 requested a review from jlaur January 23, 2023 19:36
@florian-h05
Copy link
Contributor Author

@jlaur This is ready for re-review 👍

Addresses review.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

LGTM

@jlaur jlaur merged commit f808edf into openhab:main Jan 23, 2023
@jlaur jlaur added this to the 4.0 milestone Jan 23, 2023
@jlaur jlaur changed the title [evcc] Adjust to breaking API change & Add new channel [evcc] Adjust to breaking API change and add Battery Capacity channel Jan 23, 2023
@florian-h05 florian-h05 deleted the evcc-api-updates branch January 23, 2023 20:19
@florian-h05
Copy link
Contributor Author

@jlaur Do you think this is something to include in a 3.4.2 Patch release (if there’s one)?

@jlaur
Copy link
Contributor

jlaur commented Jan 27, 2023

@florian-h05 - ideally it should then have been a pure bugfix PR without introduction of a new channel. But since I understand that the binding is quite broken for all users having upgraded to evcc 0.111, I agree it's a candiate. @openhab/add-ons-maintainers, okay to cherry-pick this one?

@jlaur
Copy link
Contributor

jlaur commented Jan 30, 2023

@lolodomo - would you agree to cherry-pick this?

@KorbinianP
Copy link
Contributor

KorbinianP commented Feb 10, 2023

@jlaur @lolodomo
The binding is partly broken, you can only read values and not write any changes to the evcc instance. This would be a great candidate for the very next openhab release!

In the current 3.4.1 version the change of the mode won't do anything. I modified the state in the unreleased market place version of the binding and it works again.

@jlaur
Copy link
Contributor

jlaur commented Feb 10, 2023

@kaikreuzer - if you agree, please cherry-pick this commit, f808edf, and 988fde1 as well (from #14381) into the 3.4.x branch before starting a build. Thanks!

kaikreuzer pushed a commit that referenced this pull request Feb 11, 2023
* [evcc] Adjust to breaking API changes

Fixes #14231.

See evcc-io/evcc#5522.

* [evcc] Add battery capacity channel
* [evcc] Version & openHABian note
* [evcc] Use already defined constants in ChannelTypeUIDs
* [evcc] Correct header in evcc.properties

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@kaikreuzer
Copy link
Member

Sure @jlaur, I have cherry-picked those two fixes to 3.4.x.

@kaikreuzer kaikreuzer added the patch A PR that has been cherry-picked to a patch release branch label Feb 13, 2023
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
* [evcc] Adjust to breaking API changes

Fixes openhab#14231.

See evcc-io/evcc#5522.

* [evcc] Add battery capacity channel
* [evcc] Version & openHABian note
* [evcc] Use already defined constants in ChannelTypeUIDs
* [evcc] Correct header in evcc.properties

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
* [evcc] Adjust to breaking API changes

Fixes openhab#14231.

See evcc-io/evcc#5522.

* [evcc] Add battery capacity channel
* [evcc] Version & openHABian note
* [evcc] Use already defined constants in ChannelTypeUIDs
* [evcc] Correct header in evcc.properties

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
FordPrfkt pushed a commit to FordPrfkt/openhab-addons that referenced this pull request Apr 20, 2023
* [evcc] Adjust to breaking API changes

Fixes openhab#14231.

See evcc-io/evcc#5522.

* [evcc] Add battery capacity channel
* [evcc] Version & openHABian note
* [evcc] Use already defined constants in ChannelTypeUIDs
* [evcc] Correct header in evcc.properties

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on patch A PR that has been cherry-picked to a patch release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[evcc] problems with EVCC binding after upgrade to 3.4.1
6 participants