clean ups and comments
MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -125,9 +125,22 @@ export default class ChargingStationService {
delete chargingStation.templateHashOcppStandard;
delete chargingStation.templateHashOcppVendor;
delete chargingStation.templateHashTechnical;
- } else if (chargingStation.manualConfiguration && !filteredRequest.manualConfiguration) {
+ } else if ((chargingStation.manualConfiguration && !filteredRequest.manualConfiguration) ||
+ (!filteredRequest.manualConfiguration && !(chargingStation.chargePoints?.length > 0))) {
+ // If charging station is not configured manually anymore, the template will be applied again
chargingStation.manualConfiguration = filteredRequest.manualConfiguration;
- await OCPPUtils.enrichChargingStationWithTemplate(req.user.tenantID, chargingStation);
+ const templateUpdateResult = await OCPPUtils.enrichChargingStationWithTemplate(req.user.tenantID, chargingStation);
+ // If not template was found, throw error (Check is done on technical configuration)
+ if (!templateUpdateResult.technicalUpdated) {
+ throw new AppError({
+ source: Constants.CENTRAL_SERVER,
+ action: action,
+ errorCode: HTTPError.GENERAL_ERROR,
+ message: `Error occurred while updating chargingStation: '${chargingStation.id}'. No template found`,
+ module: MODULE_NAME, method: 'handleUpdateChargingStationParams',
+ user: req.user,
+ });
+ }
rebootRequired = true;
}
}
@@ -143,7 +156,6 @@ export default class ChargingStationService {
connector.voltage = filteredConnector.voltage;
connector.currentType = filteredConnector.currentType;
connector.numberOfConnectedPhase = filteredConnector.numberOfConnectedPhase;
- connector.amperageLimit = connector.amperage;
}
connector.phaseAssignmentToGrid = filteredConnector.phaseAssignmentToGrid;
}
@@ -168,11 +180,13 @@ export default class ChargingStationService {
chargePoint.connectorIDs = filteredChargePoint.connectorIDs;
UtilsService.checkIfChargePointValid(chargingStation, chargePoint, req);
} else {
+ // If charging station does not have charge points, but request contains charge points, add it to the station
chargingStation.chargePoints ? chargingStation.chargePoints.push(filteredChargePoint) : chargingStation.chargePoints = [filteredChargePoint];
UtilsService.checkIfChargePointValid(chargingStation, filteredChargePoint, req);
}
}
} else if (Utils.isEmptyArray(filteredRequest.chargePoints) && !Utils.isEmptyArray(chargingStation.chargePoints)) {
+ // If charging station contains charge points, but request does not contain charge points, delete them
delete chargingStation.chargePoints;
}
}
@@ -241,7 +255,7 @@ export default class ChargingStationService {
throw new AppError({
source: Constants.CENTRAL_SERVER,
action: action,
- errorCode: HTTPError.CHARGING_POINT_NOT_VALID,
+ errorCode: HTTPError.GENERAL_ERROR,
message: 'Error occurred while restarting the charging station',
module: MODULE_NAME, method: 'handleUpdateChargingStationParams',
user: req.user, actionOnUser: req.user,

MODIFY
src/server/rest/v1/service/UtilsService.ts
src/server/rest/v1/service/UtilsService.ts
@@ -415,14 +415,16 @@ export default class UtilsService {
public static checkIfChargePointValid(chargingStation: ChargingStation, chargePoint: ChargePoint, req: Request): void {
const connectors = Utils.getConnectorsFromChargePoint(chargingStation, chargePoint);
+ // Add helpers to check if charge point is valid
let chargePointAmperage = 0;
let chargePointPower = 0;
for (const connector of connectors) {
+ // Check if properties from charge point match the properties from the connector
if (connector.voltage && chargePoint.voltage && connector.voltage !== chargePoint.voltage) {
throw new AppError({
source: Constants.CENTRAL_SERVER,
action: ServerAction.CHARGING_STATION_UPDATE_PARAMS,
- errorCode: HTTPError.CHARGING_POINT_NOT_VALID,
+ errorCode: HTTPError.CHARGE_POINT_NOT_VALID,
message: 'Charge Point does not match the voltage of its connectors',
module: MODULE_NAME, method: 'checkIfChargePointValid',
user: req.user.id
@@ -432,7 +434,7 @@ export default class UtilsService {
throw new AppError({
source: Constants.CENTRAL_SERVER,
action: ServerAction.CHARGING_STATION_UPDATE_PARAMS,
- errorCode: HTTPError.CHARGING_POINT_NOT_VALID,
+ errorCode: HTTPError.CHARGE_POINT_NOT_VALID,
message: 'Charge Point does not match the number of phases of its connectors',
module: MODULE_NAME, method: 'checkIfChargePointValid',
user: req.user.id
@@ -442,18 +444,19 @@ export default class UtilsService {
throw new AppError({
source: Constants.CENTRAL_SERVER,
action: ServerAction.CHARGING_STATION_UPDATE_PARAMS,
- errorCode: HTTPError.CHARGING_POINT_NOT_VALID,
+ errorCode: HTTPError.CHARGE_POINT_NOT_VALID,
message: 'Charge Point does not match the currentType of its connectors',
module: MODULE_NAME, method: 'checkIfChargePointValid',
user: req.user.id
});
}
+ // Check connectors power when it is shared within the charge point
if (chargePoint.sharePowerToAllConnectors) {
if (connector.amperage && chargePoint.amperage && connector.amperage !== chargePoint.amperage) {
throw new AppError({
source: Constants.CENTRAL_SERVER,
action: ServerAction.CHARGING_STATION_UPDATE_PARAMS,
- errorCode: HTTPError.CHARGING_POINT_NOT_VALID,
+ errorCode: HTTPError.CHARGE_POINT_NOT_VALID,
message: 'Charge Points amperage does not equal the amperage of the connectors (shared power between connectors)',
module: MODULE_NAME, method: 'checkIfChargePointValid',
user: req.user.id
@@ -463,7 +466,7 @@ export default class UtilsService {
throw new AppError({
source: Constants.CENTRAL_SERVER,
action: ServerAction.CHARGING_STATION_UPDATE_PARAMS,
- errorCode: HTTPError.CHARGING_POINT_NOT_VALID,
+ errorCode: HTTPError.CHARGE_POINT_NOT_VALID,
message: 'Charge Points power does not equal the power of the connectors (shared power between connectors)',
module: MODULE_NAME, method: 'checkIfChargePointValid',
user: req.user.id
@@ -478,7 +481,7 @@ export default class UtilsService {
throw new AppError({
source: Constants.CENTRAL_SERVER,
action: ServerAction.CHARGING_STATION_UPDATE_PARAMS,
- errorCode: HTTPError.CHARGING_POINT_NOT_VALID,
+ errorCode: HTTPError.CHARGE_POINT_NOT_VALID,
message: `Charge Points amperage ${chargePoint.amperage}A does not match the combined amperage of the connectors ${chargePointPower}A`,
module: MODULE_NAME, method: 'checkIfChargePointValid',
user: req.user.id
@@ -488,7 +491,7 @@ export default class UtilsService {
throw new AppError({
source: Constants.CENTRAL_SERVER,
action: ServerAction.CHARGING_STATION_UPDATE_PARAMS,
- errorCode: HTTPError.CHARGING_POINT_NOT_VALID,
+ errorCode: HTTPError.CHARGE_POINT_NOT_VALID,
message: `Charge Points power ${chargePoint.power}W does not match the combined power of the connectors ${chargePointPower}W`,
module: MODULE_NAME, method: 'checkIfChargePointValid',
user: req.user.id

MODIFY
src/types/HTTPError.ts
src/types/HTTPError.ts
@@ -66,7 +66,7 @@ export enum HTTPError {
CANNOT_ACQUIRE_LOCK = 510, // FIXME: override an already defined HTTP status code: Not extended (RFC 2774)
INVALID_FILE_FORMAT = 583,
- CHARGING_POINT_NOT_VALID = 584,
+ CHARGE_POINT_NOT_VALID = 584,
}
export enum HTTPAuthError {

clean ups and comments