}
public static createStationInfoHash(stationInfo: ChargingStationInfo): void {
- const previousInfoHash = stationInfo?.infoHash ?? '';
delete stationInfo.infoHash;
- const currentInfoHash = crypto
+ stationInfo.infoHash = crypto
.createHash(Constants.DEFAULT_HASH_ALGORITHM)
.update(JSON.stringify(stationInfo))
.digest('hex');
- if (
- Utils.isEmptyString(previousInfoHash) ||
- (!Utils.isEmptyString(previousInfoHash) && currentInfoHash !== previousInfoHash)
- ) {
- stationInfo.infoHash = currentInfoHash;
- } else {
- stationInfo.infoHash = previousInfoHash;
- }
}
public static createSerialNumber(
stationInfoDst: ChargingStationInfo = {} as ChargingStationInfo
) {
if (!stationInfoSrc || !stationTemplate) {
- throw new BaseError('Missing charging station template or info to propagate serial number');
+ throw new BaseError(
+ 'Missing charging station template or existing configuration to propagate serial number'
+ );
}
stationTemplate?.chargePointSerialNumberPrefix && stationInfoSrc?.chargePointSerialNumber
? (stationInfoDst.chargePointSerialNumber = stationInfoSrc.chargePointSerialNumber)