fix: stop the ATG on connector if its status is unavailable
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 21 Mar 2023 21:26:41 +0000 (22:26 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 21 Mar 2023 21:26:41 +0000 (22:26 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/AutomaticTransactionGenerator.ts

index 4185215aae0d25ceccf9618bb289712d46d96ed2..3fef7d878b4a3fd6122712908a60f6e7cbd92595 100644 (file)
@@ -11,6 +11,7 @@ import {
   type AuthorizeRequest,
   type AuthorizeResponse,
   type AutomaticTransactionGeneratorConfiguration,
+  ConnectorStatusEnum,
   IdTagDistribution,
   RequestCommand,
   type StartTransactionRequest,
@@ -184,6 +185,18 @@ export class AutomaticTransactionGenerator extends AsyncResource {
         this.stopConnector(connectorId);
         break;
       }
+      if (
+        this.chargingStation.getConnectorStatus(connectorId)?.status ===
+        ConnectorStatusEnum.Unavailable
+      ) {
+        logger.info(
+          `${this.logPrefix(
+            connectorId
+          )} entered in transaction loop while the connector ${connectorId} status is unavailable`
+        );
+        this.stopConnector(connectorId);
+        break;
+      }
       if (!this.chargingStation?.ocppRequestService) {
         logger.info(
           `${this.logPrefix(