- if (this.chargingStation.getConnector(connectorId)?.transactionStarted) {
- transactionId = this.chargingStation.getConnector(connectorId).transactionId;
- stopResponse = await this.chargingStation.ocppRequestService.sendStopTransaction(transactionId,
- this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
- this.chargingStation.getTransactionIdTag(transactionId),
- reason);
+ if (this.chargingStation.getConnectorStatus(connectorId)?.transactionStarted) {
+ transactionId = this.chargingStation.getConnectorStatus(connectorId).transactionId;
+ if (
+ this.chargingStation.getBeginEndMeterValues() &&
+ this.chargingStation.getOcppStrictCompliance() &&
+ !this.chargingStation.getOutOfOrderEndMeterValues()
+ ) {
+ // FIXME: Implement OCPP version agnostic helpers
+ const transactionEndMeterValue = OCPP16ServiceUtils.buildTransactionEndMeterValue(
+ this.chargingStation,
+ connectorId,
+ this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId)
+ );
+ await this.chargingStation.ocppRequestService.sendMessageHandler<MeterValuesResponse>(
+ RequestCommand.METER_VALUES,
+ {
+ connectorId,
+ transactionId,
+ meterValue: transactionEndMeterValue,
+ }
+ );
+ }
+ stopResponse =
+ await this.chargingStation.ocppRequestService.sendMessageHandler<StopTransactionResponse>(
+ RequestCommand.STOP_TRANSACTION,
+ {
+ transactionId,
+ meterStop:
+ this.chargingStation.getEnergyActiveImportRegisterByTransactionId(transactionId),
+ idTag: this.chargingStation.getTransactionIdTag(transactionId),
+ reason,
+ }
+ );
+ this.connectorsStatus.get(connectorId).stopTransactionRequests++;