Skip to content

Fix OCPP 2.1 SoC/SoH serialization for schema-specific wire keys - #796

Open
VolMax-Studio wants to merge 1 commit into
mobilityhouse:masterfrom
VolMax-Studio:fix/v21-contextual-soc-soh
Open

VolMax-Studio wants to merge 1 commit into
mobilityhouse:masterfrom
VolMax-Studio:fix/v21-contextual-soc-soh

Conversation

@VolMax-Studio

@VolMax-Studio VolMax-Studio commented Nov 17, 2026 •

Copy link
Copy Markdown

Changes included in this PR

Bug fix for schema-specific SoC/SoH JSON wire-key casing in outgoing OCPP 2.1 payloads.

  • Preserve the originating dataclass type during serialization and removal of optional fields.
  • Use targeted key overrides for BatteryDataType (soC, soH) and LimitAtSoCType (soc).
  • Preserve existing conventions for fullSoC, bulkSoC, maxSoC, targetSoC and other keys.
  • Add schema-level and ChargePoint.call() regression coverage, including nested dictionaries and compatibility cases.

Current behavior

For BatterySwap requests, BatteryDataType fields soc and soh are serialized as SoC / soh instead of the schema-required soC / soH. For LimitAtSoCType (e.g. SetChargingProfile), soc is serialized as SoC instead of soc. OCPP 2.1 schema validation rejects these requests with FormatViolationError before they are sent.

Both failures were reproduced on current master (dad5896ac92e3dca8f9e7f19ba09d216b0d07fa5); five targeted test cases fail without the fix.

Related historic casing fixes: #523 and #601, addressing other contexts.

New behavior

Correct wire keys are emitted using the originating dataclass or enclosing schema-property context. Existing conversion behavior remains for unrelated fields. A standalone plain dictionary with no context retains the legacy conversion fallback.

Impact

No public function signatures or wire schemas are changed. This fix changes previously invalid outgoing wire keys to the spellings required by OCPP 2.1. No migration is expected for conforming callers.

Checklist

  1. Does your submission pass the existing tests?
  2. Are there new tests that cover these additions/changes?
  3. Have you linted your code locally before submission?

Local verification (Python 3.12): complete pytest -q suite 193 passed (including async and Hypothesis tests); black --check, isort --check-only, flake8 on changed files passed; mypy --strict --follow-imports=silent for ocpp/charge_point.py passed. Upstream CI is separate and has not yet run.

Signed-off-by: VolMax-Studio <volmax.core@gmail.com>
@mdwcrft mdwcrft mentioned this pull request Nov 27, 2026
mdwcrft added a commit that referenced this pull request Nov 28, 2026
### Changes included in this PR

Bumps versions and changelog for the 2.2.0 release.

- `pyproject.toml` and `docs/source/conf.py`: `2.2.0rc2` → `2.2.0`
- `CHANGELOG.md`: new `2.2.0` section, identical to `2.2.0-rc.2`.
Nothing has merged since rc2, and no regressions have been reported
against it.

Open PRs #795, #796 and #797 and issue #798 are deliberately left out.
They fix problems that already exist in 2.1.0 and are planned for 2.2.1.

### After merge

Tag the merge commit `2.2.0`, then create the GitHub release (not a
pre-release).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.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

Development

Successfully merging this pull request may close these issues.

The serialisation of soc to SoC should not occur in camel case if it is existing at the beginning of a field

1 participant