Zaptec Go 2: stop retrying phase switching while APM is active - #33255
Zaptec Go 2: stop retrying phase switching while APM is active#33255nvie wants to merge 4 commits into
Conversation
When an installation uses Zaptec's Adaptive Power Management, phase
switching via installationUpdate() permanently fails with HTTP 500 /
Code 527 ("Cannot update installation when using APM"). Map this to
api.ErrNotAvailable so the loadpoint treats it as a permanent
condition instead of retrying every control cycle.
|
I'd like to keep the errors. If user doesn't see the message when it happens he may not see it at all once its rotated out of the log buffer. This maybe annoying, but so is the charger in the first place. |
|
If user doesn't see the error in the first place he'll wonder why phase switching doesn't happen... |
|
In other words: if the condition exists when starting we should not decorate phase switching. Once it occurs I‘d prefer raising the error for clarity. Does that make sense? |
|
Controlled phase switching will never be possible when you use a Zaptec Go 2 with load balancing (via Zaptec Sense P1), that’s how I understand it. The current implementation however keeps fighting for control to perform a phase switch anyway every 30 seconds and getting this error message. But that is futile: it leads to many errors and noisy logs. (I personally think noisy logs are dangerous because users start to ignore logs and also miss other errors more easily.) But fundamentally, I think it’s about making evcc understand that phase switching isnt allowed for this configuration of the Zaptec, so it won’t be attempted in the first place. So whether phase switching is allowed could maybe be modeled as a capability on the charger configuration in evcc itself that a user either configures themselves or that evcc detects upon setup? This PR kind of did this auto-detection on-demand but maybe it was too magical to detect this from a known error message. It was the easiest shot for me in an unfamiliar code base. Maybe modeling it as a capability on a charger is clearer for the end user. Once evcc knows phase switching isnt allowed, it should no longer attempt it and there would be no error at all, not even the first attempt? If you like that approach better, I’m happy to update the PR to go in that direction. |
|
So all that needs be done is identify APM on startup? |
|
Yes I think so. I just don’t know if it’s possible to cleanly detect it without a side effect (like actually switching phases). I don’t know if an API for it exists. Maybe a toggle the user configures is the simplest approach? |
|
Typically thats bool |
|
Ideally it's only a breaking change for Zaptec users with APM, but since it didn't work anyway I don't think it's really a breaking change. Happy to see if I can dig in a bit this afternoon and see if I can come up with something knowing all this. |
… failed update attempts" This reverts commit 5a8ec50.
Previously, APM being active was only discovered when an installation update was attempted and rejected with a 527 error, requiring runtime state (`apmActive`) to suppress further attempts. This meant the phase switcher was advertised even though it could never succeed. Now `EnabledFeatures` is read from the installation at init time, and if the APM feature bit is set the phase switcher is simply not registered at all. The runtime guard and the error-response parsing are no longer needed.
|
@andig Updated the PR to detect it at startup instead. Turns out Zaptec's OpenAPI spec has a feature bitmask on the installation, and Some things I'm genuinely unsure about, I don't know this codebase well:
Worth noting for anyone reading later: the charger still switches phases by itself under APM (it drops to 1p when available current on a phase falls below the installation's switch threshold). evcc just follows the measured phases now instead of trying to actively control it itself. |
This PR stops evcc from retrying a phase switch that the Zaptec API has already told us can never succeed. Fixes #33253, and supersedes #33254.
This means instead of trying to keep making requests to
api.zaptec.comand flooding the logs every 30 seconds, this now shows up like this, once — only the first time it happens:After that, retrying this will no longer be attempted (until after a restart), so it will no longer be hammering
api.zaptec.comevery 30 seconds.By the way, a HTTP 527 looked like the generic "installation update rejected" code, which could be returned for more things than just APM-related errors, so only a rejection whose error message mentions "APM" is treated as permanent — anything else is passed on and still retried exactly as before.