]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix: align OCPP 2.0 variable names to spec (LocalPreAuthorization, LocalAuthorization...
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 26 Mar 2026 22:09:05 +0000 (23:09 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 26 Mar 2026 22:09:05 +0000 (23:09 +0100)
Rename LocalPreAuthorize → LocalPreAuthorization and
LocalAuthorizeOffline → LocalAuthorizationOffline to match the OCPP
2.0.1 appendix. Add key resolution mapping for both. Replace string
literals with enum references in OCPP20AuthAdapter.

src/assets/station-templates/keba-ocpp2.station-template.json
src/charging-station/ConfigurationKeyUtils.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts
src/charging-station/ocpp/auth/adapters/OCPP20AuthAdapter.ts
src/types/ocpp/2.0/Variables.ts

index ecdbb1d71a6626f1c600e8d6e701a16b0d3d38a5..dabea003ad75ff3ed6f51297f21b56ffa1bda2a9 100644 (file)
@@ -32,7 +32,7 @@
         "value": "false"
       },
       {
-        "key": "LocalPreAuthorize",
+        "key": "LocalPreAuthorization",
         "readonly": false,
         "value": "false"
       },
index 2c97bbaa5c452d5bf23fc919aca38aed5ba534ff..90cb3cc8b5f30f9fe01e1547a459cffb401a3eeb 100644 (file)
@@ -11,6 +11,8 @@ import { logger } from '../utils/index.js'
 const OCPP2_PARAMETER_KEY_MAP: Partial<Record<ConfigurationKeyType, ConfigurationKeyType>> = {
   [StandardParametersKey.AuthorizeRemoteTxRequests]: StandardParametersKey.AuthorizeRemoteStart,
   [StandardParametersKey.ConnectionTimeOut]: StandardParametersKey.EVConnectionTimeOut,
+  [StandardParametersKey.LocalAuthorizeOffline]: StandardParametersKey.LocalAuthorizationOffline,
+  [StandardParametersKey.LocalPreAuthorize]: StandardParametersKey.LocalPreAuthorization,
   [StandardParametersKey.MeterValueSampleInterval]: StandardParametersKey.TxUpdatedInterval,
   [StandardParametersKey.MeterValuesSampledData]: StandardParametersKey.TxUpdatedMeasurands,
 }
index 417f6aa8262f7af582625475d33b2da59c9fdab8..bc7e9328e729e6d2b512aa852d9ef35ef72b7b25 100644 (file)
@@ -2930,7 +2930,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService {
      * OCPP 2.0 Authorization Logic Implementation
      *
      * OCPP 2.0 handles authorization differently from 1.6:
-     * 1. Check if authorization is required (LocalAuthorizeOffline, AuthorizeRemoteStart variables)
+     * 1. Check if authorization is required (LocalAuthorizationOffline, AuthorizeRemoteStart variables)
      * 2. Local authorization list validation if enabled
      * 3. For OCPP 2.0, there's no explicit AuthorizeRequest - authorization is validated
      *    through configuration variables and local auth lists
index 469944c6e1a37a9612e627e86d7f5c82965f4bb7..cc23745a0670b8d8209257b3b55137095d2f18dd 100644 (file)
@@ -397,7 +397,7 @@ export const VARIABLE_REGISTRY: Record<string, VariableMetadata> = {
   },
   [buildRegistryKey(
     OCPP20ComponentName.AuthCtrlr as string,
-    OCPP20RequiredVariableName.LocalAuthorizeOffline
+    OCPP20RequiredVariableName.LocalAuthorizationOffline
   )]: {
     component: OCPP20ComponentName.AuthCtrlr as string,
     dataType: DataEnumType.boolean,
@@ -407,11 +407,11 @@ export const VARIABLE_REGISTRY: Record<string, VariableMetadata> = {
     persistence: PersistenceEnumType.Persistent,
     required: true,
     supportedAttributes: [AttributeEnumType.Actual],
-    variable: OCPP20RequiredVariableName.LocalAuthorizeOffline as string,
+    variable: OCPP20RequiredVariableName.LocalAuthorizationOffline as string,
   },
   [buildRegistryKey(
     OCPP20ComponentName.AuthCtrlr as string,
-    OCPP20RequiredVariableName.LocalPreAuthorize
+    OCPP20RequiredVariableName.LocalPreAuthorization
   )]: {
     component: OCPP20ComponentName.AuthCtrlr as string,
     dataType: DataEnumType.boolean,
@@ -421,7 +421,7 @@ export const VARIABLE_REGISTRY: Record<string, VariableMetadata> = {
     persistence: PersistenceEnumType.Persistent,
     required: true,
     supportedAttributes: [AttributeEnumType.Actual],
-    variable: OCPP20RequiredVariableName.LocalPreAuthorize as string,
+    variable: OCPP20RequiredVariableName.LocalPreAuthorization as string,
   },
 
   // CHAdeMOCtrlr Component
index 21ed9af829b9a6b75b3ea05c7976a7697d5110de..98c0fd47b791dbeb89eb3552fc11223288ce34cd 100644 (file)
@@ -16,9 +16,11 @@ import type {
 import { OCPP20VariableManager } from '../../2.0/OCPP20VariableManager.js'
 import {
   GetVariableStatusEnumType,
+  OCPP20ComponentName,
   OCPP20IdTokenEnumType,
   type OCPP20IdTokenType,
   OCPP20RequestCommand,
+  OCPP20RequiredVariableName,
   OCPPVersion,
 } from '../../../../types/index.js'
 import { logger, truncateId } from '../../../../utils/index.js'
@@ -394,7 +396,10 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter {
       const isOnline = this.chargingStation.inAcceptedState()
 
       // Check AuthorizeRemoteStart variable (with type validation)
-      const remoteStartValue = this.getVariableValue('AuthCtrlr', 'AuthorizeRemoteStart')
+      const remoteStartValue = this.getVariableValue(
+        OCPP20ComponentName.AuthCtrlr,
+        OCPP20RequiredVariableName.AuthorizeRemoteStart
+      )
       const remoteStartEnabled = this.parseBooleanVariable(remoteStartValue, true)
 
       return isOnline && remoteStartEnabled
@@ -478,8 +483,8 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter {
 
   /**
    * Get default variable value based on OCPP 2.0.1 specification
-   * @param component - OCPP component name (e.g., 'AuthCtrlr')
-   * @param variable - OCPP variable name (e.g., 'AuthorizeRemoteStart')
+   * @param component - OCPP component name (e.g., OCPP20ComponentName.AuthCtrlr)
+   * @param variable - OCPP variable name (e.g., OCPP20RequiredVariableName.AuthorizeRemoteStart)
    * @param useFallback - Whether to return fallback values when variable is not configured
    * @returns Default value according to OCPP 2.0.1 spec, or undefined if no default exists
    */
@@ -493,17 +498,17 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter {
     }
 
     // Default values from OCPP 2.0.1 specification and variable registry
-    if (component === 'AuthCtrlr') {
+    if (component === (OCPP20ComponentName.AuthCtrlr as string)) {
       switch (variable) {
-        case 'AuthorizeRemoteStart':
-          return 'true' // OCPP 2.0.1 default: remote start requires authorization
         case 'Enabled':
           return 'true' // Default: authorization is enabled
         case 'LocalAuthListEnabled':
           return 'true' // Default: enable local auth list
-        case 'LocalAuthorizeOffline':
+        case OCPP20RequiredVariableName.AuthorizeRemoteStart as string:
+          return 'true' // OCPP 2.0.1 default: remote start requires authorization
+        case OCPP20RequiredVariableName.LocalAuthorizationOffline as string:
           return 'true' // OCPP 2.0.1 default: allow offline authorization
-        case 'LocalPreAuthorize':
+        case OCPP20RequiredVariableName.LocalPreAuthorization as string:
           return 'false' // OCPP 2.0.1 default: wait for CSMS authorization
         default:
           return undefined
@@ -519,7 +524,10 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter {
    */
   private getOfflineAuthorizationConfig (): boolean {
     try {
-      const value = this.getVariableValue('AuthCtrlr', 'LocalAuthorizeOffline')
+      const value = this.getVariableValue(
+        OCPP20ComponentName.AuthCtrlr,
+        OCPP20RequiredVariableName.LocalAuthorizationOffline
+      )
       return this.parseBooleanVariable(value, true)
     } catch (error) {
       logger.warn(
@@ -532,8 +540,8 @@ export class OCPP20AuthAdapter implements OCPPAuthAdapter {
 
   /**
    * Get variable value from OCPP 2.0 variable system
-   * @param component - OCPP component name (e.g., 'AuthCtrlr')
-   * @param variable - OCPP variable name (e.g., 'AuthorizeRemoteStart')
+   * @param component - OCPP component name (e.g., OCPP20ComponentName.AuthCtrlr)
+   * @param variable - OCPP variable name (e.g., OCPP20RequiredVariableName.AuthorizeRemoteStart)
    * @param useDefaultFallback - If true, use OCPP 2.0.1 spec default values when variable is not found
    * @returns Promise resolving to variable value as string, or undefined if not available
    */
index 619ea2daf83091ebffe8783bc368eab78b2ed001..b25f1b9d2b5bd6c1484fca942460b6c3da116184 100644 (file)
@@ -47,8 +47,8 @@ export enum OCPP20RequiredVariableName {
   EVConnectionTimeOut = 'EVConnectionTimeOut',
   FileTransferProtocols = 'FileTransferProtocols',
   ItemsPerMessage = 'ItemsPerMessage',
-  LocalAuthorizeOffline = 'LocalAuthorizeOffline',
-  LocalPreAuthorize = 'LocalPreAuthorize',
+  LocalAuthorizationOffline = 'LocalAuthorizationOffline',
+  LocalPreAuthorization = 'LocalPreAuthorization',
   MessageAttemptInterval = 'MessageAttemptInterval',
   MessageAttempts = 'MessageAttempts',
   MessageTimeout = 'MessageTimeout',