split ChangeAvailability
ADD
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-change-availability.json
+{
+ "title": "Change Charging Station availability (endpoint)",
+ "type": "object",
+ "properties": {
+ "chargingStationID": {
+ "$ref": "chargingstation.json#/definitions/id"
+ },
+ "args": {
+ "type": "object",
+ "properties": {
+ "connectorId": {
+ "$ref": "chargingstation.json#/definitions/connector/properties/connectorId"
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": [
+ "Inoperative",
+ "Operative"
+ ]
+ }
+ },
+ "required": [
+ "connectorId",
+ "type"
+ ]
+ }
+ },
+ "required": [
+ "chargingStationID"
+ ]
+}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1174,6 +1174,12 @@ export default class ChargingStationService {
result = await ChargingStationService.executeChargingStationCommand(
req.tenant, req.user, chargingStation, action, command, filteredRequest.args);
break;
+ // Change Availability
+ case Command.CHANGE_AVAILABILITY:
+ filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionChangeAvailabilityReq(req.body);
+ result = await ChargingStationService.executeChargingStationCommand(
+ req.tenant, req.user, chargingStation, action, command, filteredRequest.args);
+ break;
// Remote Stop Transaction / Unlock Connector
case Command.REMOTE_STOP_TRANSACTION:
filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionStopTransactionReq(req.body);

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
-import { HttpChargingProfilesRequest, HttpChargingStationClearCacheRequest, HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetCompositeScheduleRequest, HttpChargingStationGetDiagnosticsRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationResetRequest, HttpChargingStationStartTransactionRequest, HttpChargingStationStopTransactionRequest, HttpChargingStationUpdateFirmwareRequest, HttpChargingStationsInErrorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
+import { HttpChargingProfilesRequest, HttpChargingStationChangeAvailabilityRequest, HttpChargingStationClearCacheRequest, HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetCompositeScheduleRequest, HttpChargingStationGetDiagnosticsRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationResetRequest, HttpChargingStationStartTransactionRequest, HttpChargingStationStopTransactionRequest, HttpChargingStationUpdateFirmwareRequest, HttpChargingStationsInErrorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
import { ChargingProfile } from '../../../../types/ChargingProfile';
import HttpDatabaseRequest from '../../../../types/requests/HttpDatabaseRequest';
@@ -13,6 +13,7 @@ export default class ChargingStationValidator extends SchemaValidator {
private chargingStationGet: Schema;
private chargingStationDelete: Schema;
private chargingStationAction: Schema;
+ private chargingStationActionChangeAvailability: Schema;
private chargingStationActionClearCache: Schema;
private chargingStationActionStartTransaction: Schema;
private chargingStationActionStopTransaction: Schema;
@@ -41,6 +42,7 @@ export default class ChargingStationValidator extends SchemaValidator {
this.chargingStationGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-get.json`, 'utf8'));
this.chargingStationDelete = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-delete.json`, 'utf8'));
this.chargingStationAction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action.json`, 'utf8'));
+ this.chargingStationActionChangeAvailability = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-change-availability.json`, 'utf8'));
this.chargingStationActionClearCache = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-clear-cache.json`, 'utf8'));
this.chargingStationActionStartTransaction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-start-transaction.json`, 'utf8'));
this.chargingStationActionStopTransaction = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-stop-transaction.json`, 'utf8'));
@@ -95,6 +97,12 @@ export default class ChargingStationValidator extends SchemaValidator {
return data;
}
+ public validateChargingStationActionChangeAvailabilityReq(data: any): HttpChargingStationChangeAvailabilityRequest {
+ // Validate schema for ChangeAvailability
+ this.validate(this.chargingStationActionChangeAvailability, data);
+ return data;
+ }
+
public validateChargingStationActionClearCacheReq(data: any): HttpChargingStationClearCacheRequest {
// Validate schema for ClearCache
this.validate(this.chargingStationActionClearCache, data);

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -113,6 +113,14 @@ export interface HttpChargingStationCommandRequest {
args?: any;
}
+export interface HttpChargingStationChangeAvailabilityRequest {
+ chargingStationID: string,
+ args: {
+ connectorId: string,
+ type: string
+ }
+}
+
export interface HttpChargingStationClearCacheRequest {
chargingStationID: string
}

split ChangeAvailability