refactor: use helper to check charging station at WS opening
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 4 Aug 2023 17:51:24 +0000 (19:51 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 4 Aug 2023 17:51:24 +0000 (19:51 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 5a049ec5b9195b071f4920f117a6ea4e4ca59a02..f92ea2b6e96863c01ecca86ecaa91891592073be 100644 (file)
@@ -28,6 +28,7 @@ import {
 } from './ConfigurationKeyUtils';
 import {
   buildConnectorsMap,
+  checkChargingStation,
   checkConnectorsConfiguration,
   checkStationInfoConnectorStatus,
   checkTemplate,
@@ -776,15 +777,11 @@ export class ChargingStation {
   ): void {
     options = {
       handshakeTimeout: secondsToMilliseconds(this.getConnectionTimeout()),
-      ...(this.stationInfo?.wsOptions ?? {}),
+      ...this.stationInfo?.wsOptions,
       ...options,
     };
     params = { ...{ closeOpened: false, terminateOpened: false }, ...params };
-    if (this.started === false && this.starting === false) {
-      logger.warn(
-        `${this.logPrefix()} Cannot open OCPP connection to URL ${this.wsConnectionUrl.toString()}
-          on stopped charging station`,
-      );
+    if (!checkChargingStation(this, this.logPrefix())) {
       return;
     }
     if (