message: Do not override Transaction ID in Meter Value from Connector if it's empty
diff: @@ -116,7 +116,7 @@ export default class OCPPValidation extends SchemaValidator {
  // Set to 1 (KEBA has only one connector)
  meterValues.connectorId = 1;
  }
  - // Check if the transaction ID matches
  + // Check if the transaction ID matches with the one on the Connector
  const foundConnector = Utils.getConnectorFromID(chargingStation, meterValues.connectorId);
  if (!foundConnector) {
  await Logging.logWarning({
  @@ -124,42 +124,24 @@ export default class OCPPValidation extends SchemaValidator {
  tenantID: tenantID,
  module: MODULE_NAME, method: 'validateMeterValues',
  action: ServerAction.OCPP_METER_VALUES,
  - message: `Connector ID '${meterValues.connectorId}' not found in charging station for transaction '${meterValues.transactionId}'`
  + message: `Connector ID '${meterValues.connectorId}' not found for Transaction ID '${meterValues.transactionId}'`
  });
  }
  - const connectorTransactionID = Utils.convertToInt(foundConnector ? foundConnector.currentTransactionID : 0);
  - // Transaction is provided in MeterValue?
  - if (Utils.objectHasProperty(meterValues, 'transactionId')) {
  - // Always integer
  + // Transaction ID is provided on Connector
  + if (foundConnector.currentTransactionID > 0) {
  + // Check if provided in Meter Values
  meterValues.transactionId = Utils.convertToInt(meterValues.transactionId);
  - // Yes: Check Transaction ID (ABB)
  - if (meterValues.transactionId !== connectorTransactionID) {
  - // Check if valid
  - if (connectorTransactionID > 0) {
  - // No: Log that the transaction ID will be reused
  + if (meterValues.transactionId === 0 && foundConnector.currentTransactionID > 0) {
  + // Reuse Transaction ID from Connector
  + meterValues.transactionId = foundConnector.currentTransactionID;
  await Logging.logWarning({
  ...LoggingHelper.getChargingStationProperties(chargingStation),
  tenantID: tenantID,
  module: MODULE_NAME, method: 'validateMeterValues',
  action: ServerAction.OCPP_METER_VALUES,
  - message: `Transaction ID '${meterValues.transactionId}' not found but retrieved from StartTransaction '${connectorTransactionID}'`
  + message: `Transaction ID '${meterValues.transactionId}' not found in Meter Values but retrieved from Connector '${foundConnector.currentTransactionID}'`
  });
  }
  - // Always assign, even if equals to 0
  - meterValues.transactionId = connectorTransactionID;
  - }
  - // Transaction is not provided: check if there is a transaction assigned on the connector
  - } else if (connectorTransactionID > 0) {
  - // Yes: Use Connector's Transaction ID
  - await Logging.logWarning({
  - ...LoggingHelper.getChargingStationProperties(chargingStation),
  - tenantID: tenantID,
  - module: MODULE_NAME, method: 'validateMeterValues',
  - action: ServerAction.OCPP_METER_VALUES,
  - message: `Transaction ID is not provided but retrieved from StartTransaction '${connectorTransactionID}'`
  - });
  - // Override it
  - meterValues.transactionId = connectorTransactionID;
  }
  }
  