Create connectors also if undefined
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 29 Sep 2021 04:42:24 +0000 (06:42 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 29 Sep 2021 04:42:24 +0000 (06:42 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/charging-station/ChargingStation.ts

index 48d94ca000c9a6df8dae1ea9b844de00ff5e36cf..cf7a19ef731e2bb1d85ccfb41845d1790241ea4f 100644 (file)
@@ -315,13 +315,13 @@ export default class ChargingStation {
     this.startAuthorizationFileMonitoring();
     // Monitor station template file
     this.startStationTemplateFileMonitoring();
-    // Handle WebSocket incoming messages
+    // Handle WebSocket message
     this.wsConnection.on('message', this.onMessage.bind(this));
     // Handle WebSocket error
     this.wsConnection.on('error', this.onError.bind(this));
     // Handle WebSocket close
     this.wsConnection.on('close', this.onClose.bind(this));
-    // Handle WebSocket opening connection
+    // Handle WebSocket open
     this.wsConnection.on('open', this.onOpen.bind(this));
     // Handle WebSocket ping
     this.wsConnection.on('ping', this.onPing.bind(this));
@@ -509,7 +509,7 @@ export default class ChargingStation {
     }
     const connectorsConfigHash = crypto.createHash('sha256').update(JSON.stringify(this.stationInfo.Connectors) + maxConnectors.toString()).digest('hex');
     const connectorsConfigChanged = !Utils.isEmptyObject(this.connectors) && this.connectorsConfigurationHash !== connectorsConfigHash;
-    if (Utils.isEmptyObject(this.connectors) || connectorsConfigChanged) {
+    if (!this.connectors || Utils.isEmptyObject(this.connectors) || connectorsConfigChanged) {
       connectorsConfigChanged && (this.connectors = {} as Connectors);
       this.connectorsConfigurationHash = connectorsConfigHash;
       // Add connector Id 0