Updated OCPP Params handling
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
+ "/api/chargingstations/{id}/ocpp/parameters": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Get Charging Station OCPP Parameters",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
+ }
+ ],
+ "tags": [
+ "Charging Stations"
+ ],
+ "responses": {
+ "200": {
+ "description": "Return Charging Station OCPP Parameters",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "count": {
+ "type": "number"
+ },
+ "result": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string"
+ },
+ "readonly": {
+ "type": "boolean"
+ },
+ "value": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "example": {
+ "count": 2,
+ "result": [
+ {
+ "key": "AllowOfflineTxForUnknownId",
+ "readonly": false,
+ "value": "true"
+ },
+ {
+ "key": "allowpluggedcable",
+ "readonly": true,
+ "value": "true"
+ }
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "500": {
+ "$ref": "#/components/responses/500BackendError"
+ }
+ }
+ }
+ },
"/api/chargingstations/ocpp/parameters": {
"post": {
"security": [
"application/json": {
"schema": {
"type": "object",
- "required": [
- "chargeBoxID",
- "forceUpdateOCPPParamsFromTemplate"
- ],
"properties": {
"chargeBoxID": {
- "type": "string"
+ "type": "string",
+ "example": ""
},
"forceUpdateOCPPParamsFromTemplate": {
"type": "boolean",
"example": false
}
- }
+ },
+ "required": [
+ "chargeBoxID",
+ "forceUpdateOCPPParamsFromTemplate"
+ ]
}
}
}
}
}
},
- "/api/chargingstations/{id}/ocpp/parameters": {
- "get": {
- "security": [
- {
- "bearerAuth": []
- }
- ],
- "description": "Get Charging Station OCPP Parameters",
- "parameters": [
- {
- "$ref": "#/components/parameters/chargingStationID"
- }
- ],
- "tags": [
- "Charging Stations"
- ],
- "responses": {
- "200": {
- "description": "Return Charging Station OCPP Parameters",
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "count": {
- "type": "number"
- },
- "result": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "key": {
- "type": "string"
- },
- "readonly": {
- "type": "boolean"
- },
- "value": {
- "type": "string"
- }
- }
- }
- }
- }
- },
- "example": {
- "count": 2,
- "result": [
- {
- "key": "AllowOfflineTxForUnknownId",
- "readonly": false,
- "value": "true"
- },
- {
- "key": "allowpluggedcable",
- "readonly": true,
- "value": "true"
- }
- ]
- }
- }
- }
- },
- "401": {
- "$ref": "#/components/responses/UnauthorizedError"
- },
- "500": {
- "$ref": "#/components/responses/500BackendError"
- }
- }
- }
- },
"/api/chargingstations/{id}/ocpp/parameters/export": {
"get": {
"security": [

MODIFY
src/server/rest/v1/router/api/ChargingStationRouter.ts
src/server/rest/v1/router/api/ChargingStationRouter.ts
@@ -36,7 +36,7 @@ export default class ChargingStationRouter {
this.buildRouteChargingStationGetDiagnostics();
this.buildRouteChargingStationUpdateFirmware();
this.buildRouteChargingStationDownloadQRCode();
- this.buildRouteChargingStationOCPPParameters();
+ this.buildRouteChargingStationGetOCPPParameters();
this.buildRouteChargingStationExportOCPPParameters();
this.buildRouteChargingStationUpdateParameters();
this.buildRouteChargingStationLimitPower();
@@ -140,22 +140,22 @@ export default class ChargingStationRouter {
});
}
- protected buildRouteChargingStationRequestOCPPParameters(): void {
- this.router.post(`/${ServerRoute.REST_CHARGING_STATIONS_OCPP_PARAMETERS}`, async (req: Request, res: Response, next: NextFunction) => {
- await RouterUtils.handleServerAction(ChargingStationService.handleRequestChargingStationOcppParameters.bind(this), ServerAction.CHARGING_STATION_REQUEST_OCPP_PARAMETERS, req, res, next);
+ protected buildRouteChargingStationGetOCPPParameters(): void {
+ this.router.get(`/${ServerRoute.REST_CHARGING_STATION_GET_OCPP_PARAMETERS}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ChargeBoxID = req.params.id;
+ await RouterUtils.handleServerAction(ChargingStationService.handleGetChargingStationOcppParameters.bind(this), ServerAction.CHARGING_STATIONS_OCPP_PARAMETERS, req, res, next);
});
}
- protected buildRouteChargingStationOCPPParameters(): void {
- this.router.get(`/${ServerRoute.REST_CHARGING_STATION_OCPP_PARAMETERS}`, async (req: Request, res: Response, next: NextFunction) => {
- req.query.ChargeBoxID = req.params.id;
- await RouterUtils.handleServerAction(ChargingStationService.handleGetChargingStationOcppParameters.bind(this), ServerAction.CHARGING_STATIONS_OCPP_PARAMETERS, req, res, next);
+ protected buildRouteChargingStationRequestOCPPParameters(): void {
+ this.router.post(`/${ServerRoute.REST_CHARGING_STATIONS_REQUEST_OCPP_PARAMETERS}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(ChargingStationService.handleRequestChargingStationOcppParameters.bind(this), ServerAction.CHARGING_STATION_REQUEST_OCPP_PARAMETERS, req, res, next);
});
}
protected buildRouteChargingStationExportOCPPParameters(): void {
- this.router.get(`/${ServerRoute.REST_CHARGING_STATIONS_OCPP_PARAMETERS_EXPORT}`, async (req: Request, res: Response, next: NextFunction) => {
- req.query.ChargeBoxID = req.params.id;
+ this.router.get(`/${ServerRoute.REST_CHARGING_STATIONS_EXPORT_OCPP_PARAMETERS}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ChargingStationID = req.params.id;
await RouterUtils.handleServerAction(ChargingStationService.handleExportChargingStationsOCPPParams.bind(this), ServerAction.CHARGING_STATIONS_OCPP_PARAMS_EXPORT, req, res, next);
});
}

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -151,6 +151,7 @@ export default class ChargingStationStorage {
dbParams: DbParams, projectFields?: string[]): Promise<DataResult<ChargingStation>> {
// Debug
const uniqueTimerID = Logging.traceStart(tenantID, MODULE_NAME, 'getChargingStations');
+ let siteAreaLookUpAdded = false;
// Check Tenant
await DatabaseUtils.checkTenant(tenantID);
// Clone before updating the values
@@ -262,6 +263,7 @@ export default class ChargingStationStorage {
if (!Utils.isEmptyArray(params.siteIDs)) {
// TODO: Optimization: Assign SiteID to the charging station object
// Site Area
+ siteAreaLookUpAdded = true;
DatabaseUtils.pushSiteAreaLookupInAggregation({
tenantID, aggregation: aggregation, localField: 'siteAreaID', foreignField: '_id',
asField: 'siteArea', oneToOneCardinality: true
@@ -328,7 +330,7 @@ export default class ChargingStationStorage {
asField: 'connectors.user', oneToOneCardinality: true, objectIDFields: ['createdBy', 'lastChangedBy']
}, { sort: dbParams.sort });
// Site Area
- if (Utils.isEmptyArray(params.siteIDs)) {
+ if (!siteAreaLookUpAdded) {
DatabaseUtils.pushSiteAreaLookupInAggregation({
tenantID, aggregation: aggregation, localField: 'siteAreaID', foreignField: '_id',
asField: 'siteArea', oneToOneCardinality: true

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -416,10 +416,9 @@ export enum ServerRoute {
REST_CHARGING_STATIONS_QRCODE_GENERATE = 'chargingstations/:id/connectors/:connectorId/qrcode/generate',
REST_CHARGING_STATIONS_QRCODE_DOWNLOAD = 'chargingstations/:id/connectors/:connectorId/qrcode/download',
-
- REST_CHARGING_STATIONS_OCPP_PARAMETERS = 'chargingstations/ocpp/parameters',
- REST_CHARGING_STATIONS_OCPP_PARAMETERS_EXPORT = 'chargingstations/:id/ocpp/parameters/export',
- REST_CHARGING_STATION_OCPP_PARAMETERS = 'chargingstations/:id/ocpp/parameters',
+ REST_CHARGING_STATION_GET_OCPP_PARAMETERS = 'chargingstations/:id/ocpp/parameters',
+ REST_CHARGING_STATIONS_REQUEST_OCPP_PARAMETERS = 'chargingstations/ocpp/parameters',
+ REST_CHARGING_STATIONS_EXPORT_OCPP_PARAMETERS = 'chargingstations/:id/ocpp/parameters/export',
REST_CHARGING_STATIONS_PARAMETERS = 'chargingstations/general/parameters',
REST_CHARGING_STATIONS_POWER_LIMIT = 'chargingstations/power/limit',
REST_CHARGING_STATIONS_TRANSACTIONS = 'chargingstations/:id/transactions',

Updated OCPP Params handling