Added triggerSmartcharging endpoint + doc
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"$ref": "#/components/parameters/SiteID"
},
{
- "$ref": "#/components/parameters/SiteAreaID"
+ "$ref": "#/components/parameters/SiteAreaIDs"
},
{
"$ref": "#/components/parameters/InactivityStatus"
"$ref": "#/components/parameters/WithSite"
},
{
- "$ref": "#/components/parameters/SiteAreaID"
+ "$ref": "#/components/parameters/SiteAreaIDs"
},
{
"$ref": "#/components/parameters/ConnectorStatus"
"$ref": "#/components/parameters/SiteID"
},
{
- "$ref": "#/components/parameters/SiteAreaID"
+ "$ref": "#/components/parameters/SiteAreaIDs"
},
{
"in": "query",
"$ref": "#/components/parameters/SiteID"
},
{
- "$ref": "#/components/parameters/SiteAreaID"
+ "$ref": "#/components/parameters/SiteAreaIDs"
},
{
"$ref": "#/components/parameters/ErrorType"
"$ref": "#/components/parameters/WithSite"
},
{
- "$ref": "#/components/parameters/SiteAreaID"
+ "$ref": "#/components/parameters/SiteAreaIDs"
},
{
"$ref": "#/components/parameters/ConnectorStatus"
}
}
},
+ "/api/chargingstations/smartcharging/trigger": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Trigger smart charging",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/SiteAreaID"
+ }
+ ],
+ "tags": [
+ "Charging Stations"
+ ],
+ "responses": {
+ "200": {
+ "description": "Smart Charging triggered successfully on site area"
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ }
+ }
+ }
+ },
"/api/chargingprofiles": {
"get": {
"security": [
}
},
"SiteAreaID": {
+ "in": "query",
+ "name": "SiteAreaID",
+ "description": "Site Area ID",
+ "schema": {
+ "type": "string"
+ }
+ },
+ "SiteAreaIDs": {
"in": "query",
"name": "SiteAreaID",
"description": "Pipe separated Site Area IDs",

MODIFY
src/server/rest/v1/router/api/ChargingStationRouter.ts
src/server/rest/v1/router/api/ChargingStationRouter.ts
@@ -42,6 +42,7 @@ export default class ChargingStationRouter {
this.buildRouteChargingStationUpdateParameters();
this.buildRouteChargingStationLimitPower();
this.buildRouteChargingStationCheckSmartCharging();
+ this.buildRouteChargingStationTriggerSmartCharging();
return this.router;
}
@@ -208,6 +209,12 @@ export default class ChargingStationRouter {
});
}
+ protected buildRouteChargingStationTriggerSmartCharging(): void {
+ this.router.get(`/${ServerRoute.REST_CHARGING_STATION_TRIGGER_SMART_CHARGING}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(ChargingStationService.handleTriggerSmartCharging.bind(this), ServerAction.TRIGGER_SMART_CHARGING, req, res, next);
+ });
+ }
+
protected buildRouteChargingStationGetChargingProfiles(): void {
this.router.get(`/${ServerRoute.REST_CHARGING_PROFILES}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(ChargingStationService.handleGetChargingProfiles.bind(this), ServerAction.CHARGING_PROFILES, req, res, next);

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -95,7 +95,7 @@ export default class ChargingStationService {
await ocpiClient.removeChargingStation(chargingStation);
}
} catch (error) {
- Logging.logError({
+ await Logging.logError({
tenantID: req.user.tenantID,
module: MODULE_NAME, method: 'handleUpdateChargingStationParams',
action: action,
@@ -180,7 +180,7 @@ export default class ChargingStationService {
// Update
await ChargingStationStorage.saveChargingStation(req.user.tenantID, chargingStation);
// Log
- Logging.logSecurityInfo({
+ await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
source: chargingStation.id, action: action,
user: req.user, module: MODULE_NAME,
@@ -303,7 +303,7 @@ export default class ChargingStationService {
});
}
// Log
- Logging.logWarning({
+ await Logging.logWarning({
tenantID: req.user.tenantID,
source: chargingStation.id,
action: action,
@@ -331,7 +331,7 @@ export default class ChargingStationService {
user: req.user
});
}
- Logging.logInfo({
+ await Logging.logInfo({
tenantID: req.user.tenantID,
source: chargingStation.id,
action: action,
@@ -400,10 +400,10 @@ export default class ChargingStationService {
Action.UPDATE, Entity.SITE_AREA, MODULE_NAME, 'handleTriggerSmartCharging');
// Filter
const filteredRequest = ChargingStationSecurity.filterTriggerSmartCharging(req.query);
- UtilsService.assertIdIsProvided(action, filteredRequest.siteAreaID, MODULE_NAME, 'handleTriggerSmartCharging', req.user);
+ UtilsService.assertIdIsProvided(action, filteredRequest.SiteAreaID, MODULE_NAME, 'handleTriggerSmartCharging', req.user);
// Get Site Area
- const siteArea = await SiteAreaStorage.getSiteArea(req.user.tenantID, filteredRequest.siteAreaID);
- UtilsService.assertObjectExists(action, siteArea, `Site Area '${filteredRequest.siteAreaID}' does not exist`,
+ const siteArea = await SiteAreaStorage.getSiteArea(req.user.tenantID, filteredRequest.SiteAreaID);
+ UtilsService.assertObjectExists(action, siteArea, `Site Area '${filteredRequest.SiteAreaID}' does not exist`,
MODULE_NAME, 'handleTriggerSmartCharging', req.user);
// Check auth
if (!Authorizations.canUpdateSiteArea(req.user, siteArea.siteID)) {
@@ -412,7 +412,7 @@ export default class ChargingStationService {
user: req.user,
action: Action.UPDATE, entity: Entity.SITE_AREA,
module: MODULE_NAME, method: 'handleTriggerSmartCharging',
- value: filteredRequest.siteAreaID
+ value: filteredRequest.SiteAreaID
});
}
// Call Smart Charging
@@ -745,7 +745,7 @@ export default class ChargingStationService {
await ChargingStationStorage.deleteChargingStation(req.user.tenantID, chargingStation.id);
}
// Log
- Logging.logSecurityInfo({
+ await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
user: req.user, module: MODULE_NAME, method: 'handleDeleteChargingStation',
message: `Charging Station '${chargingStation.id}' has been deleted successfully`,
@@ -1524,7 +1524,7 @@ export default class ChargingStationService {
result.status === OCPPConfigurationStatus.REBOOT_REQUIRED) {
// Reboot?
if (result.status === OCPPConfigurationStatus.REBOOT_REQUIRED) {
- Logging.logWarning({
+ await Logging.logWarning({
tenantID: tenantID,
source: chargingStation.id,
user: user,
@@ -1623,7 +1623,7 @@ export default class ChargingStationService {
if (result) {
// OCPP Command with status
if (Utils.objectHasProperty(result, 'status') && ![OCPPStatus.ACCEPTED, OCPPUnlockStatus.UNLOCKED].includes(result.status)) {
- Logging.logError({
+ await Logging.logError({
tenantID: tenantID,
source: chargingStation.id,
user: user,
@@ -1634,7 +1634,7 @@ export default class ChargingStationService {
});
} else {
// OCPP Command with no status
- Logging.logInfo({
+ await Logging.logInfo({
tenantID: tenantID,
source: chargingStation.id,
user: user,

MODIFY
src/server/rest/v1/service/security/ChargingStationSecurity.ts
src/server/rest/v1/service/security/ChargingStationSecurity.ts
@@ -45,7 +45,7 @@ export default class ChargingStationSecurity {
public static filterTriggerSmartCharging(request: any): HttpTriggerSmartChargingRequest {
return {
- siteAreaID: sanitize(request.SiteAreaID)
+ SiteAreaID: sanitize(request.SiteAreaID)
};
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -432,6 +432,7 @@ export enum ServerRoute {
REST_CHARGING_STATIONS_EXPORT = 'chargingstations/export',
REST_CHARGING_STATION_CHECK_SMART_CHARGING_CONNECTION = 'chargingstations/smartcharging/connection/check',
+ REST_CHARGING_STATION_TRIGGER_SMART_CHARGING = 'chargingstations/smartcharging/trigger',
REST_CHARGING_PROFILES = 'chargingprofiles',
REST_CHARGING_PROFILE = 'chargingprofiles/:id',

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -4,7 +4,7 @@ import HttpByIDRequest from './HttpByIDRequest';
import HttpDatabaseRequest from './HttpDatabaseRequest';
export interface HttpTriggerSmartChargingRequest {
- siteAreaID: string;
+ SiteAreaID: string;
}
export interface HttpChargingStationLimitPowerRequest {

MODIFY
test/api/client/SmartChargingApi.ts
test/api/client/SmartChargingApi.ts
import CrudApi from './utils/CrudApi';
+import { ServerRoute } from '../../types/Server';
import TestConstants from './utils/TestConstants';
export default class SmartChargingApi extends CrudApi {
@@ -7,14 +8,14 @@ export default class SmartChargingApi extends CrudApi {
}
public async testConnection(params?, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
- return await super.readAll(params, paging, ordering, '/client/api/CheckSmartChargingConnection');
+ return await super.readAll(params, paging, ordering, `/v1/api/${ServerRoute.REST_CHARGING_STATION_CHECK_SMART_CHARGING_CONNECTION}`);
}
public async getChargingProfiles(params?, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
- return await super.readAll(params, paging, ordering, '/client/api/ChargingProfiles');
+ return await super.readAll(params, paging, ordering, `/v1/api/${ServerRoute.REST_CHARGING_PROFILES}`);
}
public async triggerSmartCharging(params?, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
- return await super.readAll(params, paging, ordering, '/client/api/TriggerSmartCharging');
+ return await super.readAll(params, paging, ordering, `/v1/api/${ServerRoute.REST_CHARGING_STATION_TRIGGER_SMART_CHARGING}`);
}
}

Added triggerSmartcharging endpoint + doc