Decode Zaptec API error codes into user-facing messages - #427
Open
rhammen wants to merge 3 commits into
Open
Conversation
Zaptec reports why a write was rejected in the body of an HTTP 500, as an error code with optional details. That body was only read when the DEBUG_API_CALLS flag was on, so users just saw "Set current limit to 6.0 failed" with no reason (issue custom-components#363). Parse the body onto RequestError and translate the codes at the entity layer. DeviceCommandRejected is worded so it doesn't claim failure outright, since DeAuthorizeAndStop returns it while still executing the command. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The Zaptec app offers three charging modes, two of which reject installation updates with code 527 but different Details: Automatic (managed by Zaptec Sense) and Scheduled. Only the former was translated; Scheduled fell through to showing Zaptec's English text verbatim. Both observed live on a Go 2 installation. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
help.zaptec.com calls these Automatic charging (which it defines as using Zaptec Sense) and Scheduled charging. Using the same names lets users map the error onto the mode they picked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Zaptec explains why a write was rejected in the body of an HTTP 500:
{"Code":527,"Details":"Cannot update installation when using APM"}The integration only read that body when
DEBUG_API_CALLSwas on, so users sawSet current limit to 6.0 failedwith no reason. Parse it ontoRequestErrorand translate the codes at the entity layer, covering the number/button/switch entities, the services and the update entity.Relates to #363. It doesn't lift the API restriction — it explains it.
Notes for review
DeviceCommandRejected) is worded so it doesn't claim outright failure, sinceDeAuthorizeAndStopreturns it while still executing the command (seeDEVELOPMENT.md).when using APM; any otherDetailstext is shown verbatim.{action}is intentionally left untranslated — it's built in code.nb/nn/pl/svare machine translations and unreviewed.