- ? ChargingRateUnitType.AMPERE
- : chargingProfiles.every(
- (chargingProfile) =>
- chargingProfile.chargingSchedule.chargingRateUnit === ChargingRateUnitType.WATT,
- )
- ? ChargingRateUnitType.WATT
- : ChargingRateUnitType.AMPERE,
- // FIXME: remove overlapping charging schedule periods
- chargingSchedulePeriod: chargingProfiles
- .map((chargingProfile) => chargingProfile.chargingSchedule.chargingSchedulePeriod)
- .reduce(
- (accumulator, value) =>
- accumulator.concat(value).sort((a, b) => a.startPeriod - b.startPeriod),
- [],
- ),
- minChargeRate: Math.min(
- ...chargingProfiles.map(
- (chargingProfile) => chargingProfile.chargingSchedule.minChargeRate ?? Infinity,
- ),
- ),
- };
- return {
- status: GenericStatus.Accepted,
- scheduleStart: compositeSchedule.startSchedule!,
- connectorId,
- chargingSchedule: compositeSchedule,
- };
+ previousCompositeSchedule = compositeSchedule
+ }
+ if (compositeSchedule != null) {
+ return {
+ status: GenericStatus.Accepted,
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ scheduleStart: compositeSchedule.startSchedule!,
+ connectorId,
+ chargingSchedule: compositeSchedule
+ }
+ }
+ return OCPP16Constants.OCPP_RESPONSE_REJECTED