Filter connector charging station
MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1291,6 +1291,7 @@ export default class ChargingStationService {
chargingStationIDs: filteredRequest.ChargeBoxID ? filteredRequest.ChargeBoxID.split('|') : null,
connectorStatuses: filteredRequest.ConnectorStatus ? filteredRequest.ConnectorStatus.split('|') : null,
connectorTypes: filteredRequest.ConnectorType ? filteredRequest.ConnectorType.split('|') : null,
+ connectorIDs: filteredRequest.ConnectorID ? filteredRequest.ConnectorID.split('|').map((connectorID) => Utils.convertToInt(connectorID)) : null,
issuer: filteredRequest.Issuer,
siteIDs: Authorizations.getAuthorizedSiteIDs(req.user, filteredRequest.SiteID ? filteredRequest.SiteID.split('|') : null),
siteAreaIDs: filteredRequest.SiteAreaID ? filteredRequest.SiteAreaID.split('|') : null,

MODIFY
src/server/rest/v1/service/security/ChargingStationSecurity.ts
src/server/rest/v1/service/security/ChargingStationSecurity.ts
@@ -87,6 +87,7 @@ export default class ChargingStationSecurity {
filteredRequest.SiteID = sanitize(request.SiteID);
filteredRequest.WithSite = UtilsSecurity.filterBoolean(request.WithSite);
filteredRequest.SiteAreaID = sanitize(request.SiteAreaID);
+ filteredRequest.ConnectorID = sanitize(request.ConnectorID);
filteredRequest.ConnectorStatus = sanitize(request.ConnectorStatus);
filteredRequest.ConnectorType = sanitize(request.ConnectorType);
filteredRequest.ChargeBoxID = sanitize(request.ChargeBoxID);

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -146,7 +146,7 @@ export default class ChargingStationStorage {
search?: string; chargingStationIDs?: string[]; siteAreaIDs?: string[]; withNoSiteArea?: boolean;
connectorStatuses?: string[]; connectorTypes?: string[]; statusChangedBefore?: Date;
siteIDs?: string[]; withSite?: boolean; includeDeleted?: boolean; offlineSince?: Date; issuer?: boolean;
- locCoordinates?: number[]; locMaxDistanceMeters?: number;
+ locCoordinates?: number[]; locMaxDistanceMeters?: number; connectorIDs?: number[];
},
dbParams: DbParams, projectFields?: string[]): Promise<DataResult<ChargingStation>> {
// Debug
@@ -213,6 +213,23 @@ export default class ChargingStationStorage {
aggregation.push({
$match: filters
});
+ // Connector ID
+ if (params.connectorIDs) {
+ filters['connectors.connectorId'] = { $in: params.connectorIDs };
+ aggregation.push({
+ '$addFields': {
+ 'connectors': {
+ '$filter': {
+ input: '$connectors',
+ as: 'connector',
+ cond: {
+ $in: ['$$connector.connectorId', params.connectorIDs]
+ }
+ }
+ }
+ }
+ });
+ }
// Connector Status
if (params.connectorStatuses) {
filters['connectors.status'] = { $in: params.connectorStatuses };

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -43,6 +43,7 @@ export interface HttpChargingStationsRequest extends HttpDatabaseRequest {
ErrorType?: string;
LocCoordinates?: number[];
LocMaxDistanceMeters?: number;
+ ConnectorID?: string;
}
export interface HttpChargingStationParamsUpdateRequest {

Filter connector charging station