fix: only reset defined ATG connector status
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 30 Nov 2023 11:20:59 +0000 (12:20 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 30 Nov 2023 11:20:59 +0000 (12:20 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/AutomaticTransactionGenerator.ts

index efc3769ac45b273c65cefbc2f5beea549dc3224d..d76766cc68f5d3e35187a22d265e88ccd5b8e6a9 100644 (file)
@@ -398,16 +398,19 @@ export class AutomaticTransactionGenerator extends AsyncResource {
   }
 
   private resetConnectorStatus(connectorStatus: Status | undefined): void {
+    if (connectorStatus === undefined) {
+      return;
+    }
     delete connectorStatus?.startDate;
     delete connectorStatus?.lastRunDate;
     delete connectorStatus?.stopDate;
     delete connectorStatus?.stoppedDate;
     if (
       !this.started &&
-      (connectorStatus?.start === true ||
+      (connectorStatus.start === true ||
         this.chargingStation.getAutomaticTransactionGeneratorConfiguration().enable === false)
     ) {
-      connectorStatus!.start = false;
+      connectorStatus.start = false;
     }
   }