},
params: { overwrite?: boolean; save?: boolean } = { overwrite: false, save: false }
): void {
- if (!options || Utils.isEmptyObject(options)) {
- options = {
- readonly: false,
- visible: true,
- reboot: false,
- };
- }
- const readonly = options.readonly ?? false;
- const visible = options.visible ?? true;
- const reboot = options.reboot ?? false;
+ options = options ?? ({} as { readonly?: boolean; visible?: boolean; reboot?: boolean });
+ options.readonly = options?.readonly ?? false;
+ options.visible = options?.visible ?? true;
+ options.reboot = options?.reboot ?? false;
let keyFound = this.getConfigurationKey(key);
if (keyFound && params?.overwrite) {
this.deleteConfigurationKey(keyFound.key, { save: false });
if (!keyFound) {
this.configuration.configurationKey.push({
key,
- readonly,
+ readonly: options.readonly,
value,
- visible,
- reboot,
+ visible: options.visible,
+ reboot: options.reboot,
});
params?.save && this.saveConfiguration();
} else {
idSuffix;
}
+ private getRandomSerialNumberSuffix(params?: {
+ randomBytesLength?: number;
+ upperCase?: boolean;
+ }): string {
+ const randomSerialNumberSuffix = crypto
+ .randomBytes(params?.randomBytesLength ?? 16)
+ .toString('hex');
+ if (params?.upperCase) {
+ return randomSerialNumberSuffix.toUpperCase();
+ }
+ return randomSerialNumberSuffix;
+ }
+
private buildStationInfo(): ChargingStationInfo {
let stationTemplateFromFile: ChargingStationTemplate;
try {
);
this.convertDeprecatedTemplateKey(stationTemplateFromFile, 'supervisionUrl', 'supervisionUrls');
const stationInfo: ChargingStationInfo = stationTemplateFromFile ?? ({} as ChargingStationInfo);
+ stationInfo.chargePointSerialNumber =
+ stationTemplateFromFile?.chargePointSerialNumberPrefix &&
+ stationTemplateFromFile.chargePointSerialNumberPrefix;
+ delete stationInfo.chargePointSerialNumberPrefix;
+ stationInfo.chargeBoxSerialNumber =
+ stationTemplateFromFile?.chargeBoxSerialNumberPrefix &&
+ stationTemplateFromFile.chargeBoxSerialNumberPrefix;
+ delete stationInfo.chargeBoxSerialNumberPrefix;
stationInfo.wsOptions = stationTemplateFromFile?.wsOptions ?? {};
if (!Utils.isEmptyArray(stationTemplateFromFile.power)) {
stationTemplateFromFile.power = stationTemplateFromFile.power as number[];
this.bootNotificationRequest = {
chargePointModel: this.stationInfo.chargePointModel,
chargePointVendor: this.stationInfo.chargePointVendor,
- ...(!Utils.isUndefined(this.stationInfo.chargeBoxSerialNumberPrefix) && {
- chargeBoxSerialNumber: this.stationInfo.chargeBoxSerialNumberPrefix,
+ ...(!Utils.isUndefined(this.stationInfo.chargeBoxSerialNumber) && {
+ chargeBoxSerialNumber: this.stationInfo.chargeBoxSerialNumber,
+ }),
+ ...(!Utils.isUndefined(this.stationInfo.chargePointSerialNumber) && {
+ chargePointSerialNumber: this.stationInfo.chargePointSerialNumber,
}),
...(!Utils.isUndefined(this.stationInfo.firmwareVersion) && {
firmwareVersion: this.stationInfo.firmwareVersion,
meterType: this.stationInfo.meterType,
}),
};
-
this.hashId = crypto
.createHash(Constants.DEFAULT_HASH_ALGORITHM)
.update(JSON.stringify(this.bootNotificationRequest) + this.stationInfo.chargingStationId)