refactor: cleanup default stationInfo handling
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 10 Feb 2024 00:19:08 +0000 (01:19 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 10 Feb 2024 00:19:08 +0000 (01:19 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index aca295df61a0fae9f3bbef46f720fac49db444d8..a57f3eaa071ecfceb7fd38b6d99ec3c9ef97d453 100644 (file)
@@ -1196,7 +1196,8 @@ export class ChargingStation extends EventEmitter {
   }
 
   private getStationInfoFromFile (
-    stationInfoPersistentConfiguration?: boolean
+    stationInfoPersistentConfiguration: boolean | undefined = Constants.DEFAULT_STATION_INFO
+      .stationInfoPersistentConfiguration
   ): ChargingStationInfo | undefined {
     let stationInfo: ChargingStationInfo | undefined
     if (stationInfoPersistentConfiguration === true) {
@@ -1221,7 +1222,7 @@ export class ChargingStation extends EventEmitter {
       (stationInfoFromTemplate.stationInfoPersistentConfiguration =
         stationInfoPersistentConfiguration)
     const stationInfoFromFile = this.getStationInfoFromFile(
-      stationInfoFromTemplate.stationInfoPersistentConfiguration ?? true
+      stationInfoFromTemplate.stationInfoPersistentConfiguration
     )
     // Priority:
     // 1. charging station info from template
@@ -1802,7 +1803,8 @@ export class ChargingStation extends EventEmitter {
   }
 
   private getOcppConfiguration (
-    ocppPersistentConfiguration: boolean | undefined = this.stationInfo?.ocppPersistentConfiguration
+    ocppPersistentConfiguration: boolean | undefined = Constants.DEFAULT_STATION_INFO
+      .ocppPersistentConfiguration
   ): ChargingStationOcppConfiguration | undefined {
     let ocppConfiguration: ChargingStationOcppConfiguration | undefined =
       this.getOcppConfigurationFromFile(ocppPersistentConfiguration)