Simplified update in Charging Station Service
MODIFY
src/server/rest/service/ChargingStationService.ts
src/server/rest/service/ChargingStationService.ts
@@ -158,30 +158,23 @@ export default class ChargingStationService {
filteredRequest.coordinates[1]
];
}
- // No charge point
- if ((!chargingStation.chargePoints || chargingStation.chargePoints.length === 0) && filteredRequest.connectors) {
- // Update Connectors
+ // Existing Connectors
+ if (!Utils.isEmptyArray(filteredRequest.connectors)) {
for (const filteredConnector of filteredRequest.connectors) {
- // Set
const connector = Utils.getConnectorFromID(chargingStation, filteredConnector.connectorId);
+ // Update Connectors only if no Charge Point is defined
+ if (connector && Utils.isEmptyArray(chargingStation.chargePoints)) {
connector.type = filteredConnector.type;
connector.power = filteredConnector.power;
connector.amperage = filteredConnector.amperage;
connector.voltage = filteredConnector.voltage;
connector.currentType = filteredConnector.currentType;
connector.numberOfConnectedPhase = filteredConnector.numberOfConnectedPhase;
- connector.phaseAssignmentToGrid = filteredConnector.phaseAssignmentToGrid;
}
- } else if (siteArea?.numberOfPhases === 3 && filteredRequest.connectors) {
- // Assign Phases
- for (const filteredConnector of filteredRequest.connectors) {
- // Set
- const connector = Utils.getConnectorFromID(chargingStation, filteredConnector.connectorId);
- if (filteredConnector.phaseAssignmentToGrid) {
+ // Always update
connector.phaseAssignmentToGrid = filteredConnector.phaseAssignmentToGrid;
}
}
- }
// Update timestamp
chargingStation.lastChangedBy = { 'id': req.user.id };
chargingStation.lastChangedOn = new Date();

Simplified update in Charging Station Service