From b6736a2cbdac9148cf785b81937408164b7383f5 Mon Sep 17 00:00:00 2001 From: isabelle-tmh <108529739+isabelle-tmh@users.noreply.github.com> Date: Tue, 24 Jan 2023 16:10:36 +0100 Subject: [PATCH] Add enum for OCPP 1.6 ConfigurationKey (#413) Co-authored-by: Wessel --- ocpp/v16/enums.py | 74 +++++++++++++++++++++++ tests/v16/test_v16_enums.py | 113 ++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) diff --git a/ocpp/v16/enums.py b/ocpp/v16/enums.py index 4adee58b6..8071fe17c 100644 --- a/ocpp/v16/enums.py +++ b/ocpp/v16/enums.py @@ -309,6 +309,80 @@ class ConfigurationStatus(str, Enum): notSupported = "NotSupported" +class ConfigurationKey(str, Enum): + """ + Configuration Key Names. + """ + + # 9.1 Core Profile + allow_offline_tx_for_unknown_id = "AllowOfflineTxForUnknownId" + authorization_cache_enabled = "AuthorizationCacheEnabled" + authorize_remote_tx_requests = "AuthorizeRemoteTxRequests" + blink_repeat = "BlinkRepeat" + clock_aligned_data_interval = "ClockAlignedDataInterval" + connection_time_out = "ConnectionTimeOut" + connector_phase_rotation = "ConnectorPhaseRotation" + connector_phase_rotation_max_length = "ConnectorPhaseRotationMaxLength" + get_configuration_max_keys = "GetConfigurationMaxKeys" + heartbeat_interval = "HeartbeatInterval" + light_intensity = "LightIntensity" + local_authorize_offline = "LocalAuthorizeOffline" + local_pre_authorize = "LocalPreAuthorize" + max_energy_on_invalid_id = "MaxEnergyOnInvalidId" + meter_values_aligned_data = "MeterValuesAlignedData" + meter_values_aligned_data_max_length = "MeterValuesAlignedDataMaxLength" + meter_values_sampled_data = "MeterValuesSampledData" + meter_values_sampled_data_max_length = "MeterValuesSampledDataMaxLength" + meter_value_sample_interval = "MeterValueSampleInterval" + minimum_status_duration = "MinimumStatusDuration" + number_of_connectors = "NumberOfConnectors" + reset_retries = "ResetRetries" + stop_transaction_on_ev_side_disconnect = "StopTransactionOnEVSideDisconnect" + stop_transaction_on_invalid_id = "StopTransactionOnInvalidId" + stop_txn_aligned_data = "StopTxnAlignedData" + stop_txn_aligned_data_max_length = "StopTxnAlignedDataMaxLength" + stop_txn_sampled_data = "StopTxnSampledData" + stop_txn_sampled_data_max_length = "StopTxnSampledDataMaxLength" + supported_feature_profiles = "SupportedFeatureProfiles" + supported_feature_profiles_max_length = "SupportedFeatureProfilesMaxLength" + transaction_message_attempts = "TransactionMessageAttempts" + transaction_message_retry_interval = "TransactionMessageRetryInterval" + unlock_connector_on_ev_side_disconnect = "UnlockConnectorOnEVSideDisconnect" + web_socket_ping_interval = "WebSocketPingInterval" + + # 9.2 Local Auth List Management Profile + local_auth_list_enabled = "LocalAuthListEnabled" + local_auth_list_max_length = "LocalAuthListMaxLength" + send_local_list_max_length = "SendLocalListMaxLength" + + # 9.3 Reservation Profile + reserve_connector_zero_supported = "ReserveConnectorZeroSupported" + + # 9.4 Smart Charging Profile + charge_profile_max_stack_level = "ChargeProfileMaxStackLevel" + charging_schedule_allowed_charging_rate_unit = ( + "ChargingScheduleAllowedChargingRateUnit" + ) + charging_schedule_max_periods = "ChargingScheduleMaxPeriods" + connector_switch_3to1_phase_supported = "ConnectorSwitch3to1PhaseSupported" + max_charging_profiles_installed = "MaxChargingProfilesInstalled" + + # OCPP 1.6 ISO 15118 v10 added configuration keys + central_contract_validation_allowed = "CentralContractValidationAllowed" + certificate_signed_max_chain_size = "CertificateSignedMaxChainSize" + cert_signing_wait_minimum = "CertSigningWaitMinimum" + cert_signing_repeat_times = "CertSigningRepeatTimes" + certificate_store_max_length = "CertificateStoreMaxLength" + contract_validation_offline = "ContractValidationOffline" + iso_15118_pnc_enabled = "ISO15118PnCEnabled" + + # OCPP security whitepaper added configuration keys + additional_root_certificate_check = "AdditionalRootCertificateCheck" + authorization_key = "AuthorizationKey" + cpo_name = "CpoName" + security_profile = "SecurityProfile" + + class DataTransferStatus(str, Enum): """ Status in DataTransfer.conf. diff --git a/tests/v16/test_v16_enums.py b/tests/v16/test_v16_enums.py index 74a93183c..61fbee918 100644 --- a/tests/v16/test_v16_enums.py +++ b/tests/v16/test_v16_enums.py @@ -99,6 +99,119 @@ def test_configuration_status(): assert ConfigurationStatus.not_supported == "NotSupported" +def test_configuration_keys(): + assert ( + ConfigurationKey.allow_offline_tx_for_unknown_id == "AllowOfflineTxForUnknownId" + ) + assert ConfigurationKey.authorization_cache_enabled == "AuthorizationCacheEnabled" + assert ConfigurationKey.authorize_remote_tx_requests == "AuthorizeRemoteTxRequests" + assert ConfigurationKey.blink_repeat == "BlinkRepeat" + assert ConfigurationKey.clock_aligned_data_interval == "ClockAlignedDataInterval" + assert ConfigurationKey.connection_time_out == "ConnectionTimeOut" + assert ConfigurationKey.connector_phase_rotation == "ConnectorPhaseRotation" + assert ( + ConfigurationKey.connector_phase_rotation_max_length + == "ConnectorPhaseRotationMaxLength" + ) + assert ConfigurationKey.get_configuration_max_keys == "GetConfigurationMaxKeys" + assert ConfigurationKey.heartbeat_interval == "HeartbeatInterval" + assert ConfigurationKey.light_intensity == "LightIntensity" + assert ConfigurationKey.local_authorize_offline == "LocalAuthorizeOffline" + assert ConfigurationKey.local_pre_authorize == "LocalPreAuthorize" + assert ConfigurationKey.max_energy_on_invalid_id == "MaxEnergyOnInvalidId" + assert ConfigurationKey.meter_values_aligned_data == "MeterValuesAlignedData" + assert ( + ConfigurationKey.meter_values_aligned_data_max_length + == "MeterValuesAlignedDataMaxLength" + ) + assert ConfigurationKey.meter_values_sampled_data == "MeterValuesSampledData" + assert ( + ConfigurationKey.meter_values_sampled_data_max_length + == "MeterValuesSampledDataMaxLength" + ) + assert ConfigurationKey.meter_value_sample_interval == "MeterValueSampleInterval" + assert ConfigurationKey.minimum_status_duration == "MinimumStatusDuration" + assert ConfigurationKey.number_of_connectors == "NumberOfConnectors" + assert ConfigurationKey.reset_retries == "ResetRetries" + assert ( + ConfigurationKey.stop_transaction_on_ev_side_disconnect + == "StopTransactionOnEVSideDisconnect" + ) + assert ( + ConfigurationKey.stop_transaction_on_invalid_id == "StopTransactionOnInvalidId" + ) + assert ConfigurationKey.stop_txn_aligned_data == "StopTxnAlignedData" + assert ( + ConfigurationKey.stop_txn_aligned_data_max_length + == "StopTxnAlignedDataMaxLength" + ) + assert ConfigurationKey.stop_txn_sampled_data == "StopTxnSampledData" + assert ( + ConfigurationKey.stop_txn_sampled_data_max_length + == "StopTxnSampledDataMaxLength" + ) + assert ConfigurationKey.supported_feature_profiles == "SupportedFeatureProfiles" + assert ( + ConfigurationKey.supported_feature_profiles_max_length + == "SupportedFeatureProfilesMaxLength" + ) + assert ConfigurationKey.transaction_message_attempts == "TransactionMessageAttempts" + assert ( + ConfigurationKey.transaction_message_retry_interval + == "TransactionMessageRetryInterval" + ) + assert ( + ConfigurationKey.unlock_connector_on_ev_side_disconnect + == "UnlockConnectorOnEVSideDisconnect" + ) + assert ConfigurationKey.web_socket_ping_interval == "WebSocketPingInterval" + assert ConfigurationKey.local_auth_list_enabled == "LocalAuthListEnabled" + assert ConfigurationKey.local_auth_list_max_length == "LocalAuthListMaxLength" + assert ConfigurationKey.send_local_list_max_length == "SendLocalListMaxLength" + assert ( + ConfigurationKey.reserve_connector_zero_supported + == "ReserveConnectorZeroSupported" + ) + assert ( + ConfigurationKey.charge_profile_max_stack_level == "ChargeProfileMaxStackLevel" + ) + assert ( + ConfigurationKey.charging_schedule_allowed_charging_rate_unit + == "ChargingScheduleAllowedChargingRateUnit" + ) + assert ( + ConfigurationKey.charging_schedule_max_periods == "ChargingScheduleMaxPeriods" + ) + assert ( + ConfigurationKey.connector_switch_3to1_phase_supported + == "ConnectorSwitch3to1PhaseSupported" + ) + assert ( + ConfigurationKey.max_charging_profiles_installed + == "MaxChargingProfilesInstalled" + ) + assert ( + ConfigurationKey.central_contract_validation_allowed + == "CentralContractValidationAllowed" + ) + assert ( + ConfigurationKey.certificate_signed_max_chain_size + == "CertificateSignedMaxChainSize" + ) + assert ConfigurationKey.cert_signing_wait_minimum == "CertSigningWaitMinimum" + assert ConfigurationKey.cert_signing_repeat_times == "CertSigningRepeatTimes" + assert ConfigurationKey.certificate_store_max_length == "CertificateStoreMaxLength" + assert ConfigurationKey.contract_validation_offline == "ContractValidationOffline" + assert ConfigurationKey.iso_15118_pnc_enabled == "ISO15118PnCEnabled" + assert ( + ConfigurationKey.additional_root_certificate_check + == "AdditionalRootCertificateCheck" + ) + assert ConfigurationKey.authorization_key == "AuthorizationKey" + assert ConfigurationKey.cpo_name == "CpoName" + assert ConfigurationKey.security_profile == "SecurityProfile" + + def test_data_transfer_status(): assert DataTransferStatus.accepted == "Accepted" assert DataTransferStatus.rejected == "Rejected"