fix: fix charging profile handling at remote start transaction
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 3 Aug 2023 18:21:57 +0000 (20:21 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 3 Aug 2023 18:21:57 +0000 (20:21 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts

index dd40ffafd0d89c107fdd3bf3718d4a2615262896..61c74a600e30604542e53a12b1cf08498570b308 100644 (file)
@@ -950,11 +950,13 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
     ) {
       // Authorization successful, start transaction
       if (
-        this.setRemoteStartTransactionChargingProfile(
-          chargingStation,
-          transactionConnectorId,
-          chargingProfile!,
-        ) === true
+        (chargingProfile &&
+          this.setRemoteStartTransactionChargingProfile(
+            chargingStation,
+            transactionConnectorId,
+            chargingProfile,
+          ) === true) ??
+        !chargingProfile
       ) {
         connectorStatus.transactionRemoteStarted = true;
         if (
@@ -985,11 +987,14 @@ export class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
     }
     // No authorization check required, start transaction
     if (
-      this.setRemoteStartTransactionChargingProfile(
-        chargingStation,
-        transactionConnectorId,
-        chargingProfile!,
-      ) === true
+      (chargingProfile &&
+        this.setRemoteStartTransactionChargingProfile(
+          chargingStation,
+          transactionConnectorId,
+          chargingProfile,
+          // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
+        ) === true) ||
+      !chargingProfile
     ) {
       connectorStatus.transactionRemoteStarted = true;
       if (