Skip to content

Decode Zaptec API error codes into user-facing messages - #427

Open
rhammen wants to merge 3 commits into
custom-components:masterfrom
rhammen:fix/issue-363-decode-api-error-codes
Open

Decode Zaptec API error codes into user-facing messages#427
rhammen wants to merge 3 commits into
custom-components:masterfrom
rhammen:fix/issue-363-decode-api-error-codes

Conversation

@rhammen

@rhammen rhammen commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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_CALLS was on, so users saw Set current limit to 6.0 failed with no reason. Parse it onto RequestError and 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

  • 528 (DeviceCommandRejected) is worded so it doesn't claim outright failure, since DeAuthorizeAndStop returns it while still executing the command (see DEVELOPMENT.md).
  • The Sense/APM message matches the phrase when using APM; any other Details text is shown verbatim.
  • {action} is intentionally left untranslated — it's built in code.
  • nb/nn/pl/sv are machine translations and unreviewed.

rhammen and others added 3 commits August 27, 2026 23:06
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant