Skip to content

Commit

Permalink
Merge branch 'master' into Wrong-dataclass-IdTokenType-(v201)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared-Newell-Mobility authored Feb 9, 2024
2 parents 5bdd040 + 489a6cc commit 727a040
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Change log
- [#602](https://github.com/mobilityhouse/ocpp/issues/602) Correct v2g serialisation/deserialisation
- [#557](https://github.com/mobilityhouse/ocpp/issues/557) OCPP 2.0.1 Wrong data type in CostUpdated total_cost
- [#564](https://github.com/mobilityhouse/ocpp/issues/564) Add support For Python 3.11 and 3.12
- [#583](https://github.com/mobilityhouse/ocpp/issues/583) OCPP v1.6/v2.0.1 deprecate dataclasses from calls and call results with the suffix 'Payload'
Expand All @@ -7,6 +8,7 @@
- [#435](https://github.com/mobilityhouse/ocpp/issues/435) Typo in CostUpdated Action
- [#577](https://github.com/mobilityhouse/ocpp/issues/577) v2.0.1 AttributeType Enum Corrections
- [#340](https://github.com/mobilityhouse/ocpp/issues/340) 2.0.1 dataclasses have a incorrect types that don't match carnality
- [#519](https://github.com/mobilityhouse/ocpp/issues/519) Typo in v201.enums.StatusInfoReasonType.invaild_schedule
- [#510](https://github.com/mobilityhouse/ocpp/issues/510) v2.0.1 UnitOfMeasureType - Enums missing and update docstring to allow use for variableCharacteristics
- [#508](https://github.com/mobilityhouse/ocpp/issues/508) Exception - OccurrenceConstraintViolationError doc string correction

Expand Down Expand Up @@ -46,6 +48,8 @@
- [#510](https://github.com/mobilityhouse/ocpp/issues/510) v2.0.1 UnitOfMeasureType - Enums missing and update docstring to allow use for variableCharacteristics.
- [#508](https://github.com/mobilityhouse/ocpp/issues/508) Exception - OccurrenceConstraintViolationError doc string correction.

- [#511](https://github.com/mobilityhouse/ocpp/issues/511) 2.0.1 Units of Measure update to match Appendix 2. Standardized Units Of Measure

## 0.22.0 (2023-11-03)

- [#493](https://github.com/mobilityhouse/ocpp/issues/493) Reduce use of NotSupportedError in favor of NotImplementedError. Thanks [drc38](@https://github.com/drc38).
Expand All @@ -55,6 +59,8 @@

- [#373](https://github.com/mobilityhouse/ocpp/issues/373) v201.datatypes.ChargingNeedsType.request_energy_transfer is mistyped

- [#207](https://github.com/mobilityhouse/ocpp/issues/207) v16/schemas/StopTransaction.json missing "Hertz"

## 0.21.0 (2023-10-19)

- [#492] Minor fixes _handle_call doc string - Thanks @drc38
Expand Down
4 changes: 2 additions & 2 deletions ocpp/charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def camel_to_snake_case(data):
if isinstance(data, dict):
snake_case_dict = {}
for key, value in data.items():
key = key.replace("V2X", "_v2x")
key = key.replace("V2X", "_v2x").replace("V2G", "_v2g")
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", key)
key = re.sub("([a-z0-9])([A-Z])(?=\\S)", r"\1_\2", s1).lower()

Expand Down Expand Up @@ -54,7 +54,7 @@ def snake_to_camel_case(data):
camel_case_dict = {}
for key, value in data.items():
key = key.replace("soc", "SoC")
key = key.replace("_v2x", "V2X")
key = key.replace("_v2x", "V2X").replace("_v2g", "V2G")
components = key.split("_")
key = components[0] + "".join(x[:1].upper() + x[1:] for x in components[1:])
camel_case_dict[key] = snake_to_camel_case(value)
Expand Down
1 change: 0 additions & 1 deletion ocpp/v16/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,6 @@ class UnitOfMeasure(StrEnum):
fahrenheit = "Fahrenheit"
k = "K"
percent = "Percent"
hertz = "Hertz"


class UnlockStatus(StrEnum):
Expand Down
6 changes: 3 additions & 3 deletions ocpp/v201/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,8 @@ class UnitOfMeasureType(StrEnum):
lx = "lx"
m = "m"
ms2 = "ms2"
n = "n"
ohm = "ohm"
n = "N"
ohm = "Ohm"
kpa = "kPa"
percent = "Percent"
rh = "RH"
Expand Down Expand Up @@ -1307,7 +1307,7 @@ class StatusInfoReasonType(StrEnum):
invalid_id_token = "InvalidIdToken"
invalid_message_sequence = "InvalidMessageSequence"
invalid_profile = "InvalidProfile"
invaild_schedule = "InvalidSchedule"
invalid_schedule = "InvalidSchedule"
invalid_stack_level = "InvalidStackLevel"
invalid_url = "InvalidURL"
invalid_value = "InvalidValue"
Expand Down
10 changes: 10 additions & 0 deletions tests/test_charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def heartbeat(self, **kwargs):
({"fullSoC": 100}, {"full_soc": 100}),
({"evMinV2XEnergyRequest": 200}, {"ev_min_v2x_energy_request": 200}),
({"v2xChargingCtrlr": 200}, {"v2x_charging_ctrlr": 200}),
({"signV2GCertificate": 200}, {"sign_v2g_certificate": 200}),
(
{"v2gCertificateInstallationEnabled": 200},
{"v2g_certificate_installation_enabled": 200},
),
],
)
def test_camel_to_snake_case(test_input, expected):
Expand All @@ -68,6 +73,11 @@ def test_camel_to_snake_case(test_input, expected):
({"full_soc": 100}, {"fullSoC": 100}),
({"ev_min_v2x_energy_request": 200}, {"evMinV2XEnergyRequest": 200}),
({"v2x_charging_ctrlr": 200}, {"v2xChargingCtrlr": 200}),
({"sign_v2g_certificate": 200}, {"signV2GCertificate": 200}),
(
{"v2g_certificate_installation_enabled": 200},
{"v2gCertificateInstallationEnabled": 200},
),
],
)
def test_snake_to_camel_case(test_input, expected):
Expand Down
1 change: 0 additions & 1 deletion tests/v16/test_v16_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ def test_unit_of_measure():
assert UnitOfMeasure.fahrenheit == "Fahrenheit"
assert UnitOfMeasure.k == "K"
assert UnitOfMeasure.percent == "Percent"
assert UnitOfMeasure.hertz == "Hertz"


def test_unlock_status():
Expand Down

0 comments on commit 727a040

Please sign in to comment.