From 7b4c5cae943b504d7b6e52542738af43b8555eb7 Mon Sep 17 00:00:00 2001 From: Jared-Newell-Mobility <119603687+Jared-Newell-Mobility@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:33:08 +0200 Subject: [PATCH] Add `FormationError` and `OccurrenceConstraintViolationError` (#490) In OCPP 1.6, two errors were misspelled. "FormationViolation" Error should be "FormatViolation" Error, "OccurenceConstraintViolation" Error should be "OccurrenceConstraintViolation" Error. The OCA decided not to correct the spelling in OCPP 1.6, since that would be a breaking change. FormationViolation has been fixed as of OCPP 2.0.1. OccurenceConstraintViolation Error is used for 1.6 and 2.0.1. "OccurrenceConstraintViolation" Error is used for OCPP 2.1 and up. This library doesn't support "FormationViolation" Error (for OCPP 1.6 and up) This commit adds support for those errors. See the discussion at https://github.com/mobilityhouse/ocpp/issues/381 and OCPP 1.6-J Errata sheet v1.0, section 5 "Known issues that won't be fixed". --- CHANGELOG.md | 3 +++ ocpp/exceptions.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6519f06bd..1dca3ca9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change log + +- [#381](https://github.com/mobilityhouse/ocpp/issues/381) FormatViolation serialization bug with OCPP 1.6-J + ## 0.21.0 (2023-10-19) - [#492] Minor fixes _handle_call doc string - Thanks @drc38 diff --git a/ocpp/exceptions.py b/ocpp/exceptions.py index 6c570425f..22c693b40 100644 --- a/ocpp/exceptions.py +++ b/ocpp/exceptions.py @@ -68,12 +68,31 @@ class SecurityError(OCPPError): class FormatViolationError(OCPPError): + """ + Not strict OCPP 1.6 - see FormationViolationError + Valid OCPP 2.0.1 + """ + code = "FormatViolation" default_description = ( "Payload for Action is syntactically incorrect or " "structure for Action" ) +class FormationViolationError(OCPPError): + """ + To allow for strict OCPP 1.6 compliance + 5. Known issues that will not be fixed + 5.2. Page 14, par 4.2.3. CallError: incorrect name in enum: FormationViolation + Incorrect name in enum: FormationViolation + """ + + code = "FormationViolation" + default_description = ( + "Payload for Action is syntactically incorrect or structure for Action" + ) + + class PropertyConstraintViolationError(OCPPError): code = "PropertyConstraintViolation" default_description = ( @@ -83,6 +102,14 @@ class PropertyConstraintViolationError(OCPPError): class OccurenceConstraintViolationError(OCPPError): + """ + To allow for strict OCPP 1.6 compliance + ocpp-j-1.6-errata-sheet.pdf + 5. Known issues that will not be fixed + 5.1. Page 14, par 4.2.3: CallError: Typo in enum + Typo in enum: OccurenceConstraintViolation + """ + code = "OccurenceConstraintViolation" default_description = ( "Payload for Action is syntactically correct but " @@ -91,6 +118,20 @@ class OccurenceConstraintViolationError(OCPPError): ) +class OccurrenceConstraintViolationError(OCPPError): + """ + Not strict OCPP 1.6 - see OccurenceConstraintViolationError + Valid OCPP 2.0.1 + """ + + code = "OccurrenceConstraintViolation" + default_description = ( + "Payload for Action is syntactically correct but " + "at least one of the fields violates occurence " + "constraints" + ) + + class TypeConstraintViolationError(OCPPError): code = "TypeConstraintViolation" default_description = (