From: Jérôme Benoit Date: Sat, 12 Mar 2022 11:32:56 +0000 (+0100) Subject: Delete supervision url configuration key if the feature is disabled from X-Git-Tag: v1.1.55~18 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e6895390a1697376fdee9c7ebb1e775c24f1022d;p=e-mobility-charging-stations-simulator.git Delete supervision url configuration key if the feature is disabled from persistent storage Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 3000d6d0..01829fdf 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -633,10 +633,7 @@ export default class ChargingStation { const reboot = options.reboot; let keyFound = this.getConfigurationKey(key); if (keyFound && params?.overwrite) { - this.configuration.configurationKey.splice( - this.configuration.configurationKey.indexOf(keyFound), - 1 - ); + this.deleteConfigurationKey(keyFound.key, { save: false }); keyFound = undefined; } if (!keyFound) { @@ -674,6 +671,21 @@ export default class ChargingStation { } } + public deleteConfigurationKey( + key: string | StandardParametersKey, + params: { save?: boolean; caseInsensitive?: boolean } = { save: true, caseInsensitive: false } + ): ConfigurationKey[] { + const keyFound = this.getConfigurationKey(key, params?.caseInsensitive); + if (keyFound) { + const deletedConfigurationKey = this.configuration.configurationKey.splice( + this.configuration.configurationKey.indexOf(keyFound), + 1 + ); + params?.save && this.saveConfiguration(); + return deletedConfigurationKey; + } + } + public setChargingProfile(connectorId: number, cp: ChargingProfile): void { let cpReplaced = false; if (!Utils.isEmptyArray(this.getConnectorStatus(connectorId).chargingProfiles)) { @@ -966,6 +978,11 @@ export default class ChargingStation { this.getConfiguredSupervisionUrl().href, { reboot: true } ); + } else if ( + !this.getSupervisionUrlOcppConfiguration() && + this.getConfigurationKey(this.getSupervisionUrlOcppKey()) + ) { + this.deleteConfigurationKey(this.getSupervisionUrlOcppKey(), { save: false }); } if (!this.getConfigurationKey(StandardParametersKey.SupportedFeatureProfiles)) { this.addConfigurationKey(