]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor: add Enabled to OCPP20RequiredVariableName enum and fix LocalAuthListCtrlr...
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 26 Mar 2026 22:25:20 +0000 (23:25 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 26 Mar 2026 22:40:25 +0000 (23:40 +0100)
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.

src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts
src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts
src/types/ocpp/2.0/Variables.ts

index cc23745a0670b8d8209257b3b55137095d2f18dd..3e5f3899e99224ecec54eccdf06413ca245fc797 100644 (file)
@@ -121,16 +121,6 @@ export const VARIABLE_REGISTRY: Record<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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<string, VariableMetadata> = {
     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')]: {
index 98c0fd47b791dbeb89eb3552fc11223288ce34cd..744913c0ce1b3242b16a0be5037df0862ef046d3 100644 (file)
@@ -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
       }
index b25f1b9d2b5bd6c1484fca942460b6c3da116184..22e0b31313cd4e01b27d182d67bbb225deceea0d 100644 (file)
@@ -44,6 +44,7 @@ export enum OCPP20RequiredVariableName {
   CertificateEntries = 'CertificateEntries',
   ConfigurationValueSize = 'ConfigurationValueSize',
   DateTime = 'DateTime',
+  Enabled = 'Enabled',
   EVConnectionTimeOut = 'EVConnectionTimeOut',
   FileTransferProtocols = 'FileTransferProtocols',
   ItemsPerMessage = 'ItemsPerMessage',