Fixed OCPP connector failing to load on ocpp 2.x - #2161
Open
cafe-jun wants to merge 1 commit into
Open
Conversation
The ocpp library deprecated the PascalCase Action enum members and the *Payload suffix on call/call_result classes in 1.0, and removed them in 2.0. The connector still used the old names, so importing it raises AttributeError and the OCPP connector cannot be loaded at all. The library is unpinned in requirements-full.txt, so every new install hits this. Renamed to the current API: Action.BootNotification -> Action.boot_notification, call_result.BootNotificationPayload -> call_result.BootNotification, and so on. Both spellings exist in ocpp 1.0, so this keeps working there — the enum values are identical (Action.meter_values.value == "MeterValues"), so the messageType passed to the uplink converter is unchanged. Verified the connector imports on ocpp 1.0.0, 2.0.0 and 2.1.0, where before it only imported on 1.0.0. Closes thingsboard#1908
cafe-jun
force-pushed
the
fix/ocpp-library-api-rename
branch
from
August 24, 2026 11:25
5563fde to
664f146
Compare
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.
Closes #1908
Problem
The OCPP connector cannot be imported at all on current versions of the
ocpplibrary:ocpp1.0 deprecated two things and 2.0 removed them:Actionenum members, in favour of snake_casePayloadsuffix oncall/call_resultclassesThe 1.0 source says so explicitly:
requirements-full.txtlistsocppunpinned, so any fresh install resolves to 2.x and the connector is dead on arrival.TBModuleLoaderreports the import failure and no OCPP device can connect.Change
Renamed 16 references across two files to the current API:
Action.BootNotificationAction.boot_notificationcall_result.BootNotificationPayloadcall_result.BootNotificationcall.DataTransferPayloadcall.DataTransfer…and the same for
Authorize,Heartbeat,MeterValues,DataTransfer.This does not drop ocpp 1.x support
Both spellings exist in 1.0, so the new names resolve there too. No version pin is needed and no existing install breaks.
The enum values are also identical, so nothing changes at runtime:
That matters because
Action.meter_valuesis passed through asmessageTypeto the uplink converter — the converter still receives the same string it did before.Verification
Imported
charge_pointandocpp_connectoragainst three library versions:AttributeErrorAttributeErrorSo the change strictly widens the supported range rather than shifting it.
Notes
tests/today. Happy to add an import smoke test if you would like one in this PR.ocppinrequirements-full.txt, since the connector now works on both major versions. Let me know if you would rather have a lower bound recorded there anyway.