fix: Reply NotImplemented for OCPP 2.1 actions without a handler - #777
Open
IncognitoQuack wants to merge 1 commit into
Open
IncognitoQuack wants to merge 1 commit into
IncognitoQuack wants to merge 1 commit into
Conversation
_raise_key_error() looked up OCPP 2.1 actions in the OCPP 2.0.1 Action enum. As a result, the 26 actions introduced in OCPP 2.1 were answered with a NotSupported CallError when no handler was registered, instead of NotImplemented. Use the Action enum of the OCPP version in use.
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.
Changes included in this PR
Bug fix, follow-up to #744.
Current behavior
#744 added
"2.1"to the versions handled by_raise_key_error(), but the action is still looked up in the OCPP 2.0.1Actionenum. OCPP 2.1 has 26 actions that 2.0.1 doesn't have, likeNotifyDERAlarm,SetDERControl,BatterySwapandGetTariffs. When a 2.1ChargePointreceives one of these and no handler is registered, it answers:So the peer is told that a valid OCPP 2.1 action isn't part of OCPP 2.1.
New behavior
The action is looked up in the
Actionenum of the OCPP version in use. For 2.1 that'socpp.v21.enums.Action, a superset of the 2.0.1 enum. A valid 2.1 action without a handler now gets the same answer as a 2.0.1 or 1.6 action without a handler:Actions that aren't part of OCPP 2.1 still get
NotSupported. Nothing changes for 1.6 and 2.0.1. I also replaced the two copies of thetry/exceptblock with a single lookup table.Impact
No breaking changes. The only behavior change is the error code for the 26 OCPP 2.1-only actions, when no handler is registered.
Checklist
tests/v21/test_v21_charge_point.py. TheBatterySwap,NotifyDERAlarmandSetDERControlcases fail without this change.