Allow to specify timestamp in OCPP commands payload with the UI Server
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 13 Jan 2023 10:37:19 +0000 (11:37 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 13 Jan 2023 10:37:19 +0000 (11:37 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/2.0/OCPP20RequestService.ts

index bf63ba2e6b84e764bc27728524171caec64220f2..77b5cb586d90ed9752ef911c1b9aa25ba53502cd 100644 (file)
@@ -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(
index 989ca41cd10d41410310b0af4ca7c8ed34572de3..18816f0ede247d613e4ce18079f5c1ffe0ee6394 100644 (file)
@@ -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,