Better handling of missing serial number prefix in template
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 14 Mar 2022 10:23:21 +0000 (11:23 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 14 Mar 2022 10:24:06 +0000 (11:24 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 88efd93c7a3f98586f4dd0979982a3506227ec2c..bd3e9c9cf998b26acbf0fef91b9e2cdd6f751ea9 100644 (file)
@@ -791,9 +791,13 @@ export default class ChargingStation {
     );
     this.convertDeprecatedTemplateKey(stationTemplateFromFile, 'supervisionUrl', 'supervisionUrls');
     const stationInfo: ChargingStationInfo = stationTemplateFromFile ?? ({} as ChargingStationInfo);
-    stationInfo.chargePointSerialNumber = stationTemplateFromFile?.chargePointSerialNumberPrefix;
+    stationInfo.chargePointSerialNumber =
+      stationTemplateFromFile?.chargePointSerialNumberPrefix &&
+      stationTemplateFromFile.chargePointSerialNumberPrefix;
     delete stationInfo.chargePointSerialNumberPrefix;
-    stationInfo.chargeBoxSerialNumber = stationTemplateFromFile?.chargeBoxSerialNumberPrefix;
+    stationInfo.chargeBoxSerialNumber =
+      stationTemplateFromFile?.chargeBoxSerialNumberPrefix &&
+      stationTemplateFromFile.chargeBoxSerialNumberPrefix;
     delete stationInfo.chargeBoxSerialNumberPrefix;
     stationInfo.wsOptions = stationTemplateFromFile?.wsOptions ?? {};
     if (!Utils.isEmptyArray(stationTemplateFromFile.power)) {
@@ -860,7 +864,6 @@ export default class ChargingStation {
         meterType: this.stationInfo.meterType,
       }),
     };
-
     this.hashId = crypto
       .createHash(Constants.DEFAULT_HASH_ALGORITHM)
       .update(JSON.stringify(this.bootNotificationRequest) + this.stationInfo.chargingStationId)