Skip to content

feat: Add OCPP 2.1 support#416

Closed
andig wants to merge 15 commits intolorenzodonini:masterfrom
evcc-io:feat/ocpp-2.1-support
Closed

feat: Add OCPP 2.1 support#416
andig wants to merge 15 commits intolorenzodonini:masterfrom
evcc-io:feat/ocpp-2.1-support

Conversation

@andig
Copy link
Copy Markdown
Contributor

@andig andig commented Apr 16, 2026

Summary

Implements OCPP 2.1 protocol support with full JSON schema conformance.

Phase B - Core Foundation

  • provisioning: BootNotification, Reset, GetBaseReport, GetReport, NotifyReport, GetVariables, SetVariables, SetNetworkProfile
  • authorization: Authorize (with certificate support, AllowedEnergyTransfer), ClearCache
  • availability: Heartbeat, StatusNotification, ChangeAvailability
  • data: DataTransfer

Phase C - Transactions & Remote Control

  • transactions: TransactionEvent, GetTransactionStatus
  • meter: MeterValues
  • remotecontrol: RequestStartTransaction, RequestStopTransaction, TriggerMessage, UnlockConnector

Types Package

  • 50+ Measurand values for meter readings
  • EnergyTransferMode enum (11 modes including BPT, DER, WPT)
  • ChargingProfile types with PriorityCharging, LocalGeneration, Dynamic
  • CostDetails type hierarchy for transaction cost reporting
  • All validators registered with "21" suffix to avoid conflicts with 2.0.1

All types conform to OCPP 2.1 JSON schemas with correct field names, maxLength constraints, and enum values.

Closes #337

Test plan

  • All packages build successfully (go build ./ocpp2.1/...)
  • Schema conformance verified against OCPP 2.1 JSON schemas
  • Integration testing with OCPP 2.1 compliant CSMS/CS

🤖 Generated with Claude Code

andig and others added 15 commits July 30, 2024 08:04
* chore: fix typo

* Update types.go

---------

Co-authored-by: premultiply <4681172+premultiply@users.noreply.github.com>
Initial implementation of OCPP 2.1 protocol support including:

**Types package (ocpp2.1/types/):**
- CustomDataType for vendor extensions (new in 2.1)
- Extended AuthorizationStatus, IdTokenType enums
- ChargingProfile types with new PriorityCharging, LocalGeneration, Dynamic
- MeterValue/SampledValue with 50+ Measurand values
- EnergyTransferMode enum (11 modes including BPT, DER, WPT)
- AuthorizeCertificateStatus enum (7 values)
- All validators registered with "21" suffix

**Provisioning package:**
- BootNotification, Reset (with ImmediateAndResume)
- GetBaseReport, GetReport, NotifyReport
- GetVariables, SetVariables
- SetNetworkProfile (with identity, basicAuthPassword fields)

**Authorization package:**
- Authorize (with certificate support, AllowedEnergyTransfer)
- ClearCache

**Availability package:**
- Heartbeat, StatusNotification, ChangeAvailability

**Data package:**
- DataTransfer

All types conform to OCPP 2.1 JSON schemas with correct:
- Field names and JSON tags
- MaxLength constraints
- Required/optional field handling
- Enum values

Closes lorenzodonini#337

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements OCPP 2.1 functional blocks with full JSON schema conformance:

transactions package:
- TransactionEvent (CS -> CSMS)
- GetTransactionStatus (CSMS -> CS)

meter package:
- MeterValues (CS -> CSMS)

remotecontrol package:
- RequestStartTransaction (CSMS -> CS)
- RequestStopTransaction (CSMS -> CS)
- TriggerMessage (CSMS -> CS)
- UnlockConnector (CSMS -> CS)

New types in types.go:
- Transaction-related: ChargingState, TransactionEvent, TriggerReason,
  StoppedReason, PreconditioningStatus, TransactionLimit, Transaction
- Cost-related: CostDimension, TariffCost, TaxRate, Price, TotalPrice,
  TotalUsage, TotalCost, CostDimensionValue, ChargingPeriod, CostDetails
- Remote control: MessageTrigger, TriggerMessageStatus, UnlockStatus

Schema conformance fixes:
- Removed MeasurandTemperature (not in OCPP 2.1)
- Fixed RequestStartTransactionRequest.evseId min=1 (per schema)
- Added required tag to TransactionEventRequest.seqNo
- Added range validation for chargingPriority (-9 to 9)
- Added min=1 to updatedPersonalMessageExtra array

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@andig andig requested a review from lorenzodonini as a code owner April 16, 2026 09:13
@andig andig closed this Apr 16, 2026
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.

🚀 Feature: OCPP 2.1 support

3 participants