Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix case conversion for soc in non "State of Charge" context #607

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading