Do not expose smart charging settings
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
},
{
"$ref": "#/components/parameters/ChargingStationID"
+ },
+ {
+ "$ref": "#/components/parameters/ConnectorID"
}
],
"tags": [

MODIFY
src/assets/server/rest/v1/schemas/user/user-session-context-get.json
src/assets/server/rest/v1/schemas/user/user-session-context-get.json
"ChargingStationID": {
"$ref": "chargingstation#/definitions/id"
},
+ "ConnectorID": {
+ "$ref": "chargingstation#/definitions/connector/properties/connectorId"
+ },
"ProjectFields": {
"$ref": "common#/definitions/projectFields"
}
},
"required": [
"UserID",
- "ChargingStationID"
+ "ChargingStationID",
+ "ConnectorID"
]
}

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -6,6 +6,7 @@ import { Car, CarType } from '../../../../types/Car';
import { DataResult, UserDataResult, UserSiteDataResult } from '../../../../types/DataResult';
import { HTTPAuthError, HTTPError } from '../../../../types/HTTPError';
import { NextFunction, Request, Response } from 'express';
+import { SmartChargingSessionParameters, StartTransactionErrorCode } from '../../../../types/Transaction';
import Tenant, { TenantComponents } from '../../../../types/Tenant';
import User, { ImportedUser, UserRequiredImportProperties, UserRole } from '../../../../types/User';
@@ -17,6 +18,7 @@ import BillingFactory from '../../../../integration/billing/BillingFactory';
import CSVError from 'csvtojson/v2/CSVError';
import CarStorage from '../../../../storage/mongodb/CarStorage';
import Constants from '../../../../utils/Constants';
+import { CurrentType } from '../../../../types/ChargingStation';
import EmspOCPIClient from '../../../../client/ocpi/EmspOCPIClient';
import { HttpUsersGetRequest } from '../../../../types/requests/HttpUserRequest';
import JSONStream from 'JSONStream';
@@ -28,11 +30,9 @@ import OCPIClientFactory from '../../../../client/ocpi/OCPIClientFactory';
import { OCPIRole } from '../../../../types/ocpi/OCPIRole';
import { OCPITokenWhitelist } from '../../../../types/ocpi/OCPIToken';
import OCPIUtils from '../../../ocpi/OCPIUtils';
-import { PrioritizationParameters } from '../../../../types/Setting';
import { Readable } from 'stream';
import { ServerAction } from '../../../../types/Server';
import SettingStorage from '../../../../storage/mongodb/SettingStorage';
-import { StartTransactionErrorCode } from '../../../../types/Transaction';
import { StatusCodes } from 'http-status-codes';
import Tag from '../../../../types/Tag';
import TagStorage from '../../../../storage/mongodb/TagStorage';
@@ -99,18 +99,28 @@ export default class UserService {
// Check for the billing prerequisites (such as the user's payment method)
await UserService.checkBillingErrorCodes(action, req.tenant, req.user, user, errorCodes);
}
- const settingAuthorization = await AuthorizationService.checkAndGetSettingAuthorizations(req.tenant, req.user, Action.READ);
- let prioritizationParameters: PrioritizationParameters;
+ let smartChargingSessionParameters: SmartChargingSessionParameters = null;
// Handle Smart Charging
- if (chargingStation.siteArea?.smartCharging && !chargingStation.excludeFromSmartCharging && settingAuthorization.authorized
+ if (chargingStation.siteArea?.smartCharging && !chargingStation.excludeFromSmartCharging
&& chargingStation.capabilities.supportChargingProfiles && Utils.isComponentActiveFromToken(req.user, TenantComponents.SMART_CHARGING)) {
const smartChargingSettings = await SettingStorage.getSmartChargingSettings(req.tenant);
- if (smartChargingSettings.sapSmartCharging.prioritizationParameters?.active) {
- prioritizationParameters = smartChargingSettings.sapSmartCharging.prioritizationParameters;
+ if (smartChargingSettings.sapSmartCharging.prioritizationParametersActive) {
+ // Default values are hard coded for now
+ smartChargingSessionParameters = {
+ departureTime: 18,
+ carStateOfCharge: 30,
+ targetStateOfCharge: 70,
+ };
+ if (Utils.getChargingStationCurrentType(chargingStation, null, filteredRequest.ConnectorID) === CurrentType.DC) {
+ smartChargingSessionParameters.departureTime = null;
+ smartChargingSessionParameters.carStateOfCharge = null;
+ } else if (car.carConnectorData?.carConnectorMeterID) {
+ smartChargingSessionParameters.carStateOfCharge = null;
+ }
}
}
res.json({
- tag, car, errorCodes, prioritizationParameters
+ tag, car, errorCodes, smartChargingSessionParameters
});
next();
}

MODIFY
src/storage/mongodb/SettingStorage.ts
src/storage/mongodb/SettingStorage.ts
@@ -279,12 +279,7 @@ export default class SettingStorage {
stickyLimitation: config.sapSmartCharging.stickyLimitation ? config.sapSmartCharging.stickyLimitation : false,
limitBufferDC: config.sapSmartCharging.limitBufferDC ? config.sapSmartCharging.limitBufferDC : 0,
limitBufferAC: config.sapSmartCharging.limitBufferAC ? config.sapSmartCharging.limitBufferAC : 0,
- prioritizationParameters: {
- active: config.sapSmartCharging.prioritizationParameters?.active ?? false,
- defaultSessionTimeHours: config.sapSmartCharging.prioritizationParameters?.defaultSessionTimeHours ?? null,
- defaultInitialStateOfCharge: config.sapSmartCharging.prioritizationParameters?.defaultInitialStateOfCharge ?? null,
- defaultTargetStateOfCharge: config.sapSmartCharging.prioritizationParameters?.defaultTargetStateOfCharge ?? null
- }
+ prioritizationParametersActive: config.sapSmartCharging.prioritizationParametersActive ?? false,
};
}
}

MODIFY
src/types/Setting.ts
src/types/Setting.ts
@@ -207,14 +207,7 @@ export interface SapSmartChargingSetting extends SmartChargingSetting {
stickyLimitation: boolean;
limitBufferDC: number;
limitBufferAC: number;
- prioritizationParameters: PrioritizationParameters;
-}
-
-export interface PrioritizationParameters {
- active: boolean;
- defaultSessionTimeHours: number;
- defaultInitialStateOfCharge: number;
- defaultTargetStateOfCharge: number;
+ prioritizationParametersActive?: boolean;
}
export enum RefundSettingsType {

MODIFY
src/types/Transaction.ts
src/types/Transaction.ts
@@ -207,3 +207,9 @@ export interface CollectedFundReport {
totalDurationSecs: number,
transactionIDs: number[],
}
+
+export interface SmartChargingSessionParameters {
+ departureTime: number,
+ carStateOfCharge: number,
+ targetStateOfCharge: number,
+}

MODIFY
src/types/requests/HttpUserRequest.ts
src/types/requests/HttpUserRequest.ts
@@ -120,4 +120,5 @@ export interface HttpUserDefaultTagCarGetRequest {
export interface HttpUserSessionContextGetRequest {
UserID: string;
ChargingStationID: string;
+ ConnectorID: number;
}

MODIFY
test/api/client/UserApi.ts
test/api/client/UserApi.ts
@@ -63,6 +63,6 @@ export default class UserApi extends CrudApi {
public async getUserSessionContext(params) {
const url = this.buildRestEndpointUrl(RESTServerRoute.REST_USER_SESSION_CONTEXT, { id: params.userID });
- return super.read({ ChargingStationID: params.chargingStationID }, url);
+ return super.read({ ChargingStationID: params.chargingStationID, ConnectorID: params.ConnectorID }, url);
}
}

MODIFY
test/api/context/ContextDefinition.ts
test/api/context/ContextDefinition.ts
@@ -184,13 +184,7 @@ export default class ContextDefinition {
password: '',
stickyLimitation: true,
limitBufferDC: 20,
- limitBufferAC: 10,
- prioritizationParameters:{
- active: false,
- defaultSessionTimeHours: 8,
- defaultInitialStateOfCharge: 20,
- defaultTargetStateOfCharge: 80,
- }
+ limitBufferAC: 10
}
}
},
@@ -368,13 +362,7 @@ export default class ContextDefinition {
password: '',
stickyLimitation: true,
limitBufferDC: 20,
- limitBufferAC: 10,
- prioritizationParameters:{
- active: false,
- defaultSessionTimeHours: 8,
- defaultInitialStateOfCharge: 20,
- defaultTargetStateOfCharge: 80,
- }
+ limitBufferAC: 10
}
}
},

Do not expose smart charging settings