fix: ensure template has priority over CS configuration
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 27 May 2023 13:39:02 +0000 (15:39 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 27 May 2023 13:39:02 +0000 (15:39 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 414a48c520e08cae18bcffba836d20b504a62516..de005ddf86dfb058e614e08899361e744a0a7563 100644 (file)
@@ -1094,10 +1094,9 @@ export class ChargingStation {
       `${ChargingStationUtils.getHashId(this.index, stationTemplate)}.json`
     );
     const chargingStationConfiguration = this.getConfigurationFromFile();
-    // FIXME: template changes to evses or connectors are not taken into account
     if (
-      chargingStationConfiguration?.connectorsStatus ||
-      chargingStationConfiguration?.evsesStatus
+      chargingStationConfiguration?.stationInfo?.templateHash === stationTemplate?.templateHash &&
+      (chargingStationConfiguration?.connectorsStatus || chargingStationConfiguration?.evsesStatus)
     ) {
       this.initializeConnectorsOrEvsesFromFile(chargingStationConfiguration);
     } else {
@@ -1479,7 +1478,7 @@ export class ChargingStation {
     if (stationTemplate?.Evses) {
       const evsesConfigHash = crypto
         .createHash(Constants.DEFAULT_HASH_ALGORITHM)
-        .update(`${JSON.stringify(stationTemplate?.Evses)}`)
+        .update(JSON.stringify(stationTemplate?.Evses))
         .digest('hex');
       const evsesConfigChanged =
         this.evses?.size !== 0 && this.evsesConfigurationHash !== evsesConfigHash;