diff --git a/ocpp/v201/call.py b/ocpp/v201/call.py index ddc681606..7ffdb46dd 100644 --- a/ocpp/v201/call.py +++ b/ocpp/v201/call.py @@ -2,19 +2,21 @@ from dataclasses import dataclass from typing import Any, Dict, List, Optional +from ocpp.v201 import datatypes, enums + @dataclass class Authorize: - id_token: Dict + id_token: datatypes.IdTokenType certificate: Optional[str] = None - iso15118_certificate_hash_data: Optional[List] = None + iso15118_certificate_hash_data: Optional[List[datatypes.OCSPRequestDataType]] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class BootNotification: - charging_station: Dict - reason: str + charging_station: datatypes.ChargingStationType + reason: enums.BootReasonEnumType custom_data: Optional[Dict[str, Any]] = None @@ -27,14 +29,14 @@ class CancelReservation: @dataclass class CertificateSigned: certificate_chain: str - certificate_type: Optional[str] = None + certificate_type: Optional[enums.CertificateSigningUseEnumType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class ChangeAvailability: - operational_status: str - evse: Optional[Dict] = None + operational_status: enums.OperationalStatusEnumType + evse: Optional[datatypes.EVSEType] = None custom_data: Optional[Dict[str, Any]] = None @@ -46,7 +48,7 @@ class ClearCache: @dataclass class ClearChargingProfile: charging_profile_id: Optional[int] = None - charging_profile_criteria: Optional[Dict] = None + charging_profile_criteria: Optional[datatypes.ClearChargingProfileType] = None custom_data: Optional[Dict[str, Any]] = None @@ -58,13 +60,13 @@ class ClearDisplayMessage: @dataclass class ClearVariableMonitoring: - id: List + id: List[int] custom_data: Optional[Dict[str, Any]] = None @dataclass class ClearedChargingLimit: - charging_limit_source: str + charging_limit_source: enums.ChargingLimitSourceEnumType evse_id: Optional[int] = None custom_data: Optional[Dict[str, Any]] = None @@ -81,8 +83,8 @@ class CustomerInformation: request_id: int report: bool clear: bool - customer_certificate: Optional[Dict] = None - id_token: Optional[Dict] = None + customer_certificate: Optional[datatypes.CertificateHashDataType] = None + id_token: Optional[datatypes.IdTokenType] = None customer_identifier: Optional[str] = None custom_data: Optional[Dict[str, Any]] = None @@ -97,13 +99,13 @@ class DataTransfer: @dataclass class DeleteCertificate: - certificate_hash_data: Dict + certificate_hash_data: datatypes.CertificateHashDataType custom_data: Optional[Dict[str, Any]] = None @dataclass class FirmwareStatusNotification: - status: str + status: enums.FirmwareStatusEnumType request_id: Optional[int] = None custom_data: Optional[Dict[str, Any]] = None @@ -111,7 +113,7 @@ class FirmwareStatusNotification: @dataclass class Get15118EVCertificate: iso15118_schema_version: str - action: str + action: enums.CertificateActionEnumType exi_request: str custom_data: Optional[Dict[str, Any]] = None @@ -119,20 +121,20 @@ class Get15118EVCertificate: @dataclass class GetBaseReport: request_id: int - report_base: str + report_base: enums.ReportBaseEnumType custom_data: Optional[Dict[str, Any]] = None @dataclass class GetCertificateStatus: - ocsp_request_data: Dict + ocsp_request_data: datatypes.OCSPRequestDataType custom_data: Optional[Dict[str, Any]] = None @dataclass class GetChargingProfiles: request_id: int - charging_profile: Dict + charging_profile: datatypes.ChargingProfileCriterionType evse_id: Optional[int] = None custom_data: Optional[Dict[str, Any]] = None @@ -141,22 +143,22 @@ class GetChargingProfiles: class GetCompositeSchedule: duration: int evse_id: int - charging_rate_unit: Optional[str] = None + charging_rate_unit: Optional[enums.ChargingRateUnitEnumType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetDisplayMessages: request_id: int - id: Optional[List] = None - priority: Optional[str] = None - state: Optional[str] = None + id: Optional[List[int]] = None + priority: Optional[enums.MessagePriorityEnumType] = None + state: Optional[enums.MessageStateEnumType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetInstalledCertificateIds: - certificate_type: Optional[List] = None + certificate_type: Optional[List[enums.GetCertificateIdUseEnumType]] = None custom_data: Optional[Dict[str, Any]] = None @@ -167,8 +169,8 @@ class GetLocalListVersion: @dataclass class GetLog: - log: Dict - log_type: str + log: datatypes.LogParametersType + log_type: enums.LogEnumType request_id: int retries: Optional[int] = None retry_interval: Optional[int] = None @@ -178,16 +180,16 @@ class GetLog: @dataclass class GetMonitoringReport: request_id: int - component_variable: Optional[List] = None - monitoring_criteria: Optional[List] = None + component_variable: Optional[List[datatypes.ComponentVariableType]] = None + monitoring_criteria: Optional[List[enums.MonitoringCriterionEnumType]] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetReport: request_id: int - component_variable: Optional[List] = None - component_criteria: Optional[List] = None + component_variable: Optional[List[datatypes.ComponentVariableType]] = None + component_criteria: Optional[List[enums.ComponentCriterionEnumType]] = None custom_data: Optional[Dict[str, Any]] = None @@ -199,7 +201,7 @@ class GetTransactionStatus: @dataclass class GetVariables: - get_variable_data: List + get_variable_data: List[datatypes.GetVariableDataType] custom_data: Optional[Dict[str, Any]] = None @@ -210,14 +212,14 @@ class Heartbeat: @dataclass class InstallCertificate: - certificate_type: str + certificate_type: enums.InstallCertificateUseEnumType certificate: str custom_data: Optional[Dict[str, Any]] = None @dataclass class LogStatusNotification: - status: str + status: enums.UploadLogStatusEnumType request_id: Optional[int] = None custom_data: Optional[Dict[str, Any]] = None @@ -225,14 +227,14 @@ class LogStatusNotification: @dataclass class MeterValues: evse_id: int - meter_value: List + meter_value: List[datatypes.MeterValueType] custom_data: Optional[Dict[str, Any]] = None @dataclass class NotifyChargingLimit: - charging_limit: Dict - charging_schedule: Optional[List] = None + charging_limit: datatypes.ChargingLimitType + charging_schedule: Optional[List[datatypes.ChargingScheduleType]] = None evse_id: Optional[int] = None custom_data: Optional[Dict[str, Any]] = None @@ -250,14 +252,14 @@ class NotifyCustomerInformation: @dataclass class NotifyDisplayMessages: request_id: int - message_info: Optional[List] = None + message_info: Optional[List[datatypes.MessageInfoType]] = None tbc: Optional[bool] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class NotifyEVChargingNeeds: - charging_needs: Dict + charging_needs: datatypes.ChargingNeedsType evse_id: int max_schedule_tuples: Optional[int] = None custom_data: Optional[Dict[str, Any]] = None @@ -266,7 +268,7 @@ class NotifyEVChargingNeeds: @dataclass class NotifyEVChargingSchedule: time_base: str - charging_schedule: Dict + charging_schedule: datatypes.ChargingScheduleType evse_id: int custom_data: Optional[Dict[str, Any]] = None @@ -275,7 +277,7 @@ class NotifyEVChargingSchedule: class NotifyEvent: generated_at: str seq_no: int - event_data: List + event_data: List[datatypes.EventDataType] tbc: Optional[bool] = None custom_data: Optional[Dict[str, Any]] = None @@ -285,7 +287,7 @@ class NotifyMonitoringReport: request_id: int seq_no: int generated_at: str - monitor: Optional[List] = None + monitor: Optional[List[datatypes.MonitoringDataType]] = None tbc: Optional[bool] = None custom_data: Optional[Dict[str, Any]] = None @@ -295,7 +297,7 @@ class NotifyReport: request_id: int generated_at: str seq_no: int - report_data: Optional[List] = None + report_data: Optional[List[datatypes.ReportDataType]] = None tbc: Optional[bool] = None custom_data: Optional[Dict[str, Any]] = None @@ -312,8 +314,8 @@ class PublishFirmware: @dataclass class PublishFirmwareStatusNotification: - status: str - location: Optional[List] = None + status: enums.PublishFirmwareStatusEnumType + location: Optional[List[str]] = None request_id: Optional[int] = None custom_data: Optional[Dict[str, Any]] = None @@ -321,8 +323,8 @@ class PublishFirmwareStatusNotification: @dataclass class ReportChargingProfiles: request_id: int - charging_limit_source: str - charging_profile: List + charging_limit_source: enums.ChargingLimitSourceEnumType + charging_profile: List[datatypes.ChargingProfileType] evse_id: int tbc: Optional[bool] = None custom_data: Optional[Dict[str, Any]] = None @@ -330,11 +332,11 @@ class ReportChargingProfiles: @dataclass class RequestStartTransaction: - id_token: Dict + id_token: datatypes.IdTokenType remote_start_id: int evse_id: Optional[int] = None - group_id_token: Optional[Dict] = None - charging_profile: Optional[Dict] = None + group_id_token: Optional[datatypes.IdTokenType] = None + charging_profile: Optional[datatypes.ChargingProfileType] = None custom_data: Optional[Dict[str, Any]] = None @@ -347,7 +349,7 @@ class RequestStopTransaction: @dataclass class ReservationStatusUpdate: reservation_id: int - reservation_update_status: str + reservation_update_status: enums.ReservationUpdateStatusEnumType custom_data: Optional[Dict[str, Any]] = None @@ -355,16 +357,16 @@ class ReservationStatusUpdate: class ReserveNow: id: int expiry_date_time: str - id_token: Dict - connector_type: Optional[str] = None + id_token: datatypes.IdTokenType + connector_type: Optional[enums.ConnectorEnumType] = None evse_id: Optional[int] = None - group_id_token: Optional[Dict] = None + group_id_token: Optional[datatypes.IdTokenType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class Reset: - type: str + type: enums.ResetEnumType evse_id: Optional[int] = None custom_data: Optional[Dict[str, Any]] = None @@ -380,27 +382,27 @@ class SecurityEventNotification: @dataclass class SendLocalList: version_number: int - update_type: str - local_authorization_list: Optional[List] = None + update_type: enums.UpdateEnumType + local_authorization_list: Optional[List[datatypes.AuthorizationData]] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class SetChargingProfile: evse_id: int - charging_profile: Dict + charging_profile: datatypes.ChargingProfileType custom_data: Optional[Dict[str, Any]] = None @dataclass class SetDisplayMessage: - message: Dict + message: datatypes.MessageInfoType custom_data: Optional[Dict[str, Any]] = None @dataclass class SetMonitoringBase: - monitoring_base: str + monitoring_base: enums.MonitorBaseEnumType custom_data: Optional[Dict[str, Any]] = None @@ -413,33 +415,33 @@ class SetMonitoringLevel: @dataclass class SetNetworkProfile: configuration_slot: int - connection_data: Dict + connection_data: datatypes.NetworkConnectionProfileType custom_data: Optional[Dict[str, Any]] = None @dataclass class SetVariableMonitoring: - set_monitoring_data: List + set_monitoring_data: List[datatypes.SetMonitoringDataType] custom_data: Optional[Dict[str, Any]] = None @dataclass class SetVariables: - set_variable_data: List + set_variable_data: List[datatypes.SetVariableDataType] custom_data: Optional[Dict[str, Any]] = None @dataclass class SignCertificate: csr: str - certificate_type: Optional[str] = None + certificate_type: Optional[enums.CertificateSigningUseEnumType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class StatusNotification: timestamp: str - connector_status: str + connector_status: enums.ConnectorStatusEnumType evse_id: int connector_id: int custom_data: Optional[Dict[str, Any]] = None @@ -447,25 +449,25 @@ class StatusNotification: @dataclass class TransactionEvent: - event_type: str + event_type: enums.TransactionEventEnumType timestamp: str - trigger_reason: str + trigger_reason: enums.TriggerReasonEnumType seq_no: int - transaction_info: Dict - meter_value: Optional[List] = None + transaction_info: datatypes.TransactionType + meter_value: Optional[List[datatypes.MeterValueType]] = None offline: Optional[bool] = None number_of_phases_used: Optional[int] = None cable_max_current: Optional[int] = None reservation_id: Optional[int] = None - evse: Optional[Dict] = None - id_token: Optional[Dict] = None + evse: Optional[datatypes.EVSEType] = None + id_token: Optional[datatypes.IdTokenType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class TriggerMessage: - requested_message: str - evse: Optional[Dict] = None + requested_message: enums.MessageTriggerEnumType + evse: Optional[datatypes.EVSEType] = None custom_data: Optional[Dict[str, Any]] = None @@ -485,7 +487,7 @@ class UnpublishFirmware: @dataclass class UpdateFirmware: request_id: int - firmware: Dict + firmware: datatypes.FirmwareType retries: Optional[int] = None retry_interval: Optional[int] = None custom_data: Optional[Dict[str, Any]] = None diff --git a/ocpp/v201/call_result.py b/ocpp/v201/call_result.py index 9bf387b26..c4e78326c 100644 --- a/ocpp/v201/call_result.py +++ b/ocpp/v201/call_result.py @@ -2,11 +2,13 @@ from dataclasses import dataclass from typing import Any, Dict, List, Optional +from ocpp.v201 import datatypes, enums + @dataclass class Authorize: - id_token_info: Dict - certificate_status: Optional[str] = None + id_token_info: datatypes.IdTokenInfoType + certificate_status: Optional[enums.AuthorizeCertificateStatusEnumType] = None custom_data: Optional[Dict[str, Any]] = None @@ -14,56 +16,56 @@ class Authorize: class BootNotification: current_time: str interval: int - status: str - status_info: Optional[Dict] = None + status: enums.RegistrationStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class CancelReservation: - status: str - status_info: Optional[Dict] = None + status: enums.CancelReservationStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class CertificateSigned: - status: str - status_info: Optional[Dict] = None + status: enums.CertificateSignedStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class ChangeAvailability: - status: str - status_info: Optional[Dict] = None + status: enums.ChangeAvailabilityStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class ClearCache: - status: str - status_info: Optional[Dict] = None + status: enums.ClearCacheStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class ClearChargingProfile: - status: str - status_info: Optional[Dict] = None + status: enums.ClearChargingProfileStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class ClearDisplayMessage: - status: str - status_info: Optional[Dict] = None + status: enums.ClearMessageStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class ClearVariableMonitoring: - clear_monitoring_result: List + clear_monitoring_result: List[enums.ClearMonitoringStatusEnumType] custom_data: Optional[Dict[str, Any]] = None @@ -79,23 +81,23 @@ class CostUpdated: @dataclass class CustomerInformation: - status: str - status_info: Optional[Dict] = None + status: enums.CustomerInformationStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class DataTransfer: - status: str - status_info: Optional[Dict] = None + status: enums.DataTransferStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None data: Optional[Any] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class DeleteCertificate: - status: str - status_info: Optional[Dict] = None + status: enums.DeleteCertificateStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @@ -106,54 +108,56 @@ class FirmwareStatusNotification: @dataclass class Get15118EVCertificate: - status: str + status: enums.Iso15118EVCertificateStatusEnumType exi_response: str - status_info: Optional[Dict] = None + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetBaseReport: - status: str - status_info: Optional[Dict] = None + status: enums.GenericDeviceModelStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetCertificateStatus: - status: str - status_info: Optional[Dict] = None + status: enums.GetCertificateStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None ocsp_result: Optional[str] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetChargingProfiles: - status: str - status_info: Optional[Dict] = None + status: enums.GetChargingProfileStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetCompositeSchedule: - status: str - status_info: Optional[Dict] = None - schedule: Optional[Dict] = None + status: enums.GenericStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None + schedule: Optional[datatypes.CompositeScheduleType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetDisplayMessages: - status: str - status_info: Optional[Dict] = None + status: enums.GetDisplayMessagesStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetInstalledCertificateIds: - status: str - status_info: Optional[Dict] = None - certificate_hash_data_chain: Optional[List] = None + status: enums.GetInstalledCertificateStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None + certificate_hash_data_chain: Optional[ + List[datatypes.CertificateHashDataChainType] + ] = None custom_data: Optional[Dict[str, Any]] = None @@ -165,23 +169,23 @@ class GetLocalListVersion: @dataclass class GetLog: - status: str - status_info: Optional[Dict] = None + status: enums.LogStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None filename: Optional[str] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetMonitoringReport: - status: str - status_info: Optional[Dict] = None + status: enums.GenericDeviceModelStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class GetReport: - status: str - status_info: Optional[Dict] = None + status: enums.GenericDeviceModelStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @@ -194,7 +198,7 @@ class GetTransactionStatus: @dataclass class GetVariables: - get_variable_result: List + get_variable_result: List[datatypes.GetVariableResultType] custom_data: Optional[Dict[str, Any]] = None @@ -206,8 +210,8 @@ class Heartbeat: @dataclass class InstallCertificate: - status: str - status_info: Optional[Dict] = None + status: enums.InstallCertificateStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @@ -238,15 +242,15 @@ class NotifyDisplayMessages: @dataclass class NotifyEVChargingNeeds: - status: str - status_info: Optional[Dict] = None + status: enums.NotifyEVChargingNeedsStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class NotifyEVChargingSchedule: - status: str - status_info: Optional[Dict] = None + status: enums.GenericStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @@ -267,8 +271,8 @@ class NotifyReport: @dataclass class PublishFirmware: - status: str - status_info: Optional[Dict] = None + status: enums.GenericStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @@ -284,16 +288,16 @@ class ReportChargingProfiles: @dataclass class RequestStartTransaction: - status: str - status_info: Optional[Dict] = None + status: enums.RequestStartStopStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None transaction_id: Optional[str] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class RequestStopTransaction: - status: str - status_info: Optional[Dict] = None + status: enums.RequestStartStopStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @@ -304,15 +308,15 @@ class ReservationStatusUpdate: @dataclass class ReserveNow: - status: str - status_info: Optional[Dict] = None + status: enums.ReserveNowStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class Reset: - status: str - status_info: Optional[Dict] = None + status: enums.ResetStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @@ -323,62 +327,62 @@ class SecurityEventNotification: @dataclass class SendLocalList: - status: str - status_info: Optional[Dict] = None + status: enums.SendLocalListStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class SetChargingProfile: - status: str - status_info: Optional[Dict] = None + status: enums.ChargingProfileStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class SetDisplayMessage: - status: str - status_info: Optional[Dict] = None + status: enums.DisplayMessageStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class SetMonitoringBase: - status: str - status_info: Optional[Dict] = None + status: enums.GenericDeviceModelStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class SetMonitoringLevel: - status: str - status_info: Optional[Dict] = None + status: enums.GenericStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class SetNetworkProfile: - status: str - status_info: Optional[Dict] = None + status: enums.SetNetworkProfileStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class SetVariableMonitoring: - set_monitoring_result: List + set_monitoring_result: List[datatypes.SetMonitoringResultType] custom_data: Optional[Dict[str, Any]] = None @dataclass class SetVariables: - set_variable_result: List + set_variable_result: List[datatypes.SetVariableResultType] custom_data: Optional[Dict[str, Any]] = None @dataclass class SignCertificate: - status: str - status_info: Optional[Dict] = None + status: enums.GenericStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @@ -391,35 +395,35 @@ class StatusNotification: class TransactionEvent: total_cost: Optional[float] = None charging_priority: Optional[int] = None - id_token_info: Optional[Dict] = None - updated_personal_message: Optional[Dict] = None + id_token_info: Optional[datatypes.IdTokenInfoType] = None + updated_personal_message: Optional[datatypes.MessageContentType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class TriggerMessage: - status: str - status_info: Optional[Dict] = None + status: enums.TriggerMessageStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class UnlockConnector: - status: str - status_info: Optional[Dict] = None + status: enums.UnlockStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None @dataclass class UnpublishFirmware: - status: str + status: enums.UnpublishFirmwareStatusEnumType custom_data: Optional[Dict[str, Any]] = None @dataclass class UpdateFirmware: - status: str - status_info: Optional[Dict] = None + status: enums.FirmwareStatusEnumType + status_info: Optional[datatypes.StatusInfoType] = None custom_data: Optional[Dict[str, Any]] = None diff --git a/ocpp/v201/datatypes.py b/ocpp/v201/datatypes.py index 1a63ba43f..a2e650289 100644 --- a/ocpp/v201/datatypes.py +++ b/ocpp/v201/datatypes.py @@ -1,5 +1,5 @@ from dataclasses import dataclass -from typing import List, Optional +from typing import List, Optional, Union from ocpp.v201 import enums @@ -38,7 +38,7 @@ class APNType: """ apn: str - apn_authentication: enums.APNAuthenticationType + apn_authentication: enums.APNAuthenticationEnumType apn_user_name: Optional[str] = None apn_password: Optional[str] = None sim_pin: Optional[int] = None @@ -53,7 +53,7 @@ class CertificateHashDataType: DeleteCertificateRequest, CustomerInformationRequest """ - hash_algorithm: enums.HashAlgorithmType + hash_algorithm: enums.HashAlgorithmEnumType issuer_name_hash: str issuer_key_hash: str serial_number: str @@ -65,7 +65,7 @@ class CertificateHashDataChainType: CertificateHashDataChainType is used by: GetInstalledCertificateIdsResponse """ - certificate_type: enums.GetCertificateIdUseType + certificate_type: enums.GetCertificateIdUseEnumType certificate_hash_data: CertificateHashDataType child_certificate_hash_data: Optional[List[CertificateHashDataType]] = None @@ -74,7 +74,7 @@ class CertificateHashDataChainType: class ChargingLimitType: """ChargingLimitType is used by: NotifyChargingLimitRequest""" - charging_limit_source: enums.ChargingLimitSourceType + charging_limit_source: enums.ChargingLimitSourceEnumType is_grid_critical: Optional[bool] = None @@ -101,7 +101,7 @@ class ChargingNeedsType: ChargingNeedsType is used by: NotifyEVChargingNeedsRequest """ - requested_energy_transfer: enums.EnergyTransferModeType + requested_energy_transfer: enums.EnergyTransferModeEnumType departure_time: Optional[str] = None ac_charging_parameters: Optional[ACChargingParametersType] = None dc_charging_parameters: Optional[DCChargingParametersType] = None @@ -115,10 +115,10 @@ class ChargingProfileCriterionType: ChargingProfileCriterionType is used by: GetChargingProfilesRequest """ - charging_profile_purpose: Optional[enums.ChargingProfilePurposeType] = None + charging_profile_purpose: Optional[enums.ChargingProfilePurposeEnumType] = None stack_level: Optional[int] = None charging_profile_id: Optional[List[int]] = None - charging_limit_source: Optional[List[enums.ChargingLimitSourceType]] = None + charging_limit_source: Optional[List[enums.ChargingLimitSourceEnumType]] = None @dataclass @@ -150,7 +150,7 @@ class CostType: CostType is used by: ConsumptionCostType """ - cost_kind: enums.CostKindType + cost_kind: enums.CostKindEnumType amount: int amount_multiplier: Optional[int] = None @@ -197,7 +197,7 @@ class ChargingScheduleType: """ id: int - charging_rate_unit: enums.ChargingRateUnitType + charging_rate_unit: enums.ChargingRateUnitEnumType charging_schedule_period: List[ChargingSchedulePeriodType] start_schedule: Optional[str] = None duration: Optional[int] = None @@ -216,13 +216,13 @@ class ChargingProfileType: id: int stack_level: int - charging_profile_purpose: enums.ChargingProfilePurposeType - charging_profile_kind: enums.ChargingProfileKindType + charging_profile_purpose: enums.ChargingProfilePurposeEnumType + charging_profile_kind: enums.ChargingProfileKindEnumType charging_schedule: List[ChargingScheduleType] valid_from: Optional[str] = None valid_to: Optional[str] = None transaction_id: Optional[str] = None - recurrency_kind: Optional[enums.RecurrencyKindType] = None + recurrency_kind: Optional[enums.RecurrencyKindEnumType] = None @dataclass @@ -234,7 +234,7 @@ class ClearChargingProfileType: """ evse_id: Optional[int] = None - charging_profile_purpose: Optional[enums.ChargingProfilePurposeType] = None + charging_profile_purpose: Optional[enums.ChargingProfilePurposeEnumType] = None stack_level: Optional[int] = None @@ -274,7 +274,7 @@ class ClearMonitoringResultType: ClearMonitoringResultType is used by: ClearVariableMonitoringResponse """ - status: enums.ClearMonitoringStatusType + status: enums.ClearMonitoringStatusEnumType id: int status_info: Optional[StatusInfoType] = None @@ -354,7 +354,7 @@ class CompositeScheduleType: evse_id: int duration: int schedule_start: str - charging_rate_unit: enums.ChargingRateUnitType + charging_rate_unit: enums.ChargingRateUnitEnumType charging_schedule_period: List[ChargingSchedulePeriodType] @@ -364,7 +364,7 @@ class CostType: CostType is used by: ConsumptionCostType """ - cost_kind: enums.CostKindType + cost_kind: enums.CostKindEnumType amount: int amount_multiplier: Optional[int] = None @@ -388,9 +388,9 @@ class EventDataType: event_id: int timestamp: str - trigger: enums.EventTriggerType + trigger: enums.EventTriggerEnumType actual_value: str - event_notification_type: enums.EventNotificationType + event_notification_type: enums.EventNotificationEnumType component: ComponentType variable: VariableType cause: Optional[int] = None @@ -425,7 +425,7 @@ class GetVariableDataType: component: ComponentType variable: VariableType - attribute_type: Optional[enums.AttributeType] = None + attribute_type: Optional[enums.AttributeEnumType] = None @dataclass @@ -435,10 +435,10 @@ class GetVariableResultType: GetVariableResultType is used by: GetVariablesResponse """ - attribute_status: enums.GetVariableStatusType + attribute_status: enums.GetVariableStatusEnumType component: ComponentType variable: VariableType - attribute_type: Optional[enums.AttributeType] = None + attribute_type: Optional[enums.AttributeEnumType] = None attribute_value: Optional[str] = None attribute_status_info: Optional[StatusInfoType] = None @@ -454,7 +454,7 @@ class IdTokenType: """ id_token: str - type: enums.IdTokenType + type: enums.IdTokenEnumType additional_info: Optional[List[AdditionalInfoType]] = None @@ -467,7 +467,7 @@ class MessageContentType: TransactionEventResponse """ - format: enums.MessageFormatType + format: enums.MessageFormatEnumType content: str language: Optional[str] = None @@ -483,7 +483,7 @@ class IdTokenInfoType: TransactionEventResponse """ - status: enums.AuthorizationStatusType + status: enums.AuthorizationStatusEnumType cache_expiry_date_time: Optional[str] = None charging_priority: Optional[int] = None language_1: Optional[str] = None @@ -526,9 +526,9 @@ class MessageInfoType: """ id: int - priority: enums.MessagePriorityType + priority: enums.MessagePriorityEnumType message: MessageContentType - state: Optional[enums.MessageStateType] = None + state: Optional[enums.MessageStateEnumType] = None start_date_time: Optional[str] = None end_date_time: Optional[str] = None transaction_id: Optional[str] = None @@ -555,7 +555,7 @@ class UnitOfMeasureType: UnitOfMeasureType is used by: SampledValueType """ - unit: Optional[str] = None + unit: Optional[Union[enums.StandardizedUnitsOfMeasureType, str]] = None multiplier: Optional[int] = None @@ -571,10 +571,10 @@ class SampledValueType: """ value: float - context: Optional[enums.ReadingContextType] = None - measurand: Optional[enums.MeasurandType] = None - phase: Optional[enums.PhaseType] = None - location: Optional[enums.LocationType] = None + context: Optional[enums.ReadingContextEnumType] = None + measurand: Optional[enums.MeasurandEnumType] = None + phase: Optional[enums.PhaseEnumType] = None + location: Optional[enums.LocationEnumType] = None signed_meter_value: Optional[SignedMeterValueType] = None unit_of_measure: Optional[UnitOfMeasureType] = None @@ -615,7 +615,7 @@ class VariableMonitoringType: id: int transaction: bool value: float - type: enums.MonitorType + type: enums.MonitorEnumType severity: int @@ -642,7 +642,7 @@ class VPNType: user: str password: str key: str - type: enums.VPNType + type: enums.VPNEnumType group: Optional[str] = None @@ -654,12 +654,12 @@ class NetworkConnectionProfileType: NetworkConnectionProfileType is used by: SetNetworkProfileRequest """ - ocpp_version: enums.OCPPVersionType - ocpp_transport: enums.OCPPTransportType + ocpp_version: enums.OCPPVersionEnumType + ocpp_transport: enums.OCPPTransportEnumType ocpp_csms_url: str message_timeout: int security_profile: int - ocpp_interface: enums.OCPPInterfaceType + ocpp_interface: enums.OCPPInterfaceEnumType vpn: Optional[VPNType] = None apn: Optional[APNType] = None @@ -685,7 +685,7 @@ class OCSPRequestDataType: GetCertificateStatusRequest """ - hash_algorithm: enums.HashAlgorithmType + hash_algorithm: enums.HashAlgorithmEnumType issuer_name_hash: str issuer_key_hash: str serial_number: str @@ -699,9 +699,9 @@ class VariableAttributeType: VariableAttributeType is used by: NotifyReportRequest.ReportDataType """ - type: Optional[enums.AttributeType] = None + type: Optional[enums.AttributeEnumType] = None value: Optional[str] = None - mutability: Optional[enums.MutabilityType] = None + mutability: Optional[enums.MutabilityEnumType] = None persistent: Optional[bool] = None constant: Optional[bool] = None @@ -713,7 +713,7 @@ class VariableCharacteristicsType: VariableCharacteristicsType is used by: NotifyReportRequest.ReportDataType """ - data_type: enums.DataType + data_type: enums.DataEnumType supports_monitoring: bool unit: Optional[str] = None min_limit: Optional[float] = None @@ -756,7 +756,7 @@ class SetMonitoringDataType: """ value: float - type: enums.MonitorType + type: enums.MonitorEnumType severity: int component: ComponentType variable: VariableType @@ -771,8 +771,8 @@ class SetMonitoringResultType: SetMonitoringResultType is used by: SetVariableMonitoringResponse """ - status: enums.SetMonitoringStatusType - type: enums.MonitorType + status: enums.SetMonitoringStatusEnumType + type: enums.MonitorEnumType severity: int component: ComponentType variable: VariableType @@ -787,17 +787,17 @@ class SetVariableDataType: attribute_value: str component: ComponentType variable: VariableType - attribute_type: Optional[enums.AttributeType] = None + attribute_type: Optional[enums.AttributeEnumType] = None @dataclass class SetVariableResultType: """SetVariableResultType is used by: SetVariablesResponse""" - attribute_status: enums.SetVariableStatusType + attribute_status: enums.SetVariableStatusEnumType component: ComponentType variable: VariableType - attribute_type: Optional[enums.AttributeType] = None + attribute_type: Optional[enums.AttributeEnumType] = None attribute_status_info: Optional[StatusInfoType] = None @@ -806,7 +806,7 @@ class TransactionType: """TransactionType is used by: TransactionEventRequest""" transaction_id: str - charging_state: Optional[enums.ChargingStateType] = None + charging_state: Optional[enums.ChargingStateEnumType] = None time_spent_charging: Optional[int] = None - stopped_reason: Optional[enums.ReasonType] = None + stopped_reason: Optional[enums.ReasonEnumType] = None remote_start_id: Optional[int] = None diff --git a/ocpp/v201/enums.py b/ocpp/v201/enums.py index 2f903ca75..44a634c2d 100644 --- a/ocpp/v201/enums.py +++ b/ocpp/v201/enums.py @@ -153,7 +153,7 @@ def __init__(self, *args, **kwargs): update_firmware = "UpdateFirmware" -class APNAuthenticationType(StrEnum): +class APNAuthenticationEnumType(StrEnum): """ APNAuthenticationEnumType is used by setNetworkProfileSetNetworkProfileRequest.APNType @@ -165,7 +165,7 @@ class APNAuthenticationType(StrEnum): auto = "AUTO" -class AttributeType(StrEnum): +class AttributeEnumType(StrEnum): """ AttributeEnumType is used by Common:VariableAttributeType, getVariables:GetVariablesRequest.GetVariableDataType , @@ -181,7 +181,7 @@ class AttributeType(StrEnum): max_set = "MaxSet" -class AuthorizationStatusType(StrEnum): +class AuthorizationStatusEnumType(StrEnum): """ Elements that constitute an entry of a Local Authorization List update. """ @@ -201,7 +201,7 @@ class AuthorizationStatusType(StrEnum): unknown = "Unknown" -class AuthorizeCertificateStatusType(StrEnum): +class AuthorizeCertificateStatusEnumType(StrEnum): """ Status of the EV Contract certificate. """ @@ -215,7 +215,7 @@ class AuthorizeCertificateStatusType(StrEnum): contract_cancelled = "ContractCancelled" -class BootReasonType(StrEnum): +class BootReasonEnumType(StrEnum): """ BootReasonEnumType is used by bootNotificationBootNotificationRequest """ @@ -231,7 +231,7 @@ class BootReasonType(StrEnum): watchdog = "Watchdog" -class CancelReservationStatusType(StrEnum): +class CancelReservationStatusEnumType(StrEnum): """ Status in CancelReservationResponse. """ @@ -240,7 +240,7 @@ class CancelReservationStatusType(StrEnum): rejected = "Rejected" -class CertificateActionType(StrEnum): +class CertificateActionEnumType(StrEnum): """ CertificateActionEnumType is used by get15118EVCertificateGet15118EVCertificateRequest @@ -250,12 +250,12 @@ class CertificateActionType(StrEnum): update = "Update" -class CertificateSignedStatusType(StrEnum): +class CertificateSignedStatusEnumType(StrEnum): accepted = "Accepted" rejected = "Rejected" -class CertificateSigningUseType(StrEnum): +class CertificateSigningUseEnumType(StrEnum): """ CertificateSigningUseEnumType is used by signCertificate SignCertificateRequest , @@ -266,7 +266,7 @@ class CertificateSigningUseType(StrEnum): v2g_certificate = "V2GCertificate" -class ChangeAvailabilityStatusType(StrEnum): +class ChangeAvailabilityStatusEnumType(StrEnum): """ Status returned in response to ChangeAvailability.req. """ @@ -276,7 +276,7 @@ class ChangeAvailabilityStatusType(StrEnum): scheduled = "Scheduled" -class ChargingLimitSourceType(StrEnum): +class ChargingLimitSourceEnumType(StrEnum): """ Enumeration for indicating from which source a charging limit originates. """ @@ -287,7 +287,7 @@ class ChargingLimitSourceType(StrEnum): cso = "CSO" -class ChargingProfileKindType(StrEnum): +class ChargingProfileKindEnumType(StrEnum): """ "Absolute" Schedule periods are relative to a fixed point in time defined in the schedule. @@ -301,7 +301,7 @@ class ChargingProfileKindType(StrEnum): relative = "Relative" -class ChargingProfilePurposeType(StrEnum): +class ChargingProfilePurposeEnumType(StrEnum): """ In load balancing scenarios, the Charge Point has one or more local charging profiles that limit the power or current to be shared by all @@ -345,7 +345,7 @@ class ChargingProfilePurposeType(StrEnum): tx_profile = "TxProfile" -class ChargingProfileStatus(StrEnum): +class ChargingProfileStatusEnumType(StrEnum): """ Status returned in response to SetChargingProfile.req. """ @@ -354,7 +354,7 @@ class ChargingProfileStatus(StrEnum): rejected = "Rejected" -class ChargingRateUnitType(StrEnum): +class ChargingRateUnitEnumType(StrEnum): """ Unit in which a charging schedule is defined, as used in GetCompositeSchedule.req and ChargingSchedule @@ -364,7 +364,7 @@ class ChargingRateUnitType(StrEnum): amps = "A" -class ChargingStateType(StrEnum): +class ChargingStateEnumType(StrEnum): """ The state of the charging process. """ @@ -376,7 +376,7 @@ class ChargingStateType(StrEnum): idle = "Idle" -class ClearCacheStatusType(StrEnum): +class ClearCacheStatusEnumType(StrEnum): """ Status returned in response to ClearCache.req. """ @@ -385,7 +385,7 @@ class ClearCacheStatusType(StrEnum): rejected = "Rejected" -class ClearChargingProfileStatusType(StrEnum): +class ClearChargingProfileStatusEnumType(StrEnum): """ Status returned in response to ClearChargingProfile.req. """ @@ -394,7 +394,7 @@ class ClearChargingProfileStatusType(StrEnum): unknown = "Unknown" -class ClearMessageStatusType(StrEnum): +class ClearMessageStatusEnumType(StrEnum): """ Status returned in response to ClearDisplayMessageRequest. """ @@ -403,7 +403,7 @@ class ClearMessageStatusType(StrEnum): unknown = "Unknown" -class ClearMonitoringStatusType(StrEnum): +class ClearMonitoringStatusEnumType(StrEnum): """ ClearMonitoringStatusEnumType is used by CommonClearMonitoringResultType """ @@ -413,7 +413,7 @@ class ClearMonitoringStatusType(StrEnum): not_found = "NotFound" -class ComponentCriterionType(StrEnum): +class ComponentCriterionEnumType(StrEnum): """ ComponentCriterionEnumType is used by getReportGetReportRequest """ @@ -424,7 +424,7 @@ class ComponentCriterionType(StrEnum): problem = "Problem" -class ConnectorStatusType(StrEnum): +class ConnectorStatusEnumType(StrEnum): """ Status reported in StatusNotification.req. A status can be reported for the Charge Point main controller (connectorId = 0) or for a specific @@ -443,7 +443,7 @@ class ConnectorStatusType(StrEnum): faulted = "Faulted" -class ConnectorType(StrEnum): +class ConnectorEnumType(StrEnum): """ Allowed values of ConnectorCode. """ @@ -502,7 +502,7 @@ class ConnectorType(StrEnum): unknown = "Unknown" -class CostKindType(StrEnum): +class CostKindEnumType(StrEnum): """ CostKindEnumType is used by CommonCostType """ @@ -512,7 +512,7 @@ class CostKindType(StrEnum): renewable_generation_percentage = "RenewableGenerationPercentage" -class CustomerInformationStatusType(StrEnum): +class CustomerInformationStatusEnumType(StrEnum): """ Status in CustomerInformationResponse """ @@ -522,7 +522,7 @@ class CustomerInformationStatusType(StrEnum): invalid = "Invalid" -class DataTransferStatusType(StrEnum): +class DataTransferStatusEnumType(StrEnum): """ Status in DataTransferResponse. """ @@ -533,7 +533,7 @@ class DataTransferStatusType(StrEnum): unknown_vendor_id = "UnknownVendorId" -class DataType(StrEnum): +class DataEnumType(StrEnum): """ DataEnumType is used by CommonVariableCharacteristicsType """ @@ -549,7 +549,7 @@ class DataType(StrEnum): password_string = "passwordString" -class DeleteCertificateStatusType(StrEnum): +class DeleteCertificateStatusEnumType(StrEnum): """ DeleteCertificateStatusEnumType is used by deleteCertificateDeleteCertificateResponse @@ -560,7 +560,7 @@ class DeleteCertificateStatusType(StrEnum): not_found = "NotFound" -class DisplayMessageStatusType(StrEnum): +class DisplayMessageStatusEnumType(StrEnum): """ Result for a SetDisplayMessageRequest as used in a SetDisplayMessageResponse. @@ -574,7 +574,7 @@ class DisplayMessageStatusType(StrEnum): unknown_transaction = "UnknownTransaction" -class EnergyTransferModeType(StrEnum): +class EnergyTransferModeEnumType(StrEnum): """ Enumeration of energy transfer modes. """ @@ -585,7 +585,7 @@ class EnergyTransferModeType(StrEnum): ac_three_phase = "AC_three_phase" -class EventNotificationType(StrEnum): +class EventNotificationEnumType(StrEnum): """ Specifies the event notification type of the message. """ @@ -596,7 +596,7 @@ class EventNotificationType(StrEnum): custom_monitor = "CustomMonitor" -class EventTriggerType(StrEnum): +class EventTriggerEnumType(StrEnum): """ EventTriggerEnumType is used by notifyEventNotifyEventRequest.EventDataType @@ -607,7 +607,7 @@ class EventTriggerType(StrEnum): periodic = "Periodic" -class FirmwareStatusType(StrEnum): +class FirmwareStatusEnumType(StrEnum): """ Status of a firmware download as reported in FirmwareStatusNotificationRequest @@ -629,7 +629,7 @@ class FirmwareStatusType(StrEnum): signature_verified = "SignatureVerified" -class GenericDeviceModelStatusType(StrEnum): +class GenericDeviceModelStatusEnumType(StrEnum): """ Status of a firmware download as reported in GetBaseReportResponse """ @@ -640,7 +640,7 @@ class GenericDeviceModelStatusType(StrEnum): empty_result_set = "EmptyResultSet" -class GenericStatusType(StrEnum): +class GenericStatusEnumType(StrEnum): """ Generic message response status """ @@ -649,7 +649,7 @@ class GenericStatusType(StrEnum): rejected = "Rejected" -class GetCertificateIdUseType(StrEnum): +class GetCertificateIdUseEnumType(StrEnum): v2g_root_certificate = "V2GRootCertificate" mo_root_certificate = "MORootCertificate" csms_root_certificate = "CSMSRootCertificate" @@ -657,7 +657,7 @@ class GetCertificateIdUseType(StrEnum): manufacturer_root_certificate = "ManufacturerRootCertificate" -class GetCertificateStatusType(StrEnum): +class GetCertificateStatusEnumType(StrEnum): """ GetCertificateStatusEnumType is used by getCertificateStatusGetCertificateStatusResponse @@ -667,7 +667,7 @@ class GetCertificateStatusType(StrEnum): failed = "Failed" -class GetChargingProfileStatusType(StrEnum): +class GetChargingProfileStatusEnumType(StrEnum): """ GetChargingProfileStatusEnumType is used by getChargingProfilesGetChargingProfilesResponse @@ -677,7 +677,7 @@ class GetChargingProfileStatusType(StrEnum): no_profiles = "NoProfiles" -class GetDisplayMessagesStatusType(StrEnum): +class GetDisplayMessagesStatusEnumType(StrEnum): """ GetDisplayMessagesStatusEnumType is used by getDisplayMessagesGetDisplayMessagesResponse @@ -687,7 +687,7 @@ class GetDisplayMessagesStatusType(StrEnum): unknown = "Unknown" -class GetInstalledCertificateStatusType(StrEnum): +class GetInstalledCertificateStatusEnumType(StrEnum): """ GetInstalledCertificateStatusEnumType is used by getInstalledCertificateIdsGetInstalledCertificateIdsResponse @@ -697,7 +697,7 @@ class GetInstalledCertificateStatusType(StrEnum): notFound = "NotFound" -class GetVariableStatusType(StrEnum): +class GetVariableStatusEnumType(StrEnum): """ GetVariableStatusEnumType is used by getVariablesGetVariablesResponse.GetVariableResultType @@ -710,7 +710,7 @@ class GetVariableStatusType(StrEnum): not_supported_attribute_type = "NotSupportedAttributeType" -class HashAlgorithmType(StrEnum): +class HashAlgorithmEnumType(StrEnum): """ HashAlgorithmEnumType is used by CommonCertificateHashDataType , CommonOCSPRequestDataType @@ -721,7 +721,7 @@ class HashAlgorithmType(StrEnum): sha512 = "SHA512" -class IdTokenType(StrEnum): +class IdTokenEnumType(StrEnum): """ Allowable values of the IdTokenType field. """ @@ -736,7 +736,7 @@ class IdTokenType(StrEnum): no_authorization = "NoAuthorization" -class InstallCertificateStatusType(StrEnum): +class InstallCertificateStatusEnumType(StrEnum): """ InstallCertificateStatusEnumType is used by installCertificateInstallCertificateResponse @@ -747,7 +747,7 @@ class InstallCertificateStatusType(StrEnum): failed = "Failed" -class InstallCertificateUseType(StrEnum): +class InstallCertificateUseEnumType(StrEnum): """ InstallCertificateUseEnumType is used by installCertificateInstallCertificateRequest @@ -759,7 +759,7 @@ class InstallCertificateUseType(StrEnum): manufacturer_root_certificate = "ManufacturerRootCertificate" -class Iso15118EVCertificateStatusType(StrEnum): +class Iso15118EVCertificateStatusEnumType(StrEnum): """ Iso15118EVCertificateStatusEnumType is used by get15118EVCertificateGet15118EVCertificateResponse @@ -769,7 +769,7 @@ class Iso15118EVCertificateStatusType(StrEnum): failed = "Failed" -class LocationType(StrEnum): +class LocationEnumType(StrEnum): """ Allowable values of the optional "location" field of a value element in SampledValue. @@ -782,7 +782,7 @@ class LocationType(StrEnum): outlet = "Outlet" -class LogType(StrEnum): +class LogEnumType(StrEnum): """ LogEnumType is used by getLogGetLogRequest """ @@ -791,7 +791,7 @@ class LogType(StrEnum): security_log = "SecurityLog" -class LogStatusType(StrEnum): +class LogStatusEnumType(StrEnum): """ Generic message response status """ @@ -801,7 +801,7 @@ class LogStatusType(StrEnum): accepted_canceled = "AcceptedCanceled" -class MeasurandType(StrEnum): +class MeasurandEnumType(StrEnum): """ Allowable values of the optional "measurand" field of a Value element, as used in MeterValues.req and StopTransaction.req messages. Default value of @@ -835,7 +835,7 @@ class MeasurandType(StrEnum): voltage = "Voltage" -class MessageFormatType(StrEnum): +class MessageFormatEnumType(StrEnum): """ Format of a message to be displayed on the display of the Charging Station. """ @@ -846,7 +846,7 @@ class MessageFormatType(StrEnum): utf8 = "UTF8" -class MessagePriorityType(StrEnum): +class MessagePriorityEnumType(StrEnum): """ Priority with which a message should be displayed on a Charging Station. """ @@ -856,7 +856,7 @@ class MessagePriorityType(StrEnum): normal_cycle = "NormalCycle" -class MessageStateType(StrEnum): +class MessageStateEnumType(StrEnum): """ State of the Charging Station during which a message SHALL be displayed. """ @@ -866,7 +866,7 @@ class MessageStateType(StrEnum): idle = "Idle" -class MessageTriggerType(StrEnum): +class MessageTriggerEnumType(StrEnum): """ Type of request to be triggered in a TriggerMessage.req """ @@ -887,7 +887,7 @@ class MessageTriggerType(StrEnum): publish_firmware_status_notification = "PublishFirmwareStatusNotification" -class MonitorType(StrEnum): +class MonitorEnumType(StrEnum): """ MonitorEnumType is used by CommonVariableMonitoringType """ @@ -899,7 +899,7 @@ class MonitorType(StrEnum): periodic_clock_aligned = "PeriodicClockAligned" -class MonitorBaseType(StrEnum): +class MonitorBaseEnumType(StrEnum): """ MonitoringBaseEnumType is used by setMonitoringBaseSetMonitoringBaseRequest @@ -910,7 +910,7 @@ class MonitorBaseType(StrEnum): hard_wired_only = "HardWiredOnly" -class MonitoringCriterionType(StrEnum): +class MonitoringCriterionEnumType(StrEnum): """ MonitoringCriterionEnumType is used by getMonitoringReportGetMonitoringReportRequest @@ -921,7 +921,7 @@ class MonitoringCriterionType(StrEnum): periodic_monitoring = "PeriodicMonitoring" -class MutabilityType(StrEnum): +class MutabilityEnumType(StrEnum): """ MutabilityEnumType is used by CommonVariableAttributeType """ @@ -931,7 +931,7 @@ class MutabilityType(StrEnum): read_write = "ReadWrite" -class NotifyEVChargingNeedsStatusType(StrEnum): +class NotifyEVChargingNeedsStatusEnumType(StrEnum): """ Accepted a SASchedule will be provided momentarily. Rejected Servoce is Not Available @@ -943,7 +943,7 @@ class NotifyEVChargingNeedsStatusType(StrEnum): processing = "Processing" -class OCPPInterfaceType(StrEnum): +class OCPPInterfaceEnumType(StrEnum): """ Enumeration of network interfaces. """ @@ -958,7 +958,7 @@ class OCPPInterfaceType(StrEnum): wireless3 = "Wireless3" -class OCPPTransportType(StrEnum): +class OCPPTransportEnumType(StrEnum): """ Enumeration of OCPP transport mechanisms. SOAP is currently not a valid value for OCPP 2.0. @@ -968,7 +968,7 @@ class OCPPTransportType(StrEnum): soap = "SOAP" -class OCPPVersionType(StrEnum): +class OCPPVersionEnumType(StrEnum): """ Enumeration of OCPP transport mechanisms. SOAP is currently not a valid value for OCPP 2.0. @@ -980,7 +980,7 @@ class OCPPVersionType(StrEnum): ocpp20 = "OCPP20" -class OperationalStatusType(StrEnum): +class OperationalStatusEnumType(StrEnum): """ Requested availability change in ChangeAvailability.req. """ @@ -989,7 +989,7 @@ class OperationalStatusType(StrEnum): operative = "Operative" -class PhaseType(StrEnum): +class PhaseEnumType(StrEnum): """ Phase as used in SampledValue. Phase specifies how a measured value is to be interpreted. Please note that not all values of Phase are applicable to @@ -1008,7 +1008,7 @@ class PhaseType(StrEnum): l3_l1 = "L3-L1" -class PublishFirmwareStatusType(StrEnum): +class PublishFirmwareStatusEnumType(StrEnum): """ Status for when publishing a Firmware """ @@ -1025,7 +1025,7 @@ class PublishFirmwareStatusType(StrEnum): publish_failed = "PublishFailed" -class ReadingContextType(StrEnum): +class ReadingContextEnumType(StrEnum): """ Values of the context field of a value in SampledValue. """ @@ -1040,7 +1040,7 @@ class ReadingContextType(StrEnum): trigger = "Trigger" -class ReasonType(StrEnum): +class ReasonEnumType(StrEnum): """ Reason for stopping a transaction in StopTransactionRequest """ @@ -1066,7 +1066,7 @@ class ReasonType(StrEnum): timeout = "Timeout" -class RecurrencyKindType(StrEnum): +class RecurrencyKindEnumType(StrEnum): """ "Daily" The schedule restarts at the beginning of the next day. "Weekly" The schedule restarts at the beginning of the next week @@ -1077,7 +1077,7 @@ class RecurrencyKindType(StrEnum): weekly = "Weekly" -class RegistrationStatusType(StrEnum): +class RegistrationStatusEnumType(StrEnum): """ Result of registration in response to BootNotification.req. """ @@ -1087,7 +1087,7 @@ class RegistrationStatusType(StrEnum): rejected = "Rejected" -class ReportBaseType(StrEnum): +class ReportBaseEnumType(StrEnum): """ Report Base Type required in GetBaseReportRequest """ @@ -1097,7 +1097,7 @@ class ReportBaseType(StrEnum): summary_inventory = "SummaryInventory" -class RequestStartStopStatusType(StrEnum): +class RequestStartStopStatusEnumType(StrEnum): """ The result of a RemoteStartTransaction.req or RemoteStopTransaction.req request. @@ -1107,12 +1107,12 @@ class RequestStartStopStatusType(StrEnum): rejected = "Rejected" -class ReservationUpdateStatusType(StrEnum): +class ReservationUpdateStatusEnumType(StrEnum): expired = "Expired" removed = "Removed" -class ReserveNowStatusType(StrEnum): +class ReserveNowStatusEnumType(StrEnum): """ Status in ReserveNowResponse. """ @@ -1124,7 +1124,7 @@ class ReserveNowStatusType(StrEnum): unavailable = "Unavailable" -class ResetStatusType(StrEnum): +class ResetStatusEnumType(StrEnum): """ Result of Reset.req """ @@ -1134,7 +1134,7 @@ class ResetStatusType(StrEnum): scheduled = "Scheduled" -class ResetType(StrEnum): +class ResetEnumType(StrEnum): """ Type of reset requested by Reset.req """ @@ -1143,7 +1143,7 @@ class ResetType(StrEnum): on_idle = "OnIdle" -class SendLocalListStatusType(StrEnum): +class SendLocalListStatusEnumType(StrEnum): """ Type of update for a SendLocalList Request. """ @@ -1153,7 +1153,7 @@ class SendLocalListStatusType(StrEnum): version_mismatch = "VersionMismatch" -class SetMonitoringStatusType(StrEnum): +class SetMonitoringStatusEnumType(StrEnum): """ Status in SetVariableMonitoringResponse """ @@ -1166,7 +1166,7 @@ class SetMonitoringStatusType(StrEnum): duplicate = "Duplicate" -class SetNetworkProfileStatusType(StrEnum): +class SetNetworkProfileStatusEnumType(StrEnum): """ Status in SetNetworkProfileResponse """ @@ -1176,7 +1176,7 @@ class SetNetworkProfileStatusType(StrEnum): failed = "Failed" -class SetVariableStatusType(StrEnum): +class SetVariableStatusEnumType(StrEnum): """ Status in ChangeConfigurationResponse. """ @@ -1189,7 +1189,7 @@ class SetVariableStatusType(StrEnum): reboot_required = "RebootRequired" -class TransactionEventType(StrEnum): +class TransactionEventEnumType(StrEnum): """ Type of Event in TransactionEventRequest """ @@ -1199,7 +1199,7 @@ class TransactionEventType(StrEnum): updated = "Updated" -class TriggerMessageStatusType(StrEnum): +class TriggerMessageStatusEnumType(StrEnum): """ Status in TriggerMessageResponse. """ @@ -1209,7 +1209,7 @@ class TriggerMessageStatusType(StrEnum): not_implemented = "NotImplemented" -class TriggerReasonType(StrEnum): +class TriggerReasonEnumType(StrEnum): """ Reason that triggered a transactionEventRequest """ @@ -1237,7 +1237,7 @@ class TriggerReasonType(StrEnum): reset_command = "ResetCommand" -class TxStartStopPointType(StrEnum): +class TxStartStopPointEnumType(StrEnum): """ The values allowed for the TxStartPoint and TxStopPoint variables. """ @@ -1250,7 +1250,7 @@ class TxStartStopPointType(StrEnum): power_path_closed = "PowerPathClosed" -class UnlockStatusType(StrEnum): +class UnlockStatusEnumType(StrEnum): """ Status in response to UnlockConnector.req. """ @@ -1261,7 +1261,7 @@ class UnlockStatusType(StrEnum): unknown_connector = "UnknownConnector" -class UnpublishFirmwareStatusType(StrEnum): +class UnpublishFirmwareStatusEnumType(StrEnum): """ Status for when unpublishing a Firmware (used by UnpublishFirmwareResponse) """ @@ -1271,7 +1271,7 @@ class UnpublishFirmwareStatusType(StrEnum): unpublished = "Unpublished" -class UpdateFirmwareStatusType(StrEnum): +class UpdateFirmwareStatusEnumType(StrEnum): """ Generic message response status for UpdateFirmwareResponse """ @@ -1283,7 +1283,7 @@ class UpdateFirmwareStatusType(StrEnum): revoked_certificate = "RevokedCertificate" -class UpdateType(StrEnum): +class UpdateEnumType(StrEnum): """ Type of update for a SendLocalList Request. """ @@ -1292,7 +1292,7 @@ class UpdateType(StrEnum): full = "Full" -class UploadLogStatusType(StrEnum): +class UploadLogStatusEnumType(StrEnum): """ Status in LogStatusNotificationRequest. """ @@ -1307,7 +1307,7 @@ class UploadLogStatusType(StrEnum): accepted_canceled = "AcceptedCanceled" -class VPNType(StrEnum): +class VPNEnumType(StrEnum): """ Enumeration of VPN Types used in SetNetworkProfileRequest.VPNType """ @@ -1321,7 +1321,7 @@ class VPNType(StrEnum): # DataTypes -class UnitOfMeasureType(StrEnum): +class StandardizedUnitsOfMeasureType(StrEnum): """ Allowable values of the optional "unit" field of a Value element, as used in MeterValues.req and StopTransaction.req messages. Default value of @@ -1330,7 +1330,7 @@ class UnitOfMeasureType(StrEnum): """ asu = "ASU" - b = "Bytes" + b = "B" db = "dB" dbm = "dBm" deg = "Deg" @@ -1378,7 +1378,7 @@ class StatusInfoReasonType(StrEnum): invalid_certificate = "InvalidCertificate" invalid_csr = "InvalidCSR" invalid_id_token = "InvalidIdToken" - invalid_message_sequence = "InvalidMessageSequence" + invalid_message_sequence = "InvalidMessageSeq" invalid_profile = "InvalidProfile" invalid_schedule = "InvalidSchedule" invalid_stack_level = "InvalidStackLevel" @@ -1536,7 +1536,7 @@ class PhysicalComponentName(StrEnum): vehicle_id_sensor = "VehicleIdSensor" -class GenericVariableName(StrEnum): +class StandardizedVariableName(StrEnum): """ Variable names where the component type is non-specific derived from a union of in appendices_CSV_v1.3.zip, @@ -1592,6 +1592,7 @@ class GenericVariableName(StrEnum): impedance = "Impedance" imsi = "IMSI" interval = "Interval" + iso15118_evse_id = "ISO15118EvseId" length = "Length" light = "Light" manufacturer = "Manufacturer" @@ -1967,7 +1968,6 @@ class TxCtrlrVariableName(StrEnum): See ControllerComponentName for referenced logical component """ - charging_time = "ChargingTime" ev_connection_time_out = "EVConnectionTimeOut" max_energy_on_invalid_id = "MaxEnergyOnInvalidId" stop_tx_on_ev_side_disconnect = "StopTxOnEVSideDisconnect" @@ -2120,7 +2120,6 @@ class ChargingStationVariableName(StrEnum): current_imbalance = "CurrentImbalance" ec_variant = "ECVariant" enabled = "Enabled" - identity = "Identity" model = "Model" operating_times = "OperatingTimes" overload = "Overload" @@ -2152,26 +2151,50 @@ class ConnectedEVVariableName(StrEnum): See PhysicalComponentName for referenced physical component """ + available = "Available" + + # Vehicle + vehicle_id = "VehicleId" protocol_agreed = "ProtocolAgreed" protocol_supported_by_ev = "ProtocolSupportedByEV" - vehicle_id = "VehicleId" + # Voltage and current values - ac_current = "ACCurrent" - ac_voltage = "ACVoltage" - dc_current = "DCCurrent" - dc_voltage = "DCVoltage" + ac_current_min_set = "ACCurrent.minSet" + ac_current_max_set = "ACCurrent.maxSet" + ac_voltage_max_set = "ACVoltage.maxSet" + dc_current_min_set = "DCCurrent.minSet" + dc_current_max_set = "DCCurrent.maxSet" + dc_current_target = "DCCurrent.target" + dc_voltage_min_set = "DCVoltage.minSet" + dc_voltage_max_set = "DCVoltage.maxSet" + dc_voltage_target = "DCVoltage.target" + # Power, energy and time values - power = "Power" - energy_import = "EnergyImport" - departure_time = "DepartureTime" + power_max_set = "Power.maxSet" energy_capacity = "EnergyCapacity" + energy_import_target = "EnergyImport.target" + departure_time = "DepartureTime" remaining_time_bulk = "RemainingTimeBulk" - remaining_time_full = "RemainingTimeFull" - state_of_charge = "StateOfCharge" + remaining_time_full_max_set = "RemainingTimeFull.maxSet" + remaining_time_full_actual = "RemainingTimeFull.actual" state_of_charge_bulk = "StateOfChargeBulk" + state_of_charge_max_set = "StateOfCharge.maxSet" + state_of_charge_actual = "StateOfCharge.actual" charging_complete_bulk = "ChargingCompleteBulk" charging_complete_full = "ChargingCompleteFull" + # Status values + battery_overvoltage = "BatteryOvervoltage" + battery_undervoltage = "BatteryUndervoltage" + charging_current_deviation = "ChargingCurrentDeviation" + battery_temperature = "BatteryTemperature" + voltage_deviation = "VoltageDeviation" + charging_system_error = "ChargingSystemError" + vehicle_shift_position = "VehicleShiftPosition" + vehicle_charging_enabled = "VehicleChargingEnabled" + charging_system_incompatibility = "ChargingSystemIncompatibility" + charger_connector_lock_fault = "ChargerConnectorLockFault" + class ChargingStateVariableName(StrEnum): """ @@ -2601,7 +2624,6 @@ class LocalEnergyStorageVariableName(StrEnum): See PhysicalComponentName for referenced physical component """ - capacity = "Capacity" energy_capacity = "EnergyCapacity" identity = "Identity" diff --git a/tests/test_charge_point.py b/tests/test_charge_point.py index 00571f9fd..074b4afd7 100644 --- a/tests/test_charge_point.py +++ b/tests/test_charge_point.py @@ -26,7 +26,11 @@ NetworkConnectionProfileType, VariableType, ) -from ocpp.v201.enums import OCPPInterfaceType, OCPPTransportType, OCPPVersionType +from ocpp.v201.enums import ( + OCPPInterfaceEnumType, + OCPPTransportEnumType, + OCPPVersionEnumType, +) def test_getters_should_not_be_called_during_routemap_setup(): @@ -138,12 +142,12 @@ def test_nested_remove_nones(): } connection_data = NetworkConnectionProfileType( - ocpp_version=OCPPVersionType.ocpp20, - ocpp_transport=OCPPTransportType.json, + ocpp_version=OCPPVersionEnumType.ocpp20, + ocpp_transport=OCPPTransportEnumType.json, ocpp_csms_url="wss://localhost:9000", message_timeout=60, security_profile=1, - ocpp_interface=OCPPInterfaceType.wired0, + ocpp_interface=OCPPInterfaceEnumType.wired0, vpn=None, apn=None, ) @@ -328,7 +332,7 @@ def test_serialization_of_collection_of_multiple_elements(): payload = call_result.SetVariables( set_variable_result=[ datatypes.SetVariableResultType( - attribute_status=enums.SetVariableStatusType.accepted, + attribute_status=enums.SetVariableStatusEnumType.accepted, component={ "name": "TemperatureSensor", "instance": "First", diff --git a/tests/v201/test_v201_data_types.py b/tests/v201/test_v201_data_types.py new file mode 100644 index 000000000..30cffc552 --- /dev/null +++ b/tests/v201/test_v201_data_types.py @@ -0,0 +1,1016 @@ +import json +from dataclasses import asdict, dataclass +from typing import TypeVar + +from ocpp.v201.datatypes import ( + ACChargingParametersType, + AdditionalInfoType, + APNType, + AuthorizationData, + CertificateHashDataChainType, + CertificateHashDataType, + ChargingLimitType, + ChargingNeedsType, + ChargingProfileCriterionType, + ChargingProfileType, + ChargingSchedulePeriodType, + ChargingScheduleType, + ChargingStationType, + ClearChargingProfileType, + ClearMonitoringResultType, + ComponentType, + ComponentVariableType, + CompositeScheduleType, + ConsumptionCostType, + CostType, + DCChargingParametersType, + EventDataType, + EVSEType, + FirmwareType, + GetVariableDataType, + GetVariableResultType, + IdTokenInfoType, + IdTokenType, + LogParametersType, + MessageContentType, + MessageInfoType, + MeterValueType, + ModemType, + MonitoringDataType, + NetworkConnectionProfileType, + OCSPRequestDataType, + RelativeTimeIntervalType, + ReportDataType, + SalesTariffEntryType, + SampledValueType, + SetMonitoringDataType, + SetMonitoringResultType, + SetVariableResultType, + StatusInfoType, + UnitOfMeasureType, + VariableAttributeType, + VariableCharacteristicsType, + VariableMonitoringType, + VariableType, +) +from ocpp.v201.enums import ( + APNAuthenticationEnumType, + AttributeEnumType, + AuthorizationStatusEnumType, + ChargingProfileKindEnumType, + ChargingProfilePurposeEnumType, + ChargingRateUnitEnumType, + ChargingStateEnumType, + ClearMonitoringStatusEnumType, + CostKindEnumType, + DataEnumType, + EnergyTransferModeEnumType, + EventNotificationEnumType, + EventTriggerEnumType, + HashAlgorithmEnumType, + IdTokenEnumType, + LocationEnumType, + MeasurandEnumType, + MessageFormatEnumType, + MonitorEnumType, + MutabilityEnumType, + OCPPInterfaceEnumType, + OCPPTransportEnumType, + OCPPVersionEnumType, + PhaseEnumType, + ReadingContextEnumType, + ReasonEnumType, + SetMonitoringStatusEnumType, + SetVariableStatusEnumType, + StandardizedUnitsOfMeasureType, + VPNEnumType, +) + +T = TypeVar("T", bound="dataclass") + + +def to_datatype(cls, dc: T): + to_dict = asdict(dc) + to_json = json.dumps(to_dict) + from_json = json.loads(to_json) + return cls(**from_json) + + +def test_ac_charging_parameters_type(): + acpt = ACChargingParametersType( + energy_amount=20.5, ev_min_current=10.0, ev_max_current=32.0, ev_max_voltage=400 + ) + + new_acpt = to_datatype(ACChargingParametersType, acpt) + + assert new_acpt.energy_amount == acpt.energy_amount + assert new_acpt.ev_min_current == acpt.ev_min_current + assert new_acpt.ev_max_current == acpt.ev_max_current + assert new_acpt.ev_max_voltage == acpt.ev_max_voltage + + +def test_additional_info_type(): + ait = AdditionalInfoType( + additional_id_token="additional_token123", type="type_value" + ) + + new_ait = to_datatype(AdditionalInfoType, ait) + + assert new_ait.additional_id_token == ait.additional_id_token + assert new_ait.type == ait.type + + +def test_apn_type(): + at = APNType( + apn="internet.example.com", + apn_authentication=APNAuthenticationEnumType.auto, + apn_user_name="username", + apn_password="password", + sim_pin=1234, + preferred_network="preferred", + use_only_preferred_network=True, + ) + + new_at = to_datatype(APNType, at) + + assert new_at.apn == at.apn + assert new_at.apn_authentication == at.apn_authentication + assert new_at.apn_user_name == at.apn_user_name + assert new_at.apn_password == at.apn_password + assert new_at.sim_pin == at.sim_pin + assert new_at.preferred_network == at.preferred_network + assert new_at.use_only_preferred_network == at.use_only_preferred_network + + +def test_authorization_data(): + ad = AuthorizationData( + id_token_info=IdTokenInfoType( + status=AuthorizationStatusEnumType.accepted, + cache_expiry_date_time="2024-01-01T10:00:00Z", + charging_priority=1, + language_1="en", + language_2="fr", + group_id_token=IdTokenType( + type=IdTokenEnumType.central, + id_token="1234567890", + ), + ), + id_token=IdTokenEnumType.central, + ) + + new_ad = to_datatype(AuthorizationData, ad) + + assert isinstance(new_ad.id_token_info, dict) + assert new_ad.id_token_info["status"] == ad.id_token_info.status + assert ( + new_ad.id_token_info["cache_expiry_date_time"] + == ad.id_token_info.cache_expiry_date_time + ) + assert ( + new_ad.id_token_info["charging_priority"] == ad.id_token_info.charging_priority + ) + assert new_ad.id_token_info["language_1"] == ad.id_token_info.language_1 + assert new_ad.id_token_info["language_2"] == ad.id_token_info.language_2 + assert isinstance(new_ad.id_token, str) + assert new_ad.id_token == ad.id_token + + +def test_certificate_hash_data_chain_type(): + chdct = CertificateHashDataChainType( + certificate_type="V2G", + certificate_hash_data=CertificateHashDataType( + hash_algorithm="SHA256", + issuer_name_hash="issuer_hash", + issuer_key_hash="key_hash", + serial_number="serial123", + ), + child_certificate_hash_data=[ + CertificateHashDataType( + hash_algorithm="SHA256", + issuer_name_hash="child_issuer_hash", + issuer_key_hash="child_key_hash", + serial_number="child_serial123", + ) + ], + ) + + new_chdct = to_datatype(CertificateHashDataChainType, chdct) + + assert new_chdct.certificate_type == chdct.certificate_type + assert isinstance(new_chdct.certificate_hash_data, dict) + assert ( + new_chdct.certificate_hash_data["hash_algorithm"] + == chdct.certificate_hash_data.hash_algorithm + ) + assert ( + new_chdct.certificate_hash_data["issuer_name_hash"] + == chdct.certificate_hash_data.issuer_name_hash + ) + assert ( + new_chdct.certificate_hash_data["issuer_key_hash"] + == chdct.certificate_hash_data.issuer_key_hash + ) + assert ( + new_chdct.certificate_hash_data["serial_number"] + == chdct.certificate_hash_data.serial_number + ) + assert isinstance(new_chdct.child_certificate_hash_data[0], dict) + assert ( + new_chdct.child_certificate_hash_data[0]["hash_algorithm"] + == chdct.child_certificate_hash_data[0].hash_algorithm + ) + + +def test_certificate_hash_data_type(): + chdt = CertificateHashDataType( + hash_algorithm="SHA256", + issuer_name_hash="issuer_hash", + issuer_key_hash="key_hash", + serial_number="serial123", + ) + + new_chdt = to_datatype(CertificateHashDataType, chdt) + + assert new_chdt.hash_algorithm == chdt.hash_algorithm + assert new_chdt.issuer_name_hash == chdt.issuer_name_hash + assert new_chdt.issuer_key_hash == chdt.issuer_key_hash + assert new_chdt.serial_number == chdt.serial_number + + +def test_charging_limit_type(): + clt = ChargingLimitType(charging_limit_source="EMS", is_grid_critical=True) + + new_clt = to_datatype(ChargingLimitType, clt) + + assert new_clt.charging_limit_source == clt.charging_limit_source + assert new_clt.is_grid_critical == clt.is_grid_critical + + +def test_charging_needs_type(): + cnt = ChargingNeedsType( + requested_energy_transfer=EnergyTransferModeEnumType.dc, + departure_time="2024-01-01T10:00:00Z", + ac_charging_parameters=ACChargingParametersType( + energy_amount=20, ev_min_current=10, ev_max_current=32, ev_max_voltage=400 + ), + dc_charging_parameters=DCChargingParametersType( + ev_max_current=100, + ev_max_voltage=500, + energy_amount=50, + ev_max_power=50000, + state_of_charge=80, + ), + ) + + new_cnt = to_datatype(ChargingNeedsType, cnt) + + assert new_cnt.requested_energy_transfer == cnt.requested_energy_transfer + assert new_cnt.departure_time == cnt.departure_time + assert isinstance(new_cnt.ac_charging_parameters, dict) + assert ( + new_cnt.ac_charging_parameters["energy_amount"] + == cnt.ac_charging_parameters.energy_amount + ) + assert ( + new_cnt.ac_charging_parameters["ev_min_current"] + == cnt.ac_charging_parameters.ev_min_current + ) + assert isinstance(new_cnt.dc_charging_parameters, dict) + assert ( + new_cnt.dc_charging_parameters["ev_max_current"] + == cnt.dc_charging_parameters.ev_max_current + ) + assert ( + new_cnt.dc_charging_parameters["state_of_charge"] + == cnt.dc_charging_parameters.state_of_charge + ) + + +def test_charging_profile_criterion_type(): + cpct = ChargingProfileCriterionType( + charging_profile_purpose=ChargingProfilePurposeEnumType.tx_default_profile, + stack_level=0, + charging_profile_id=[1, 2, 3], + ) + + new_cpct = to_datatype(ChargingProfileCriterionType, cpct) + + assert new_cpct.charging_profile_purpose == cpct.charging_profile_purpose + assert new_cpct.stack_level == cpct.stack_level + assert new_cpct.charging_profile_id == cpct.charging_profile_id + + +def test_charging_profile_type(): + cpt = ChargingProfileType( + id=1, + stack_level=0, + charging_profile_purpose=ChargingProfilePurposeEnumType.tx_default_profile, + charging_profile_kind=ChargingProfileKindEnumType.absolute, + charging_schedule=[ + ChargingScheduleType( + id=1, + charging_rate_unit=ChargingRateUnitEnumType.watts, + charging_schedule_period=[ + ChargingSchedulePeriodType( + start_period=0, limit=11000.0, number_phases=3 + ) + ], + start_schedule="2024-01-01T10:00:00Z", + duration=3600, + ) + ], + valid_from="2024-01-01T00:00:00Z", + valid_to="2024-12-31T23:59:59Z", + ) + + new_cpt = to_datatype(ChargingProfileType, cpt) + + assert new_cpt.id == cpt.id + assert new_cpt.stack_level == cpt.stack_level + assert new_cpt.charging_profile_purpose == cpt.charging_profile_purpose + assert new_cpt.charging_profile_kind == cpt.charging_profile_kind + assert isinstance(new_cpt.charging_schedule[0], dict) + assert new_cpt.charging_schedule[0]["id"] == cpt.charging_schedule[0].id + assert new_cpt.valid_from == cpt.valid_from + assert new_cpt.valid_to == cpt.valid_to + + +def test_charging_schedule_period_type(): + cspt = ChargingSchedulePeriodType( + start_period=0, limit=32.0, number_phases=3, phase_to_use=1 + ) + + new_cspt = to_datatype(ChargingSchedulePeriodType, cspt) + + assert new_cspt.start_period == cspt.start_period + assert new_cspt.limit == cspt.limit + assert new_cspt.number_phases == cspt.number_phases + assert new_cspt.phase_to_use == cspt.phase_to_use + + +def test_charging_station_type(): + cst = ChargingStationType( + model="Station Model X", + vendor_name="Vendor ABC", + serial_number="SN123456", + modem=ModemType(iccid="89001234567890123456", imsi="123456789012345"), + firmware_version="1.2.3", + ) + + new_cst = to_datatype(ChargingStationType, cst) + + assert new_cst.model == cst.model + assert new_cst.vendor_name == cst.vendor_name + assert new_cst.serial_number == cst.serial_number + assert isinstance(new_cst.modem, dict) + assert new_cst.modem["iccid"] == cst.modem.iccid + assert new_cst.modem["imsi"] == cst.modem.imsi + assert new_cst.firmware_version == cst.firmware_version + + +def test_clear_charging_profile_type(): + ccpt = ClearChargingProfileType( + evse_id=1, + charging_profile_purpose=ChargingProfilePurposeEnumType.tx_default_profile, + stack_level=0, + ) + + new_ccpt = to_datatype(ClearChargingProfileType, ccpt) + + assert new_ccpt.evse_id == ccpt.evse_id + assert new_ccpt.charging_profile_purpose == ccpt.charging_profile_purpose + assert new_ccpt.stack_level == ccpt.stack_level + + +def test_clear_monitoring_result_type(): + cmrt = ClearMonitoringResultType( + status=ClearMonitoringStatusEnumType.accepted, + id=123, + status_info=StatusInfoType( + reason_code=ReasonEnumType.other, + additional_info="Successfully cleared monitoring", + ), + ) + + new_cmrt = to_datatype(ClearMonitoringResultType, cmrt) + + assert new_cmrt.status == cmrt.status + assert new_cmrt.id == cmrt.id + assert isinstance(new_cmrt.status_info, dict) + assert new_cmrt.status_info["reason_code"] == cmrt.status_info.reason_code + assert new_cmrt.status_info["additional_info"] == cmrt.status_info.additional_info + + +def test_component_type(): + ct = ComponentType( + name="MainController", instance="instance1", evse=EVSEType(id=1, connector_id=2) + ) + + new_ct = to_datatype(ComponentType, ct) + + assert new_ct.name == ct.name + assert new_ct.instance == ct.instance + assert isinstance(new_ct.evse, dict) + assert new_ct.evse["id"] == ct.evse.id + assert new_ct.evse["connector_id"] == ct.evse.connector_id + + +def test_component_variable_type(): + cvt = ComponentVariableType( + component=ComponentType(name="MainController", instance="instance1"), + variable=VariableType(name="CurrentLimit", instance="instance1"), + ) + + new_cvt = to_datatype(ComponentVariableType, cvt) + + assert isinstance(new_cvt.component, dict) + assert new_cvt.component["name"] == cvt.component.name + assert new_cvt.component["instance"] == cvt.component.instance + assert isinstance(new_cvt.variable, dict) + assert new_cvt.variable["name"] == cvt.variable.name + assert new_cvt.variable["instance"] == cvt.variable.instance + + +def test_composite_schedule_type(): + cst = CompositeScheduleType( + evse_id=1, + duration=3600, + schedule_start="2024-01-01T10:00:00Z", + charging_rate_unit=ChargingRateUnitEnumType.watts, + charging_schedule_period=[ + ChargingSchedulePeriodType(start_period=0, limit=11000.0, number_phases=3) + ], + ) + + new_cst = to_datatype(CompositeScheduleType, cst) + + assert new_cst.evse_id == cst.evse_id + assert new_cst.duration == cst.duration + assert new_cst.schedule_start == cst.schedule_start + assert new_cst.charging_rate_unit == cst.charging_rate_unit + assert isinstance(new_cst.charging_schedule_period[0], dict) + assert ( + new_cst.charging_schedule_period[0]["start_period"] + == cst.charging_schedule_period[0].start_period + ) + assert ( + new_cst.charging_schedule_period[0]["limit"] + == cst.charging_schedule_period[0].limit + ) + + +def test_consumption_cost_type(): + cct = ConsumptionCostType( + start_value=0.0, + cost=[CostType(cost_kind="RelativePrice", amount=1.0, amount_multiplier=0)], + ) + + new_cct = to_datatype(ConsumptionCostType, cct) + + assert new_cct.start_value == cct.start_value + assert isinstance(new_cct.cost[0], dict) + assert new_cct.cost[0]["cost_kind"] == cct.cost[0].cost_kind + assert new_cct.cost[0]["amount"] == cct.cost[0].amount + assert new_cct.cost[0]["amount_multiplier"] == cct.cost[0].amount_multiplier + + +def test_cost_type(): + ct = CostType( + cost_kind=CostKindEnumType.carbon_dioxide_emission, + amount=1.0, + amount_multiplier=0, + ) + + new_ct = to_datatype(CostType, ct) + + assert new_ct.cost_kind == ct.cost_kind + assert new_ct.amount == ct.amount + assert new_ct.amount_multiplier == ct.amount_multiplier + + +def test_event_data_type(): + edt = EventDataType( + event_id=1, + timestamp="2024-01-01T10:00:00Z", + trigger=EventTriggerEnumType.alerting, + actual_value="High Temperature", + tech_code="TC001", + tech_info="Temperature sensor reading high", + cleared=False, + transaction_id="TX001", + variable_monitoring_id=1, + event_notification_type=EventNotificationEnumType.hard_wired_notification, + component=ComponentType(name="MainController", instance="instance1"), + variable=VariableType(name="Temperature", instance="instance1"), + ) + + new_edt = to_datatype(EventDataType, edt) + + assert new_edt.event_id == edt.event_id + assert new_edt.timestamp == edt.timestamp + assert new_edt.trigger == edt.trigger + assert new_edt.actual_value == edt.actual_value + assert new_edt.tech_code == edt.tech_code + assert new_edt.tech_info == edt.tech_info + assert new_edt.cleared == edt.cleared + assert new_edt.transaction_id == edt.transaction_id + assert new_edt.variable_monitoring_id == edt.variable_monitoring_id + assert new_edt.event_notification_type == edt.event_notification_type + assert isinstance(new_edt.component, dict) + assert new_edt.component["name"] == edt.component.name + assert isinstance(new_edt.variable, dict) + assert new_edt.variable["name"] == edt.variable.name + + +def test_firmware_type(): + ft = FirmwareType( + location="https://firmware.example.com/v1.2.3", + retrieve_date_time="2024-01-01T10:00:00Z", + install_date_time="2024-01-01T11:00:00Z", + signing_certificate="MIIB...", + signature="SHA256...", + ) + + new_ft = to_datatype(FirmwareType, ft) + + assert new_ft.location == ft.location + assert new_ft.retrieve_date_time == ft.retrieve_date_time + assert new_ft.install_date_time == ft.install_date_time + assert new_ft.signing_certificate == ft.signing_certificate + assert new_ft.signature == ft.signature + + +def test_get_variable_data_type(): + gvdt = GetVariableDataType( + component=ComponentType(name="MainController", instance="instance1"), + variable=VariableType(name="CurrentLimit", instance="instance1"), + attribute_type=AttributeEnumType.actual, + ) + + new_gvdt = to_datatype(GetVariableDataType, gvdt) + + assert isinstance(new_gvdt.component, dict) + assert new_gvdt.component["name"] == gvdt.component.name + assert new_gvdt.component["instance"] == gvdt.component.instance + assert isinstance(new_gvdt.variable, dict) + assert new_gvdt.variable["name"] == gvdt.variable.name + assert new_gvdt.variable["instance"] == gvdt.variable.instance + assert new_gvdt.attribute_type == gvdt.attribute_type + + +def test_get_variable_result_type(): + gvrt = GetVariableResultType( + attribute_status="Accepted", + attribute_type=AttributeEnumType.actual, + attribute_value="100", + component=ComponentType(name="MainController", instance="instance1"), + variable=VariableType(name="CurrentLimit", instance="instance1"), + ) + + new_gvrt = to_datatype(GetVariableResultType, gvrt) + + assert new_gvrt.attribute_status == gvrt.attribute_status + assert new_gvrt.attribute_type == gvrt.attribute_type + assert new_gvrt.attribute_value == gvrt.attribute_value + assert isinstance(new_gvrt.component, dict) + assert new_gvrt.component["name"] == gvrt.component.name + assert isinstance(new_gvrt.variable, dict) + assert new_gvrt.variable["name"] == gvrt.variable.name + + +def test_id_token_info_type(): + itit = IdTokenInfoType( + status="Accepted", + cache_expiry_date_time="2024-01-01T10:00:00Z", + charging_priority=1, + language_1="en", + language_2="fr", + group_id_token=IdTokenEnumType.central, + personal_message=MessageContentType( + format=MessageFormatEnumType.ascii, content="Welcome back!", language="en" + ), + ) + + new_itit = to_datatype(IdTokenInfoType, itit) + + assert new_itit.status == itit.status + assert new_itit.cache_expiry_date_time == itit.cache_expiry_date_time + assert new_itit.charging_priority == itit.charging_priority + assert new_itit.language_1 == itit.language_1 + assert new_itit.language_2 == itit.language_2 + assert isinstance(new_itit.group_id_token, str) + assert new_itit.group_id_token == itit.group_id_token + assert isinstance(new_itit.personal_message, dict) + assert new_itit.personal_message["content"] == itit.personal_message.content + + +def test_log_parameters_type(): + lpt = LogParametersType( + remote_location="https://logs.example.com", + oldest_timestamp="2024-01-01T00:00:00Z", + latest_timestamp="2024-01-01T23:59:59Z", + ) + + new_lpt = to_datatype(LogParametersType, lpt) + + assert new_lpt.remote_location == lpt.remote_location + assert new_lpt.oldest_timestamp == lpt.oldest_timestamp + assert new_lpt.latest_timestamp == lpt.latest_timestamp + + +def test_message_info_type(): + mit = MessageInfoType( + id=1, + priority=1, + message=MessageContentType( + format=MessageFormatEnumType.ascii, + content="Important notice", + language="en", + ), + display=ComponentType(name="MainDisplay", instance="instance1"), + state=ChargingStateEnumType.charging, + ) + + new_mit = to_datatype(MessageInfoType, mit) + + assert new_mit.id == mit.id + assert new_mit.priority == mit.priority + assert isinstance(new_mit.message, dict) + assert new_mit.message["content"] == mit.message.content + assert isinstance(new_mit.display, dict) + assert new_mit.display["name"] == mit.display.name + assert new_mit.state == mit.state + + +def test_meter_value_type(): + mvt = MeterValueType( + timestamp="2024-01-01T10:00:00Z", + sampled_value=[ + SampledValueType( + value=230.0, + context=ReadingContextEnumType.sample_periodic, + measurand=MeasurandEnumType.voltage, + phase=PhaseEnumType.l1, + location=LocationEnumType.outlet, + ) + ], + ) + + new_mvt = to_datatype(MeterValueType, mvt) + + assert new_mvt.timestamp == mvt.timestamp + assert isinstance(new_mvt.sampled_value[0], dict) + assert new_mvt.sampled_value[0]["value"] == mvt.sampled_value[0].value + assert new_mvt.sampled_value[0]["context"] == mvt.sampled_value[0].context + assert new_mvt.sampled_value[0]["measurand"] == mvt.sampled_value[0].measurand + assert new_mvt.sampled_value[0]["phase"] == mvt.sampled_value[0].phase + assert new_mvt.sampled_value[0]["location"] == mvt.sampled_value[0].location + + +def test_modem_type(): + mt = ModemType(iccid="89012345678901234567", imsi="123456789012345") + + new_mt = to_datatype(ModemType, mt) + + assert new_mt.iccid == mt.iccid + assert new_mt.imsi == mt.imsi + + +def test_monitoring_data_type(): + mdt = MonitoringDataType( + component=ComponentType(name="MainController", instance="instance1"), + variable=VariableType(name="Temperature", instance="instance1"), + variable_monitoring=VariableMonitoringType( + id=1, + transaction=True, + value=100.0, + type=MonitorEnumType.upper_threshold, + severity=1, + ), + ) + + new_mdt = to_datatype(MonitoringDataType, mdt) + + assert isinstance(new_mdt.component, dict) + assert new_mdt.component["name"] == mdt.component.name + assert isinstance(new_mdt.variable, dict) + assert new_mdt.variable["name"] == mdt.variable.name + assert isinstance(new_mdt.variable_monitoring, dict) + assert new_mdt.variable_monitoring["id"] == mdt.variable_monitoring.id + assert new_mdt.variable_monitoring["value"] == mdt.variable_monitoring.value + + +def test_network_connection_profile_type(): + ncpt = NetworkConnectionProfileType( + ocpp_version=OCPPVersionEnumType.ocpp20, + ocpp_transport=OCPPTransportEnumType.json, + ocpp_csms_url="wss://example.com/ocpp", + message_timeout=30, + security_profile=1, + ocpp_interface=OCPPInterfaceEnumType.wired0, + vpn=VPNEnumType.ikev2, + ) + + new_ncpt = to_datatype(NetworkConnectionProfileType, ncpt) + + assert new_ncpt.ocpp_version == ncpt.ocpp_version + assert new_ncpt.ocpp_transport == ncpt.ocpp_transport + assert new_ncpt.ocpp_csms_url == ncpt.ocpp_csms_url + assert new_ncpt.message_timeout == ncpt.message_timeout + assert new_ncpt.security_profile == ncpt.security_profile + assert new_ncpt.ocpp_interface == ncpt.ocpp_interface + assert new_ncpt.vpn == ncpt.vpn + + +def test_ocsp_request_data_type(): + ordt = OCSPRequestDataType( + hash_algorithm=HashAlgorithmEnumType.sha256, + issuer_name_hash="issuer_hash_value", + issuer_key_hash="issuer_key_hash_value", + serial_number="serial123", + responder_url="https://ocsp.example.com", + ) + + new_ordt = to_datatype(OCSPRequestDataType, ordt) + + assert new_ordt.hash_algorithm == ordt.hash_algorithm + assert new_ordt.issuer_name_hash == ordt.issuer_name_hash + assert new_ordt.issuer_key_hash == ordt.issuer_key_hash + assert new_ordt.serial_number == ordt.serial_number + assert new_ordt.responder_url == ordt.responder_url + + +def test_relative_time_interval_type(): + rtit = RelativeTimeIntervalType(start=0, duration=3600) + + new_rtit = to_datatype(RelativeTimeIntervalType, rtit) + + assert new_rtit.start == rtit.start + assert new_rtit.duration == rtit.duration + + +def test_report_data_type(): + rdt = ReportDataType( + component=ComponentType(name="MainController", instance="instance1"), + variable=VariableType(name="Temperature", instance="instance1"), + variable_attribute=[ + VariableAttributeType( + type=AttributeEnumType.actual, + value="25.5", + mutability="ReadWrite", + persistent=True, + constant=False, + ) + ], + variable_characteristics=VariableCharacteristicsType( + unit="Celsius", + data_type=DataEnumType.decimal, + min_limit="-20", + max_limit="50", + values_list=["10", "20", "30"], + supports_monitoring=True, + ), + ) + + new_rdt = to_datatype(ReportDataType, rdt) + + assert isinstance(new_rdt.component, dict) + assert new_rdt.component["name"] == rdt.component.name + assert isinstance(new_rdt.variable, dict) + assert new_rdt.variable["name"] == rdt.variable.name + assert isinstance(new_rdt.variable_attribute[0], dict) + assert new_rdt.variable_attribute[0]["type"] == rdt.variable_attribute[0].type + assert new_rdt.variable_attribute[0]["value"] == rdt.variable_attribute[0].value + assert isinstance(new_rdt.variable_characteristics, dict) + assert new_rdt.variable_characteristics["unit"] == rdt.variable_characteristics.unit + assert ( + new_rdt.variable_characteristics["data_type"] + == rdt.variable_characteristics.data_type + ) + assert ( + new_rdt.variable_characteristics["supports_monitoring"] + == rdt.variable_characteristics.supports_monitoring + ) + + +def test_sales_tariff_entry_type(): + stet = SalesTariffEntryType( + e_price_level=1, + relative_time_interval=RelativeTimeIntervalType(start=0, duration=3600), + consumption_cost=[ + ConsumptionCostType( + start_value=0.0, + cost=[ + CostType(cost_kind="RelativePrice", amount=1.0, amount_multiplier=0) + ], + ) + ], + ) + + new_stet = to_datatype(SalesTariffEntryType, stet) + + assert new_stet.e_price_level == stet.e_price_level + assert isinstance(new_stet.relative_time_interval, dict) + assert new_stet.relative_time_interval["start"] == stet.relative_time_interval.start + assert ( + new_stet.relative_time_interval["duration"] + == stet.relative_time_interval.duration + ) + assert isinstance(new_stet.consumption_cost[0], dict) + assert ( + new_stet.consumption_cost[0]["start_value"] + == stet.consumption_cost[0].start_value + ) + assert isinstance(new_stet.consumption_cost[0]["cost"][0], dict) + assert ( + new_stet.consumption_cost[0]["cost"][0]["cost_kind"] + == stet.consumption_cost[0].cost[0].cost_kind + ) + assert ( + new_stet.consumption_cost[0]["cost"][0]["amount"] + == stet.consumption_cost[0].cost[0].amount + ) + assert ( + new_stet.consumption_cost[0]["cost"][0]["amount_multiplier"] + == stet.consumption_cost[0].cost[0].amount_multiplier + ) + + +def test_sampled_value_type(): + svt = SampledValueType( + value=230.0, + context=ReadingContextEnumType.sample_periodic, + measurand=MeasurandEnumType.voltage, + phase=PhaseEnumType.l1, + location=LocationEnumType.outlet, + unit_of_measure=UnitOfMeasureType( + unit=StandardizedUnitsOfMeasureType.v, multiplier=0 + ), + ) + + new_svt = to_datatype(SampledValueType, svt) + + assert new_svt.value == svt.value + assert new_svt.context == svt.context + assert new_svt.measurand == svt.measurand + assert new_svt.phase == svt.phase + assert new_svt.location == svt.location + assert isinstance(new_svt.unit_of_measure, dict) + assert new_svt.unit_of_measure["unit"] == svt.unit_of_measure.unit + assert new_svt.unit_of_measure["multiplier"] == svt.unit_of_measure.multiplier + + +def test_set_monitoring_data_type(): + smdt = SetMonitoringDataType( + value=100.0, + type=MonitorEnumType.upper_threshold, + severity=1, + component=ComponentType(name="MainController", instance="instance1"), + variable=VariableType(name="Temperature", instance="instance1"), + id=123456, + ) + + new_smdt = to_datatype(SetMonitoringDataType, smdt) + + assert new_smdt.value == smdt.value + assert new_smdt.type == smdt.type + assert new_smdt.severity == smdt.severity + assert isinstance(new_smdt.component, dict) + assert new_smdt.component["name"] == smdt.component.name + assert new_smdt.component["instance"] == smdt.component.instance + assert isinstance(new_smdt.variable, dict) + assert new_smdt.variable["name"] == smdt.variable.name + assert new_smdt.variable["instance"] == smdt.variable.instance + assert new_smdt.id == smdt.id + + +def test_set_monitoring_result_type(): + smrt = SetMonitoringResultType( + status=SetMonitoringStatusEnumType.accepted, + id=123, + status_info=StatusInfoType( + reason_code=ReasonEnumType.other, + additional_info="Successfully set monitoring", + ), + type=MonitorEnumType.upper_threshold, + severity=1, + component=ComponentType(name="MainController", instance="instance1"), + variable=VariableType(name="Temperature", instance="instance1"), + ) + + new_smrt = to_datatype(SetMonitoringResultType, smrt) + + assert new_smrt.status == smrt.status + assert new_smrt.id == smrt.id + assert isinstance(new_smrt.status_info, dict) + assert new_smrt.status_info["reason_code"] == smrt.status_info.reason_code + assert new_smrt.status_info["additional_info"] == smrt.status_info.additional_info + assert new_smrt.type == smrt.type + assert new_smrt.severity == smrt.severity + assert isinstance(new_smrt.component, dict) + assert new_smrt.component["name"] == smrt.component.name + assert new_smrt.component["instance"] == smrt.component.instance + assert isinstance(new_smrt.variable, dict) + assert new_smrt.variable["name"] == smrt.variable.name + assert new_smrt.variable["instance"] == smrt.variable.instance + + +def test_set_variable_result_type(): + svrt = SetVariableResultType( + attribute_type=AttributeEnumType.actual, + attribute_status=SetVariableStatusEnumType.accepted, + component=ComponentType(name="MainController", instance="instance1"), + variable=VariableType(name="CurrentLimit", instance="instance1"), + attribute_status_info=StatusInfoType( + reason_code=ReasonEnumType.other, + additional_info="Successfully set variable", + ), + ) + + new_svrt = to_datatype(SetVariableResultType, svrt) + + assert new_svrt.attribute_type == svrt.attribute_type + assert new_svrt.attribute_status == svrt.attribute_status + assert isinstance(new_svrt.component, dict) + assert new_svrt.component["name"] == svrt.component.name + assert new_svrt.component["instance"] == svrt.component.instance + assert isinstance(new_svrt.variable, dict) + assert new_svrt.variable["name"] == svrt.variable.name + assert new_svrt.variable["instance"] == svrt.variable.instance + assert isinstance(new_svrt.attribute_status_info, dict) + assert ( + new_svrt.attribute_status_info["reason_code"] + == svrt.attribute_status_info.reason_code + ) + assert ( + new_svrt.attribute_status_info["additional_info"] + == svrt.attribute_status_info.additional_info + ) + + +def test_unit_of_measure_type(): + uomt = UnitOfMeasureType( + # unit=UnitOfMeasureType.w, + multiplier=1 + ) + + new_uomt = to_datatype(UnitOfMeasureType, uomt) + + assert new_uomt.unit == uomt.unit + assert new_uomt.multiplier == uomt.multiplier + + +def test_variable_attribute_type(): + vat = VariableAttributeType( + type=AttributeEnumType.actual, + value="25.5", + mutability=MutabilityEnumType.read_write, + persistent=True, + constant=False, + ) + + new_vat = to_datatype(VariableAttributeType, vat) + + assert new_vat.type == vat.type + assert new_vat.value == vat.value + assert new_vat.mutability == vat.mutability + assert new_vat.persistent == vat.persistent + assert new_vat.constant == vat.constant + + +def test_variable_characteristics_type(): + vct = VariableCharacteristicsType( + unit="Celsius", + data_type=DataEnumType.decimal, + min_limit="-20", + max_limit="50", + values_list=["10", "20", "30"], + supports_monitoring=True, + ) + + new_vct = to_datatype(VariableCharacteristicsType, vct) + + assert new_vct.unit == vct.unit + assert new_vct.data_type == vct.data_type + assert new_vct.min_limit == vct.min_limit + assert new_vct.max_limit == vct.max_limit + assert new_vct.values_list == vct.values_list + assert new_vct.supports_monitoring == vct.supports_monitoring + + +def test_variable_monitoring_type(): + vmt = VariableMonitoringType( + id=1, + transaction=True, + value=100.0, + type=MonitorEnumType.upper_threshold, + severity=1, + ) + + new_vmt = to_datatype(VariableMonitoringType, vmt) + + assert new_vmt.id == vmt.id + assert new_vmt.transaction == vmt.transaction + assert new_vmt.value == vmt.value + assert new_vmt.type == vmt.type + assert new_vmt.severity == vmt.severity diff --git a/tests/v201/test_v201_enums.py b/tests/v201/test_v201_enums.py index d717a11aa..ce26e6576 100644 --- a/tests/v201/test_v201_enums.py +++ b/tests/v201/test_v201_enums.py @@ -1,50 +1,50 @@ -from ocpp.v201.enums import ConnectorType, DataType, TxStartStopPointType +from ocpp.v201.enums import ConnectorEnumType, DataEnumType, TxStartStopPointEnumType def test_connector_type(): - assert ConnectorType.c_ccs1 == "cCCS1" - assert ConnectorType.c_ccs2 == "cCCS2" - assert ConnectorType.c_chao_ji == "cChaoJi" - assert ConnectorType.c_g105 == "cG105" - assert ConnectorType.c_gbt == "cGBT" - assert ConnectorType.c_tesla == "cTesla" - assert ConnectorType.c_type1 == "cType1" - assert ConnectorType.c_type2 == "cType2" - assert ConnectorType.s309_1p_16a == "s309-1P-16A" - assert ConnectorType.s309_1p_32a == "s309-1P-32A" - assert ConnectorType.s309_3p_16a == "s309-3P-16A" - assert ConnectorType.s309_3p_32a == "s309-3P-32A" - assert ConnectorType.s_bs1361 == "sBS1361" - assert ConnectorType.s_cee_7_7 == "sCEE-7-7" - assert ConnectorType.s_type2 == "sType2" - assert ConnectorType.s_type3 == "sType3" - assert ConnectorType.opp_charge == "OppCharge" - assert ConnectorType.other_1ph_max_16a == "Other1PhMax16A" - assert ConnectorType.other_1ph_over_16a == "Other1PhOver16A" - assert ConnectorType.other_3ph == "Other3Ph" - assert ConnectorType.pan == "Pan" - assert ConnectorType.w_inductive == "wInductive" - assert ConnectorType.w_resonant == "wResonant" - assert ConnectorType.undetermined == "Undetermined" - assert ConnectorType.unknown == "Unknown" + assert ConnectorEnumType.c_ccs1 == "cCCS1" + assert ConnectorEnumType.c_ccs2 == "cCCS2" + assert ConnectorEnumType.c_chao_ji == "cChaoJi" + assert ConnectorEnumType.c_g105 == "cG105" + assert ConnectorEnumType.c_gbt == "cGBT" + assert ConnectorEnumType.c_tesla == "cTesla" + assert ConnectorEnumType.c_type1 == "cType1" + assert ConnectorEnumType.c_type2 == "cType2" + assert ConnectorEnumType.s309_1p_16a == "s309-1P-16A" + assert ConnectorEnumType.s309_1p_32a == "s309-1P-32A" + assert ConnectorEnumType.s309_3p_16a == "s309-3P-16A" + assert ConnectorEnumType.s309_3p_32a == "s309-3P-32A" + assert ConnectorEnumType.s_bs1361 == "sBS1361" + assert ConnectorEnumType.s_cee_7_7 == "sCEE-7-7" + assert ConnectorEnumType.s_type2 == "sType2" + assert ConnectorEnumType.s_type3 == "sType3" + assert ConnectorEnumType.opp_charge == "OppCharge" + assert ConnectorEnumType.other_1ph_max_16a == "Other1PhMax16A" + assert ConnectorEnumType.other_1ph_over_16a == "Other1PhOver16A" + assert ConnectorEnumType.other_3ph == "Other3Ph" + assert ConnectorEnumType.pan == "Pan" + assert ConnectorEnumType.w_inductive == "wInductive" + assert ConnectorEnumType.w_resonant == "wResonant" + assert ConnectorEnumType.undetermined == "Undetermined" + assert ConnectorEnumType.unknown == "Unknown" def test_data_type(): - assert DataType.string == "string" - assert DataType.decimal == "decimal" - assert DataType.integer == "integer" - assert DataType.date_time == "dateTime" - assert DataType.boolean == "boolean" - assert DataType.option_list == "OptionList" - assert DataType.sequence_list == "SequenceList" - assert DataType.member_list == "MemberList" - assert DataType.password_string == "passwordString" + assert DataEnumType.string == "string" + assert DataEnumType.decimal == "decimal" + assert DataEnumType.integer == "integer" + assert DataEnumType.date_time == "dateTime" + assert DataEnumType.boolean == "boolean" + assert DataEnumType.option_list == "OptionList" + assert DataEnumType.sequence_list == "SequenceList" + assert DataEnumType.member_list == "MemberList" + assert DataEnumType.password_string == "passwordString" def test_tx_start_stop_point(): - assert TxStartStopPointType.authorized == "Authorized" - assert TxStartStopPointType.data_signed == "DataSigned" - assert TxStartStopPointType.energy_transfer == "EnergyTransfer" - assert TxStartStopPointType.ev_connected == "EVConnected" - assert TxStartStopPointType.parking_bay_occupancy == "ParkingBayOccupancy" - assert TxStartStopPointType.power_path_closed == "PowerPathClosed" + assert TxStartStopPointEnumType.authorized == "Authorized" + assert TxStartStopPointEnumType.data_signed == "DataSigned" + assert TxStartStopPointEnumType.energy_transfer == "EnergyTransfer" + assert TxStartStopPointEnumType.ev_connected == "EVConnected" + assert TxStartStopPointEnumType.parking_bay_occupancy == "ParkingBayOccupancy" + assert TxStartStopPointEnumType.power_path_closed == "PowerPathClosed"