+ if (
+ chargingProfile.chargingSchedule?.startSchedule != null &&
+ !isDate(chargingProfile.chargingSchedule?.startSchedule)
+ ) {
+ logger.warn(
+ `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetCompositeSchedule: Charging profile id ${
+ chargingProfile.chargingProfileId
+ } startSchedule property is not a Date instance. Trying to convert it to a Date instance`
+ )
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ chargingProfile.chargingSchedule.startSchedule = convertToDate(
+ chargingProfile.chargingSchedule?.startSchedule
+ )!
+ }
+ if (
+ chargingProfile.chargingSchedule?.startSchedule != null &&
+ chargingProfile.chargingSchedule?.duration == null
+ ) {
+ logger.debug(
+ `${chargingStation.logPrefix()} ${moduleName}.handleRequestGetCompositeSchedule: Charging profile id ${
+ chargingProfile.chargingProfileId
+ } has no duration defined and will be set to the maximum time allowed`
+ )
+ // OCPP specifies that if duration is not defined, it should be infinite
+ chargingProfile.chargingSchedule.duration = differenceInSeconds(
+ maxTime,
+ chargingProfile.chargingSchedule.startSchedule
+ )
+ }
+ if (
+ !prepareChargingProfileKind(
+ connectorStatus,
+ chargingProfile,
+ compositeScheduleInterval.start as Date,
+ chargingStation.logPrefix()
+ )
+ ) {
+ continue
+ }
+ if (
+ !canProceedChargingProfile(
+ chargingProfile,
+ compositeScheduleInterval.start as Date,
+ chargingStation.logPrefix()
+ )
+ ) {
+ continue
+ }
+ compositeSchedule = OCPP16ServiceUtils.composeChargingSchedules(
+ previousCompositeSchedule,
+ chargingProfile.chargingSchedule,
+ compositeScheduleInterval
+ )
+ previousCompositeSchedule = compositeSchedule