Skip to content

fix: Reply NotImplemented for OCPP 2.1 actions without a handler - #777

Open
IncognitoQuack wants to merge 1 commit into
mobilityhouse:masterfrom
IncognitoQuack:fix/v21-not-implemented-actions
Open

IncognitoQuack wants to merge 1 commit into
mobilityhouse:masterfrom
IncognitoQuack:fix/v21-not-implemented-actions

Conversation

@IncognitoQuack

Copy link
Copy Markdown

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.1 Action enum. OCPP 2.1 has 26 actions that 2.0.1 doesn't have, like NotifyDERAlarm, SetDERControl, BatterySwap and GetTariffs. When a 2.1 ChargePoint receives one of these and no handler is registered, it answers:

[4,"1","NotSupported","Requested Action is not known by receiver",{"cause":"NotifyDERAlarm not supported by OCPP2.1."}]

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 Action enum of the OCPP version in use. For 2.1 that's ocpp.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:

[4,"1","NotImplemented","Request Action is recognized but not supported by the receiver",{"cause":"No handler for NotifyDERAlarm registered."}]

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 the try/except block 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

  1. Does your submission pass the existing tests?
  2. Are there new tests that cover these additions/changes? tests/v21/test_v21_charge_point.py. The BatterySwap, NotifyDERAlarm and SetDERControl cases fail without this change.
  3. Have you linted your code locally before submission?

_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.
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.

1 participant