stationInfo.resetTime = !Utils.isNullOrUndefined(stationTemplate?.resetTime)
? stationTemplate.resetTime * 1000
: Constants.CHARGING_STATION_DEFAULT_RESET_TIME;
- // Initialize evses or connectors if needed (FIXME: should be factored out)
+ // Initialize evses or connectors if needed (FIXME: should be factored out but connectors and evses configuration are only available in templates)
this.initializeConnectorsOrEvses(stationInfo);
stationInfo.maximumAmperage = this.getMaximumAmperage(stationInfo);
- ChargingStationUtils.createStationInfoHash(stationInfo);
+ delete stationInfo?.Connectors;
+ delete stationInfo?.Evses;
return stationInfo;
}
private getStationInfoFromFile(): ChargingStationInfo | undefined {
let stationInfo: ChargingStationInfo | undefined;
- this.getStationInfoPersistentConfiguration() &&
- (stationInfo = this.getConfigurationFromFile()?.stationInfo);
- stationInfo && ChargingStationUtils.createStationInfoHash(stationInfo);
+ if (this.getStationInfoPersistentConfiguration()) {
+ stationInfo = this.getConfigurationFromFile()?.stationInfo;
+ if (stationInfo) {
+ delete stationInfo?.infoHash;
+ }
+ }
return stationInfo;
}
// Priority:
// 1. charging station info from template
// 2. charging station info from configuration file
- // 3. charging station info attribute
if (stationInfoFromFile?.templateHash === stationInfoFromTemplate.templateHash) {
- if (this.stationInfo?.infoHash === stationInfoFromFile?.infoHash) {
- return this.stationInfo;
- }
return stationInfoFromFile;
}
stationInfoFromFile &&
this.stationInfo.firmwareVersion = match?.join('.');
}
this.saveStationInfo();
- // Avoid duplication of connectors or evses related information in RAM
- delete this.stationInfo?.Connectors;
- delete this.stationInfo?.Evses;
this.configuredSupervisionUrl = this.getConfiguredSupervisionUrl();
if (this.getEnableStatistics() === true) {
this.performanceStatistics = PerformanceStatistics.getInstance(
return stationTemplate as unknown as ChargingStationInfo;
}
- public static createStationInfoHash(stationInfo: ChargingStationInfo): void {
- delete stationInfo.infoHash;
- stationInfo.infoHash = crypto
- .createHash(Constants.DEFAULT_HASH_ALGORITHM)
- .update(JSON.stringify(stationInfo))
- .digest('hex');
- }
-
public static createSerialNumber(
stationTemplate: ChargingStationTemplate,
stationInfo: ChargingStationInfo,
randomSerialNumber: true,
}
): void {
- params = params ?? {};
- params.randomSerialNumberUpperCase = params?.randomSerialNumberUpperCase ?? true;
- params.randomSerialNumber = params?.randomSerialNumber ?? true;
+ params = { ...{ randomSerialNumberUpperCase: true, randomSerialNumber: true }, ...params };
const serialNumberSuffix = params?.randomSerialNumber
? ChargingStationUtils.getRandomSerialNumberSuffix({
upperCase: params.randomSerialNumberUpperCase,
})
: '';
- stationInfo.chargePointSerialNumber = Utils.isNotEmptyString(
- stationTemplate?.chargePointSerialNumberPrefix
- )
- ? `${stationTemplate.chargePointSerialNumberPrefix}${serialNumberSuffix}`
- : undefined;
- stationInfo.chargeBoxSerialNumber = Utils.isNotEmptyString(
- stationTemplate?.chargeBoxSerialNumberPrefix
- )
- ? `${stationTemplate.chargeBoxSerialNumberPrefix}${serialNumberSuffix}`
- : undefined;
- stationInfo.meterSerialNumber = Utils.isNotEmptyString(stationTemplate?.meterSerialNumberPrefix)
- ? `${stationTemplate.meterSerialNumberPrefix}${serialNumberSuffix}`
- : undefined;
+ Utils.isNotEmptyString(stationTemplate?.chargePointSerialNumberPrefix) &&
+ (stationInfo.chargePointSerialNumber = `${stationTemplate.chargePointSerialNumberPrefix}${serialNumberSuffix}`);
+ Utils.isNotEmptyString(stationTemplate?.chargeBoxSerialNumberPrefix) &&
+ (stationInfo.chargeBoxSerialNumber = `${stationTemplate.chargeBoxSerialNumberPrefix}${serialNumberSuffix}`);
+ Utils.isNotEmptyString(stationTemplate?.meterSerialNumberPrefix) &&
+ (stationInfo.meterSerialNumber = `${stationTemplate.meterSerialNumberPrefix}${serialNumberSuffix}`);
}
public static propagateSerialNumber(
| 'meterSerialNumberPrefix'
> & {
hashId: string;
+ /** @deprecated Use hashId instead */
infoHash?: string;
chargingStationId?: string;
chargeBoxSerialNumber?: string;
firmwareVersion?: string;
numberOfConnectors?: number | number[];
baseName: string;
- infoHash?: string;
templateHash?: string;
chargeBoxSerialNumber?: string;
chargePointSerialNumber?: string;