From e0617e04295e3ebce8ef99af8f75f8ad4323bc24 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 26 Mar 2026 23:25:20 +0100 Subject: [PATCH] refactor: add Enabled to OCPP20RequiredVariableName enum and fix LocalAuthListCtrlr.Enabled mapping Replace all 'Enabled' string literals with OCPP20RequiredVariableName.Enabled in the variable registry and auth adapter. Move LocalAuthListEnabled default from AuthCtrlr to LocalAuthListCtrlr component per OCPP 2.0.1 spec. --- .../ocpp/2.0/OCPP20VariableRegistry.ts | 238 ++++++++++-------- .../ocpp/auth/adapters/OCPP20AuthAdapter.ts | 21 +- src/types/ocpp/2.0/Variables.ts | 1 + 3 files changed, 150 insertions(+), 110 deletions(-) diff --git a/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts b/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts index cc23745a..3e5f3899 100644 --- a/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts +++ b/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts @@ -121,16 +121,6 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'Available', }, - [buildRegistryKey(OCPP20ComponentName.AlignedDataCtrlr as string, 'Enabled')]: { - component: OCPP20ComponentName.AlignedDataCtrlr as string, - dataType: DataEnumType.boolean, - defaultValue: 'false', - description: 'If this variable reports a value of true, Clock-Aligned Data is enabled', - mutability: MutabilityEnumType.ReadWrite, - persistence: PersistenceEnumType.Persistent, - supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', - }, [buildRegistryKey(OCPP20ComponentName.AlignedDataCtrlr as string, 'Interval')]: { component: OCPP20ComponentName.AlignedDataCtrlr as string, dataType: DataEnumType.integer, @@ -249,6 +239,19 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: OCPP20RequiredVariableName.TxEndedMeasurands, }, + [buildRegistryKey( + OCPP20ComponentName.AlignedDataCtrlr as string, + OCPP20RequiredVariableName.Enabled as string + )]: { + component: OCPP20ComponentName.AlignedDataCtrlr as string, + dataType: DataEnumType.boolean, + defaultValue: 'false', + description: 'If this variable reports a value of true, Clock-Aligned Data is enabled', + mutability: MutabilityEnumType.ReadWrite, + persistence: PersistenceEnumType.Persistent, + supportedAttributes: [AttributeEnumType.Actual], + variable: OCPP20RequiredVariableName.Enabled as string, + }, // AuthCacheCtrlr Component [buildRegistryKey(OCPP20ComponentName.AuthCacheCtrlr as string, 'Available')]: { @@ -272,16 +275,6 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'DisablePostAuthorize', }, - [buildRegistryKey(OCPP20ComponentName.AuthCacheCtrlr as string, 'Enabled')]: { - component: OCPP20ComponentName.AuthCacheCtrlr as string, - dataType: DataEnumType.boolean, - defaultValue: 'false', - description: 'If set to true, Authorization caching is enabled.', - mutability: MutabilityEnumType.ReadWrite, - persistence: PersistenceEnumType.Persistent, - supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', - }, [buildRegistryKey(OCPP20ComponentName.AuthCacheCtrlr as string, 'LifeTime')]: { component: OCPP20ComponentName.AuthCacheCtrlr as string, dataType: DataEnumType.integer, @@ -322,6 +315,19 @@ export const VARIABLE_REGISTRY: Record = { unit: OCPP20UnitEnumType.BYTES, variable: 'Storage', }, + [buildRegistryKey( + OCPP20ComponentName.AuthCacheCtrlr as string, + OCPP20RequiredVariableName.Enabled as string + )]: { + component: OCPP20ComponentName.AuthCacheCtrlr as string, + dataType: DataEnumType.boolean, + defaultValue: 'false', + description: 'If set to true, Authorization caching is enabled.', + mutability: MutabilityEnumType.ReadWrite, + persistence: PersistenceEnumType.Persistent, + supportedAttributes: [AttributeEnumType.Actual], + variable: OCPP20RequiredVariableName.Enabled as string, + }, // AuthCtrlr Component [buildRegistryKey(OCPP20ComponentName.AuthCtrlr as string, 'AdditionalInfoItemsPerMessage')]: { @@ -349,17 +355,6 @@ export const VARIABLE_REGISTRY: Record = { variable: 'DisableRemoteAuthorization', }, - [buildRegistryKey(OCPP20ComponentName.AuthCtrlr as string, 'Enabled')]: { - component: OCPP20ComponentName.AuthCtrlr as string, - dataType: DataEnumType.boolean, - defaultValue: 'true', - description: - 'If set to false, no authorization is done before starting a transaction or when reading an idToken.', - mutability: MutabilityEnumType.ReadWrite, - persistence: PersistenceEnumType.Persistent, - supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', - }, [buildRegistryKey(OCPP20ComponentName.AuthCtrlr as string, 'MasterPassGroupId')]: { component: OCPP20ComponentName.AuthCtrlr as string, dataType: DataEnumType.string, @@ -395,6 +390,20 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: OCPP20RequiredVariableName.AuthorizeRemoteStart as string, }, + [buildRegistryKey( + OCPP20ComponentName.AuthCtrlr as string, + OCPP20RequiredVariableName.Enabled as string + )]: { + component: OCPP20ComponentName.AuthCtrlr as string, + dataType: DataEnumType.boolean, + defaultValue: 'true', + description: + 'If set to false, no authorization is done before starting a transaction or when reading an idToken.', + mutability: MutabilityEnumType.ReadWrite, + persistence: PersistenceEnumType.Persistent, + supportedAttributes: [AttributeEnumType.Actual], + variable: OCPP20RequiredVariableName.Enabled as string, + }, [buildRegistryKey( OCPP20ComponentName.AuthCtrlr as string, OCPP20RequiredVariableName.LocalAuthorizationOffline @@ -1175,17 +1184,6 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'DisablePostAuthorize', }, - [buildRegistryKey(OCPP20ComponentName.LocalAuthListCtrlr as string, 'Enabled')]: { - component: OCPP20ComponentName.LocalAuthListCtrlr as string, - dataType: DataEnumType.boolean, - defaultValue: 'false', - description: - 'If this variable exists and reports a value of true, Local Authorization List is enabled.', - mutability: MutabilityEnumType.ReadWrite, - persistence: PersistenceEnumType.Persistent, - supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', - }, [buildRegistryKey(OCPP20ComponentName.LocalAuthListCtrlr as string, 'Entries')]: { component: OCPP20ComponentName.LocalAuthListCtrlr as string, dataType: DataEnumType.integer, @@ -1226,6 +1224,20 @@ export const VARIABLE_REGISTRY: Record = { unit: OCPP20UnitEnumType.BYTES, variable: 'Storage', }, + [buildRegistryKey( + OCPP20ComponentName.LocalAuthListCtrlr as string, + OCPP20RequiredVariableName.Enabled as string + )]: { + component: OCPP20ComponentName.LocalAuthListCtrlr as string, + dataType: DataEnumType.boolean, + defaultValue: 'false', + description: + 'If this variable exists and reports a value of true, Local Authorization List is enabled.', + mutability: MutabilityEnumType.ReadWrite, + persistence: PersistenceEnumType.Persistent, + supportedAttributes: [AttributeEnumType.Actual], + variable: OCPP20RequiredVariableName.Enabled as string, + }, // MonitoringCtrlr Component [buildRegistryKey(OCPP20ComponentName.MonitoringCtrlr as string, 'ActiveMonitoringBase')]: { @@ -1296,16 +1308,6 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: OCPP20RequiredVariableName.BytesPerMessage, }, - [buildRegistryKey(OCPP20ComponentName.MonitoringCtrlr as string, 'Enabled')]: { - component: OCPP20ComponentName.MonitoringCtrlr as string, - dataType: DataEnumType.boolean, - defaultValue: 'true', - description: 'Whether monitoring is enabled.', - mutability: MutabilityEnumType.ReadWrite, - persistence: PersistenceEnumType.Persistent, - supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', - }, [buildRegistryKey( OCPP20ComponentName.MonitoringCtrlr as string, 'ItemsPerMessage', @@ -1376,6 +1378,19 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'OfflineQueuingSeverity', }, + [buildRegistryKey( + OCPP20ComponentName.MonitoringCtrlr as string, + OCPP20RequiredVariableName.Enabled as string + )]: { + component: OCPP20ComponentName.MonitoringCtrlr as string, + dataType: DataEnumType.boolean, + defaultValue: 'true', + description: 'Whether monitoring is enabled.', + mutability: MutabilityEnumType.ReadWrite, + persistence: PersistenceEnumType.Persistent, + supportedAttributes: [AttributeEnumType.Actual], + variable: OCPP20RequiredVariableName.Enabled as string, + }, // OCPPCommCtrlr Component [buildRegistryKey(OCPP20ComponentName.OCPPCommCtrlr as string, 'ActiveNetworkProfile')]: { @@ -1651,26 +1666,29 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'Available', }, - [buildRegistryKey(OCPP20ComponentName.ReservationCtrlr as string, 'Enabled')]: { + [buildRegistryKey(OCPP20ComponentName.ReservationCtrlr as string, 'NonEvseSpecific')]: { component: OCPP20ComponentName.ReservationCtrlr as string, dataType: DataEnumType.boolean, defaultValue: 'false', - description: 'Whether reservation is enabled.', - mutability: MutabilityEnumType.ReadWrite, + description: + 'If this configuration variable is present and set to true: Charging Station supports Reservation where EVSE id is not specified.', + mutability: MutabilityEnumType.ReadOnly, persistence: PersistenceEnumType.Persistent, supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', + variable: 'NonEvseSpecific', }, - [buildRegistryKey(OCPP20ComponentName.ReservationCtrlr as string, 'NonEvseSpecific')]: { + [buildRegistryKey( + OCPP20ComponentName.ReservationCtrlr as string, + OCPP20RequiredVariableName.Enabled as string + )]: { component: OCPP20ComponentName.ReservationCtrlr as string, dataType: DataEnumType.boolean, defaultValue: 'false', - description: - 'If this configuration variable is present and set to true: Charging Station supports Reservation where EVSE id is not specified.', - mutability: MutabilityEnumType.ReadOnly, + description: 'Whether reservation is enabled.', + mutability: MutabilityEnumType.ReadWrite, persistence: PersistenceEnumType.Persistent, supportedAttributes: [AttributeEnumType.Actual], - variable: 'NonEvseSpecific', + variable: OCPP20RequiredVariableName.Enabled as string, }, // SampledDataCtrlr Component @@ -1684,16 +1702,6 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'Available', }, - [buildRegistryKey(OCPP20ComponentName.SampledDataCtrlr as string, 'Enabled')]: { - component: OCPP20ComponentName.SampledDataCtrlr as string, - dataType: DataEnumType.boolean, - defaultValue: 'true', - description: 'If this variable reports a value of true, Sampled Data is enabled.', - mutability: MutabilityEnumType.ReadWrite, - persistence: PersistenceEnumType.Persistent, - supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', - }, [buildRegistryKey(OCPP20ComponentName.SampledDataCtrlr as string, 'RegisterValuesWithoutPhases')]: { component: OCPP20ComponentName.SampledDataCtrlr as string, @@ -1791,6 +1799,19 @@ export const VARIABLE_REGISTRY: Record = { variable: OCPP20MeasurandEnumType.VOLTAGE, vendorSpecific: true, }, + [buildRegistryKey( + OCPP20ComponentName.SampledDataCtrlr as string, + OCPP20RequiredVariableName.Enabled as string + )]: { + component: OCPP20ComponentName.SampledDataCtrlr as string, + dataType: DataEnumType.boolean, + defaultValue: 'true', + description: 'If this variable reports a value of true, Sampled Data is enabled.', + mutability: MutabilityEnumType.ReadWrite, + persistence: PersistenceEnumType.Persistent, + supportedAttributes: [AttributeEnumType.Actual], + variable: OCPP20RequiredVariableName.Enabled as string, + }, [buildRegistryKey( OCPP20ComponentName.SampledDataCtrlr as string, OCPP20RequiredVariableName.TxEndedMeasurands @@ -2061,16 +2082,6 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'Available', }, - [buildRegistryKey(OCPP20ComponentName.SmartChargingCtrlr as string, 'Enabled')]: { - component: OCPP20ComponentName.SmartChargingCtrlr as string, - dataType: DataEnumType.boolean, - defaultValue: 'true', - description: 'Whether smart charging is enabled.', - mutability: MutabilityEnumType.ReadWrite, - persistence: PersistenceEnumType.Persistent, - supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', - }, [buildRegistryKey( OCPP20ComponentName.SmartChargingCtrlr as string, 'Entries', @@ -2180,6 +2191,19 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'RateUnit', }, + [buildRegistryKey( + OCPP20ComponentName.SmartChargingCtrlr as string, + OCPP20RequiredVariableName.Enabled as string + )]: { + component: OCPP20ComponentName.SmartChargingCtrlr as string, + dataType: DataEnumType.boolean, + defaultValue: 'true', + description: 'Whether smart charging is enabled.', + mutability: MutabilityEnumType.ReadWrite, + persistence: PersistenceEnumType.Persistent, + supportedAttributes: [AttributeEnumType.Actual], + variable: OCPP20RequiredVariableName.Enabled as string, + }, // TariffCostCtrlr Component [buildRegistryKey(OCPP20ComponentName.TariffCostCtrlr as string, 'Available', 'Cost')]: { @@ -2216,28 +2240,6 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'Currency', }, - [buildRegistryKey(OCPP20ComponentName.TariffCostCtrlr as string, 'Enabled', 'Cost')]: { - component: OCPP20ComponentName.TariffCostCtrlr as string, - dataType: DataEnumType.boolean, - defaultValue: 'false', - description: 'Instance Cost: Whether costs are enabled.', - instance: 'Cost', - mutability: MutabilityEnumType.ReadWrite, - persistence: PersistenceEnumType.Persistent, - supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', - }, - [buildRegistryKey(OCPP20ComponentName.TariffCostCtrlr as string, 'Enabled', 'Tariff')]: { - component: OCPP20ComponentName.TariffCostCtrlr as string, - dataType: DataEnumType.boolean, - defaultValue: 'false', - description: 'Instance Tariff: Whether tariffs are enabled.', - instance: 'Tariff', - mutability: MutabilityEnumType.ReadWrite, - persistence: PersistenceEnumType.Persistent, - supportedAttributes: [AttributeEnumType.Actual], - variable: 'Enabled', - }, [buildRegistryKey(OCPP20ComponentName.TariffCostCtrlr as string, 'TariffFallbackMessage')]: { component: OCPP20ComponentName.TariffCostCtrlr as string, dataType: DataEnumType.string, @@ -2264,6 +2266,36 @@ export const VARIABLE_REGISTRY: Record = { supportedAttributes: [AttributeEnumType.Actual], variable: 'TotalCostFallbackMessage', }, + [buildRegistryKey( + OCPP20ComponentName.TariffCostCtrlr as string, + OCPP20RequiredVariableName.Enabled as string, + 'Cost' + )]: { + component: OCPP20ComponentName.TariffCostCtrlr as string, + dataType: DataEnumType.boolean, + defaultValue: 'false', + description: 'Instance Cost: Whether costs are enabled.', + instance: 'Cost', + mutability: MutabilityEnumType.ReadWrite, + persistence: PersistenceEnumType.Persistent, + supportedAttributes: [AttributeEnumType.Actual], + variable: OCPP20RequiredVariableName.Enabled as string, + }, + [buildRegistryKey( + OCPP20ComponentName.TariffCostCtrlr as string, + OCPP20RequiredVariableName.Enabled as string, + 'Tariff' + )]: { + component: OCPP20ComponentName.TariffCostCtrlr as string, + dataType: DataEnumType.boolean, + defaultValue: 'false', + description: 'Instance Tariff: Whether tariffs are enabled.', + instance: 'Tariff', + mutability: MutabilityEnumType.ReadWrite, + persistence: PersistenceEnumType.Persistent, + supportedAttributes: [AttributeEnumType.Actual], + variable: OCPP20RequiredVariableName.Enabled as string, + }, // TxCtrlr Component [buildRegistryKey(OCPP20ComponentName.TxCtrlr as string, 'ChargingTime')]: { diff --git a/src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts b/src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts index 98c0fd47..744913c0 100644 --- a/src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts +++ b/src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts @@ -500,16 +500,23 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter { // Default values from OCPP 2.0.1 specification and variable registry if (component === (OCPP20ComponentName.AuthCtrlr as string)) { switch (variable) { - case 'Enabled': - return 'true' // Default: authorization is enabled - case 'LocalAuthListEnabled': - return 'true' // Default: enable local auth list case OCPP20RequiredVariableName.AuthorizeRemoteStart as string: - return 'true' // OCPP 2.0.1 default: remote start requires authorization + return 'true' + case OCPP20RequiredVariableName.Enabled as string: + return 'true' case OCPP20RequiredVariableName.LocalAuthorizationOffline as string: - return 'true' // OCPP 2.0.1 default: allow offline authorization + return 'true' case OCPP20RequiredVariableName.LocalPreAuthorization as string: - return 'false' // OCPP 2.0.1 default: wait for CSMS authorization + return 'false' + default: + return undefined + } + } + + if (component === (OCPP20ComponentName.LocalAuthListCtrlr as string)) { + switch (variable) { + case OCPP20RequiredVariableName.Enabled as string: + return 'true' default: return undefined } diff --git a/src/types/ocpp/2.0/Variables.ts b/src/types/ocpp/2.0/Variables.ts index b25f1b9d..22e0b313 100644 --- a/src/types/ocpp/2.0/Variables.ts +++ b/src/types/ocpp/2.0/Variables.ts @@ -44,6 +44,7 @@ export enum OCPP20RequiredVariableName { CertificateEntries = 'CertificateEntries', ConfigurationValueSize = 'ConfigurationValueSize', DateTime = 'DateTime', + Enabled = 'Enabled', EVConnectionTimeOut = 'EVConnectionTimeOut', FileTransferProtocols = 'FileTransferProtocols', ItemsPerMessage = 'ItemsPerMessage', -- 2.43.0