From: Jérôme Benoit Date: Sun, 9 Jun 2024 13:52:02 +0000 (+0200) Subject: fix: ensure no charging profile purpose TxProfile is loaded at startup X-Git-Tag: v1.3.6~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3edfdf53dc3c75bf26b4737bb014e6e98239ef38;p=e-mobility-charging-stations-simulator.git fix: ensure no charging profile purpose TxProfile is loaded at startup Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 47e911a4..7dbb0d3e 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -131,7 +131,7 @@ import { hasFeatureProfile, hasReservationExpired, initializeConnectorsMapStatus, - prepareDatesInConnectorStatus, + prepareConnectorStatus, propagateSerialNumber, setChargingStationOptions, stationTemplateToStationInfo, @@ -1480,7 +1480,7 @@ export class ChargingStation extends EventEmitter { for (const [connectorId, connectorStatus] of configuration.connectorsStatus.entries()) { this.connectors.set( connectorId, - prepareDatesInConnectorStatus(clone(connectorStatus)) + prepareConnectorStatus(clone(connectorStatus)) ) } } else if (configuration.evsesStatus != null && configuration.connectorsStatus == null) { @@ -1493,7 +1493,7 @@ export class ChargingStation extends EventEmitter { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion evseStatusConfiguration.connectorsStatus!.map((connectorStatus, connectorId) => [ connectorId, - prepareDatesInConnectorStatus(connectorStatus) + prepareConnectorStatus(connectorStatus) ]) ) }) diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index 4d6a477c..01c7f292 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -436,22 +436,25 @@ export const resetConnectorStatus = (connectorStatus: ConnectorStatus | undefine delete connectorStatus.transactionBeginMeterValue } -export const prepareDatesInConnectorStatus = ( - connectorStatus: ConnectorStatus -): ConnectorStatus => { +export const prepareConnectorStatus = (connectorStatus: ConnectorStatus): ConnectorStatus => { if (connectorStatus.reservation != null) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion connectorStatus.reservation.expiryDate = convertToDate(connectorStatus.reservation.expiryDate)! } if (isNotEmptyArray(connectorStatus.chargingProfiles)) { - connectorStatus.chargingProfiles = connectorStatus.chargingProfiles.map(chargingProfile => { - chargingProfile.chargingSchedule.startSchedule = convertToDate( - chargingProfile.chargingSchedule.startSchedule + connectorStatus.chargingProfiles = connectorStatus.chargingProfiles + .filter( + chargingProfile => + chargingProfile.chargingProfilePurpose !== ChargingProfilePurposeType.TX_PROFILE ) - chargingProfile.validFrom = convertToDate(chargingProfile.validFrom) - chargingProfile.validTo = convertToDate(chargingProfile.validTo) - return chargingProfile - }) + .map(chargingProfile => { + chargingProfile.chargingSchedule.startSchedule = convertToDate( + chargingProfile.chargingSchedule.startSchedule + ) + chargingProfile.validFrom = convertToDate(chargingProfile.validFrom) + chargingProfile.validTo = convertToDate(chargingProfile.validTo) + return chargingProfile + }) } return connectorStatus }