Do not push OCPI Locations (Sites) if there is no public Charging Station
MODIFY
src/client/ocpi/CpoOCPIClient.ts
src/client/ocpi/CpoOCPIClient.ts
@@ -745,7 +745,7 @@ export default class CpoOCPIClient extends OCPIClient {
};
// Define get option
const options = {
- 'addChargeBoxID': true,
+ addChargeBoxID: true,
countryID: this.getLocalCountryCode(ServerAction.OCPI_CHECK_LOCATIONS),
partyID: this.getLocalPartyID(ServerAction.OCPI_CHECK_LOCATIONS)
};

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/OCPIMapping.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/OCPIMapping.ts
@@ -8,6 +8,7 @@ import { OCPIToken, OCPITokenType, OCPITokenWhitelist } from '../../../../types/
import { PricingSettings, PricingSettingsType, SimplePricingSetting } from '../../../../types/Setting';
import { ChargePointStatus } from '../../../../types/ocpp/OCPPServer';
+import ChargingStationStorage from '../../../../storage/mongodb/ChargingStationStorage';
import Configuration from '../../../../utils/Configuration';
import Constants from '../../../../utils/Constants';
import Consumption from '../../../../types/Consumption';
@@ -164,10 +165,29 @@ export default class OCPIMapping {
const sites = await SiteStorage.getSites(tenant.id, { issuer: true, withOnlyChargingStations: true }, { limit, skip });
// Convert Sites to Locations
for (const site of sites.result) {
+ let foundPublicChargingStation = false;
+ // Site with Charging Station only
+ const siteAreas = await SiteAreaStorage.getSiteAreas(tenant.id, { withChargingStations: true }, Constants.DB_PARAMS_MAX_LIMIT);
+ if (siteAreas) {
+ for (const siteArea of siteAreas.result) {
+ if (siteArea.chargingStations) {
+ for (const chargingStation of siteArea.chargingStations) {
+ // Take into account this site?
+ if (chargingStation.public) {
+ foundPublicChargingStation = true;
ocpiLocationsResult.result.push(await OCPIMapping.convertSite2Location(tenant, site, options));
+ break;
+ }
+ }
+ }
+ if (foundPublicChargingStation) {
+ break;
+ }
+ }
+ }
}
// Set count
- ocpiLocationsResult.count = sites.count;
+ ocpiLocationsResult.count = ocpiLocationsResult.result.length;
// Return locations
return ocpiLocationsResult;
}

Do not push OCPI Locations (Sites) if there is no public Charging Station