Reorder connectors at Status Notification OCPP event
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1081,6 +1081,11 @@ export default class OCPPService {
await this.updateOCPIConnectorStatus(tenantID, chargingStation, foundConnector);
}
}
+ // Update connector's order
+ if (!Utils.isEmptyArray(chargingStation?.connectors)) {
+ chargingStation.connectors.sort((connector1: Connector, connector2: Connector) =>
+ connector1?.connectorId - connector2?.connectorId);
+ }
// Save
await ChargingStationStorage.saveChargingStation(tenantID, chargingStation);
// Trigger Smart Charging

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -353,8 +353,6 @@ export default class ChargingStationStorage {
// Reorder connector ID
// TODO: To remove the 'if containsGPSCoordinates' when SiteID optimization will be implemented
if (!Utils.containsGPSCoordinates(params.locCoordinates)) {
- // Always add Connector ID
- dbParams.sort = { ...dbParams.sort, 'connectors.connectorId': 1 };
aggregation.push({
$sort: dbParams.sort
});

Reorder connectors at Status Notification OCPP event