From b2a0452d368cfc43bbacc4991de59afa64f662a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 13 Jan 2023 11:37:19 +0100 Subject: [PATCH] Allow to specify timestamp in OCPP commands payload with the UI Server MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ocpp/1.6/OCPP16RequestService.ts | 4 ++-- src/charging-station/ocpp/2.0/OCPP20RequestService.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index bf63ba2e..77b5cb58 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -202,7 +202,7 @@ export default class OCPP16RequestService extends OCPPRequestService { meterStart: chargingStation.getEnergyActiveImportRegisterByConnectorId( commandParams?.connectorId as number ), - timestamp: new Date(), + timestamp: commandParams?.timestamp ?? new Date(), } as unknown as Request; case OCPP16RequestCommand.STOP_TRANSACTION: connectorId = chargingStation.getConnectorIdByTransactionId( @@ -220,7 +220,7 @@ export default class OCPP16RequestService extends OCPPRequestService { commandParams?.idTag ?? chargingStation.getTransactionIdTag(commandParams?.transactionId as number), meterStop: commandParams?.meterStop ?? energyActiveImportRegister, - timestamp: new Date(), + timestamp: commandParams?.timestamp ?? new Date(), reason: commandParams?.reason, ...(chargingStation.getTransactionDataMeterValues() && { transactionData: OCPP16ServiceUtils.buildTransactionDataMeterValues( diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index 989ca41c..18816f0e 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -122,7 +122,7 @@ export default class OCPP20RequestService extends OCPPRequestService { return {} as unknown as Request; case OCPP20RequestCommand.STATUS_NOTIFICATION: return { - timestamp: commandParams?.timestamp, + timestamp: commandParams?.timestamp ?? new Date(), connectorStatus: commandParams?.connectorStatus, evseId: commandParams?.evseId, connectorId: commandParams?.connectorId, -- 2.34.1