From ccfa30bcb2406fa394faf8fb2402a1d409c1a409 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 2 Aug 2023 16:44:53 +0200 Subject: [PATCH] fix: ensure the latest schedule period within the charging profile duration is used MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/Helpers.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/charging-station/Helpers.ts b/src/charging-station/Helpers.ts index 1856007e..1dfc0f80 100644 --- a/src/charging-station/Helpers.ts +++ b/src/charging-station/Helpers.ts @@ -826,14 +826,13 @@ const getLimitFromChargingProfiles = ( if ( index === chargingSchedule.chargingSchedulePeriod.length - 1 || (index < chargingSchedule.chargingSchedulePeriod.length - 1 && - chargingSchedule.duration! > - differenceInSeconds( - addSeconds( - chargingSchedule.startSchedule!, - chargingSchedule.chargingSchedulePeriod[index + 1].startPeriod, - ), + differenceInSeconds( + addSeconds( chargingSchedule.startSchedule!, - )) + chargingSchedule.chargingSchedulePeriod[index + 1].startPeriod, + ), + chargingSchedule.startSchedule!, + ) > chargingSchedule.duration!) ) { const result: ChargingProfilesLimit = { limit: previousChargingSchedulePeriod.limit, @@ -862,6 +861,12 @@ export const prepareChargingProfileKind = ( prepareRecurringChargingProfile(chargingProfile, currentDate, logPrefix); break; case ChargingProfileKindType.RELATIVE: + if (!isNullOrUndefined(chargingProfile.chargingSchedule.startSchedule)) { + logger.warn( + `${logPrefix} ${moduleName}.prepareChargingProfileKind: Charging profile id ${chargingProfile.chargingProfileId} has a startSchedule property defined. It will be ignored or set to the connector current transaction start date`, + ); + delete chargingProfile.chargingSchedule.startSchedule; + } connectorStatus?.transactionStarted && (chargingProfile.chargingSchedule.startSchedule = connectorStatus?.transactionStart); break; -- 2.34.1