Skip to content

Commit

Permalink
OCPP 2.0.1 support (#1381)
Browse files Browse the repository at this point in the history
* Create different ChargePoint based on subprotocol

This also changes default subprotocol setting from OCPP 1.6 to 1.6 and
2.0.1.

* Don't use CentralSystem from ChargePoint

* Create base class for both OCPP versions

* Move some functions to common ChargePoint class

* Move entire post_connect to base ChargePoint

* Move more boot notification handling to base ChargePoint

* Add to base ChargePoint functions called by api.py

* Split off OCPP part of get_supported_features

* Initial OCPP 2.0.1 support

* Implement get features and connector count for OCPP 2.0.1

* Implement connector status for OCPP 2.0.1

* Configure measurands on charger with OCPP 2.0.1

Also report available measurands to home assistant

* Implement set availability and reboot with OCPP 2.0.1

* Implement trigger status notification with OCPP 2.0.1

* Implement get/set variables with OCPP 2.0.1

* Implement same authorisation logic for OCPP 2.0.1

Same as that used for OCPP 1.6, based on configuration.yaml

* Support transaction measurements with OCPP 2.0.1

* Report charging state from OCPP 2.0.1 to HA

* Report id token from OCPP 2.0.1 transactions to HA

* Implement remote start and remote stop with OCPP 2.0.1

* Implement current limit with OCPP 2.0.1

* Clean up unused imports

* Add common functions to be reused by OCPP 2.0.1 tests

Only use switch and button pressing functions in existing 1.6 tests in
this commit.

* Add simple OCPP 2.0.1 test

Test start-up, remote start and remote stop

* Test realistic transaction with OCPP 2.0.1

* Test get/set variable services

* Test more 2.0.1 calls and services

* Move meter value processing to base ChargePoint

* Reuse OCPP 1.6 meter value logic for 2.0.1

* Round energy consumption to 3 decimal places

Subtracting to floats causes imprecision

---------

Co-authored-by: Arseniy Lartsev <[email protected]>
  • Loading branch information
ars3niy and Arseniy Lartsev authored Nov 25, 2024
1 parent b8f190c commit fb59acd
Show file tree
Hide file tree
Showing 13 changed files with 3,880 additions and 1,469 deletions.
1,444 changes: 34 additions & 1,410 deletions custom_components/ocpp/api.py

Large diffs are not rendered by default.

851 changes: 851 additions & 0 deletions custom_components/ocpp/chargepoint.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion custom_components/ocpp/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
DEFAULT_SSL = False
DEFAULT_SSL_CERTFILE_PATH = pathlib.Path.cwd().joinpath("fullchain.pem")
DEFAULT_SSL_KEYFILE_PATH = pathlib.Path.cwd().joinpath("privkey.pem")
DEFAULT_SUBPROTOCOL = "ocpp1.6"
DEFAULT_SUBPROTOCOL = "ocpp1.6,ocpp2.0.1"
OCPP_2_0 = "ocpp2.0"
DEFAULT_METER_INTERVAL = 60
DEFAULT_IDLE_INTERVAL = 900
DEFAULT_WEBSOCKET_CLOSE_TIMEOUT = 10
Expand Down
2 changes: 2 additions & 0 deletions custom_components/ocpp/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class HAChargerServices(str, Enum):
service_unlock = "unlock"
service_update_firmware = "update_firmware"
service_configure = "configure"
service_configure_v201 = "configure_v201"
service_get_configuration = "get_configuration"
service_get_configuration_v201 = "get_configuration_v201"
service_get_diagnostics = "get_diagnostics"
service_clear_profile = "clear_profile"
service_data_transfer = "data_transfer"
Expand Down
Loading

0 comments on commit fb59acd

Please sign in to comment.