Skip to content

Commit

Permalink
Fix case conversion for soc in non "State of Charge" context (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
RoaringDev1203 committed Feb 14, 2024
1 parent 6ee96ed commit 6ec2f93
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Change log

- [#601](https://github.com/mobilityhouse/ocpp/issues/601) Fix case conversion for soc in non "State of Charge" context
- [#523](https://github.com/mobilityhouse/ocpp/issues/523) The serialisation of soc to SoC should not occur in camel case if it is existing at the beginning of a field
- [#515](https://github.com/mobilityhouse/ocpp/issues/515) Update Readthedocs configuration
- [#602](https://github.com/mobilityhouse/ocpp/issues/602) Correct v2g serialisation/deserialisation
Expand Down
3 changes: 2 additions & 1 deletion ocpp/charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def snake_to_camel_case(data):
if isinstance(data, dict):
camel_case_dict = {}
for key, value in data.items():
key = key.replace("soc", "SoC").replace("_SoCket", "Socket")
key = key.replace("_v2x", "V2X")
key = key.replace("soc_limit_reached", "SOCLimitReached")
key = key.replace("soc", "SoC")
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:])
Expand Down
2 changes: 2 additions & 0 deletions tests/test_charge_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def heartbeat(self, **kwargs):
({"fullSoC": 100}, {"full_soc": 100}),
({"evMinV2XEnergyRequest": 200}, {"ev_min_v2x_energy_request": 200}),
({"v2xChargingCtrlr": 200}, {"v2x_charging_ctrlr": 200}),
({"webSocketPingInterval": 200}, {"web_socket_ping_interval": 200}),
({"signV2GCertificate": 200}, {"sign_v2g_certificate": 200}),
(
{"v2gCertificateInstallationEnabled": 200},
Expand All @@ -74,6 +75,7 @@ def test_camel_to_snake_case(test_input, expected):
({"soc_limit_reached": 200}, {"SOCLimitReached": 200}),
({"ev_min_v2x_energy_request": 200}, {"evMinV2XEnergyRequest": 200}),
({"v2x_charging_ctrlr": 200}, {"v2xChargingCtrlr": 200}),
({"web_socket_ping_interval": 200}, {"webSocketPingInterval": 200}),
({"sign_v2g_certificate": 200}, {"signV2GCertificate": 200}),
(
{"v2g_certificate_installation_enabled": 200},
Expand Down

0 comments on commit 6ec2f93

Please sign in to comment.