Add getter for supervisionUrlOcppKey value
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 12 Mar 2022 09:44:31 +0000 (10:44 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 12 Mar 2022 09:44:31 +0000 (10:44 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 75094ceb104f538d92d1882c5145b3cf18fd664e..cc0fd47f2ab9edd15f41d7202a1a4b0bab24cb38 100644 (file)
@@ -105,9 +105,7 @@ export default class ChargingStation {
   get wsConnectionUrl(): URL {
     return this.getSupervisionUrlOcppConfiguration()
       ? new URL(
-          this.getConfigurationKey(
-            this.stationInfo.supervisionUrlOcppKey ?? VendorDefaultParametersKey.ConnectionUrl
-          ).value +
+          this.getConfigurationKey(this.getSupervisionUrlOcppKey()).value +
             '/' +
             this.stationInfo.chargingStationId
         )
@@ -720,6 +718,10 @@ export default class ChargingStation {
     }
   }
 
+  private getSupervisionUrlOcppKey(): string {
+    return this.stationInfo.supervisionUrlOcppKey ?? VendorDefaultParametersKey.ConnectionUrl;
+  }
+
   private getSupervisionUrlOcppConfiguration(): boolean {
     return this.stationInfo.supervisionUrlOcppConfiguration ?? false;
   }
@@ -951,12 +953,10 @@ export default class ChargingStation {
   private initOcppParameters(): void {
     if (
       this.getSupervisionUrlOcppConfiguration() &&
-      !this.getConfigurationKey(
-        this.stationInfo.supervisionUrlOcppKey ?? VendorDefaultParametersKey.ConnectionUrl
-      )
+      !this.getConfigurationKey(this.getSupervisionUrlOcppKey())
     ) {
       this.addConfigurationKey(
-        this.stationInfo.supervisionUrlOcppKey ?? VendorDefaultParametersKey.ConnectionUrl,
+        this.getSupervisionUrlOcppKey(),
         this.getConfiguredSupervisionUrl().href,
         { reboot: true }
       );