From: Jérôme Benoit Date: Thu, 26 Mar 2026 20:35:50 +0000 (+0100) Subject: fix: use OCPP version-specific parameter keys for meter value measurands X-Git-Tag: ocpp-server@v4.0.0~54 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=572389955eab4697aaa7ec38c464094b82b3a707;p=e-mobility-charging-stations-simulator.git fix: use OCPP version-specific parameter keys for meter value measurands Remap keba-ocpp2 template configuration keys from OCPP 1.6 names to OCPP 2.0 variable names (MeterValuesSampledData → TxUpdatedMeasurands, MeterValueSampleInterval → TxUpdatedInterval, AuthorizeRemoteTxRequests → AuthorizeRemoteStart). Remove OCPP 1.6-only keys with no 2.0 equivalent. Use StandardParametersKey union to resolve the correct key at runtime based on OCPP version. --- diff --git a/src/assets/station-templates/keba-ocpp2.station-template.json b/src/assets/station-templates/keba-ocpp2.station-template.json index 0df78ecc..afa1d6fb 100644 --- a/src/assets/station-templates/keba-ocpp2.station-template.json +++ b/src/assets/station-templates/keba-ocpp2.station-template.json @@ -17,27 +17,17 @@ "Configuration": { "configurationKey": [ { - "key": "MeterValuesSampledData", + "key": "TxUpdatedMeasurands", "readonly": false, "value": "Energy.Active.Import.Register,Power.Active.Import,Current.Import,Voltage" }, { - "key": "MeterValueSampleInterval", + "key": "TxUpdatedInterval", "readonly": false, "value": "30" }, { - "key": "SupportedFeatureProfiles", - "readonly": true, - "value": "Core,FirmwareManagement,LocalAuthListManagement,SmartCharging,RemoteTrigger,Reservation" - }, - { - "key": "LocalAuthListEnabled", - "readonly": false, - "value": "false" - }, - { - "key": "AuthorizeRemoteTxRequests", + "key": "AuthorizeRemoteStart", "readonly": false, "value": "false" }, @@ -45,11 +35,6 @@ "key": "WebSocketPingInterval", "readonly": false, "value": "60" - }, - { - "key": "ReserveConnectorZeroSupported", - "readonly": false, - "value": "false" } ] }, diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index f502a879..b0ecd94c 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -2029,17 +2029,19 @@ const getSampledValueTemplate = ( ) return } + const isOCPP2 = + chargingStation.stationInfo?.ocppVersion === OCPPVersion.VERSION_20 || + chargingStation.stationInfo?.ocppVersion === OCPPVersion.VERSION_201 + const measurandsParameterKey = isOCPP2 + ? StandardParametersKey.TxUpdatedMeasurands + : StandardParametersKey.MeterValuesSampledData if ( measurand !== MeterValueMeasurand.ENERGY_ACTIVE_IMPORT_REGISTER && - getConfigurationKey( - chargingStation, - StandardParametersKey.MeterValuesSampledData - )?.value?.includes(measurand) === false + getConfigurationKey(chargingStation, measurandsParameterKey)?.value?.includes(measurand) === + false ) { logger.debug( - `${chargingStation.logPrefix()} Trying to get MeterValues measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId.toString()} not found in '${ - StandardParametersKey.MeterValuesSampledData - }' OCPP parameter` + `${chargingStation.logPrefix()} Trying to get MeterValues measurand '${measurand}' ${onPhaseStr}in template on connector id ${connectorId.toString()} not found in '${measurandsParameterKey}' OCPP parameter` ) return }