From 86ad08b201bdfb35de3295a5f36a3998f24ae702 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 29 Sep 2021 05:28:41 +0200 Subject: [PATCH] Handle connectors number shrinking at template reload. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index f93f4133..a5319ecc 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -508,8 +508,9 @@ export default class ChargingStation { this.stationInfo.randomConnectors = true; } const connectorsConfigHash = crypto.createHash('sha256').update(JSON.stringify(this.stationInfo.Connectors) + maxConnectors.toString()).digest('hex'); - // FIXME: Handle shrinking the number of connectors - if (!this.connectors || (this.connectors && this.connectorsConfigurationHash !== connectorsConfigHash)) { + const connectorsConfigChanged = !Utils.isEmptyObject(this.connectors) && this.connectorsConfigurationHash !== connectorsConfigHash; + if (Utils.isEmptyObject(this.connectors) || connectorsConfigChanged) { + connectorsConfigChanged && (this.connectors = {} as Connectors); this.connectorsConfigurationHash = connectorsConfigHash; // Add connector Id 0 let lastConnector = '0'; -- 2.34.1