- params: { overwrite?: boolean; save?: boolean } = { overwrite: false, save: false }
- ): void {
- 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 = ChargingStationConfigurationUtils.getConfigurationKey(chargingStation, key);
- if (keyFound && params?.overwrite) {
- ChargingStationConfigurationUtils.deleteConfigurationKey(chargingStation, keyFound.key, {
- save: false,
- });
- keyFound = undefined;
- }
- if (!keyFound) {
- chargingStation.ocppConfiguration.configurationKey.push({
- key,
- readonly: options.readonly,
- value,
- visible: options.visible,
- reboot: options.reboot,
- });
- params?.save && chargingStation.saveOcppConfiguration();
- } else {
- logger.error(
- `${chargingStation.logPrefix()} Trying to add an already existing configuration key: %j`,
- keyFound
- );
- }
+ ...options,
+ };
+ params = { ...{ overwrite: false, save: false }, ...params };
+ let keyFound = getConfigurationKey(chargingStation, key);
+ if (keyFound && params?.overwrite) {
+ deleteConfigurationKey(chargingStation, keyFound.key, {
+ save: false,
+ });
+ keyFound = undefined;