fix: fix gap in schedule periods in composeChargingSchedules()
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16RequestService.ts
index ac1c1ac30d8810ac85e00de9b94b438e4e9876a0..5c1c129f6b671a96d22207f8aa4c6620a88ab7d1 100644 (file)
@@ -12,6 +12,7 @@ import {
   type JsonType,
   type OCPP16AuthorizeRequest,
   type OCPP16BootNotificationRequest,
+  OCPP16ChargePointStatus,
   type OCPP16DataTransferRequest,
   type OCPP16DiagnosticsStatusNotificationRequest,
   type OCPP16FirmwareStatusNotificationRequest,
@@ -183,6 +184,18 @@ export class OCPP16RequestService extends OCPPRequestService {
             true,
           ),
           timestamp: new Date(),
+          ...(OCPP16ServiceUtils.hasReservation(
+            chargingStation,
+            commandParams?.connectorId as number,
+            commandParams?.idTag as string,
+          ) && {
+            reservationId: chargingStation.getReservationBy(
+              'connectorId',
+              chargingStation.getConnectorStatus(0)?.status === OCPP16ChargePointStatus.Reserved
+                ? 0
+                : (commandParams?.connectorId as number),
+            )!.reservationId,
+          }),
           ...commandParams,
         } as unknown as Request;
       case OCPP16RequestCommand.STOP_TRANSACTION: