Use human readable name for OCPI Site Area
MODIFY
src/client/ocpi/EmspOCPIClient.ts
src/client/ocpi/EmspOCPIClient.ts
@@ -136,8 +136,6 @@ export default class EmspOCPIClient extends OCPIClient {
const company = await OCPIUtils.checkAndGetEMSPCompany(this.tenant, this.ocpiEndpoint);
const sites = await SiteStorage.getSites(this.tenant,
{ companyIDs: [ company.id ] }, Constants.DB_PARAMS_MAX_LIMIT);
- const siteAreas = await SiteAreaStorage.getSiteAreas(this.tenant,
- { companyIDs: [ company.id ] }, Constants.DB_PARAMS_MAX_LIMIT);
let nextResult = true;
do {
// Call IOP
@@ -161,11 +159,10 @@ export default class EmspOCPIClient extends OCPIClient {
const foundSite = sites.result.find((existingSite) => existingSite.name === siteName);
const site = await OCPIUtils.processEMSPLocationSite(
this.tenant, location, company, foundSite, siteName);
+ // Get Site Area
+ const foundSiteArea = await SiteAreaStorage.getSiteAreaByOcpiLocationUid(this.tenant, location.id);
// Process Site Area
- const siteAreaName = `${location.operator.name}${Constants.OCPI_SEPARATOR}${location.id}`;
- const foundSiteArea = siteAreas.result.find((existingSiteArea) => existingSiteArea.name === siteAreaName);
- const siteArea = await OCPIUtils.processEMSPLocationSiteArea(
- this.tenant, location, site, foundSiteArea);
+ const siteArea = await OCPIUtils.processEMSPLocationSiteArea(this.tenant, location, site, foundSiteArea);
// Process Charging Station
await OCPIUtils.processEMSPLocationChargingStations(
this.tenant, location, site, siteArea, evses, ServerAction.OCPI_PULL_LOCATIONS);

MODIFY
src/server/ocpi/OCPIUtils.ts
src/server/ocpi/OCPIUtils.ts
@@ -134,10 +134,6 @@ export default class OCPIUtils {
return `${countryCode}*${partyId}`;
}
- public static buildSiteAreaName(countryCode: string, partyId: string, locationId: string): string {
- return `${countryCode}*${partyId}-${locationId}`;
- }
-
public static buildEvseUIDs(chargingStation: ChargingStation): string[] {
const evseUIDs: string[] = [];
for (const connector of chargingStation.connectors) {
@@ -485,16 +481,14 @@ export default class OCPIUtils {
public static async processEMSPLocationSiteArea(tenant: Tenant, location: OCPILocation, site: Site, siteArea: SiteArea): Promise<SiteArea> {
// Create Site Area
if (!siteArea) {
- const siteAreaName = `${site.name}${Constants.OCPI_SEPARATOR}${location.id}`;
siteArea = {
- name: siteAreaName,
+ name: location.name,
createdOn: new Date(),
siteID: site.id,
issuer: false,
ocpiData: { location },
address: {
address1: location.address,
- address2: location.name,
postalCode: location.postal_code,
city: location.city,
country: location.country,
@@ -504,12 +498,12 @@ export default class OCPIUtils {
} else {
siteArea = {
...siteArea,
+ name: location.name,
lastChangedOn: new Date(),
siteID: site.id,
ocpiData: { location },
address: {
address1: location.address,
- address2: location.name,
postalCode: location.postal_code,
city: location.city,
country: location.country,

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/emsp/EMSPLocationsEndpoint.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/emsp/EMSPLocationsEndpoint.ts
import { NextFunction, Request, Response } from 'express';
-import { StatusCodes } from 'http-status-codes';
-import _ from 'lodash';
+
+import AbstractEndpoint from '../../AbstractEndpoint';
+import AbstractOCPIService from '../../../AbstractOCPIService';
import AppError from '../../../../../exception/AppError';
import ChargingStationStorage from '../../../../../storage/mongodb/ChargingStationStorage';
-import SiteAreaStorage from '../../../../../storage/mongodb/SiteAreaStorage';
import Company from '../../../../../types/Company';
import { HTTPError } from '../../../../../types/HTTPError';
+import LoggingHelper from '../../../../../utils/LoggingHelper';
import { OCPIConnector } from '../../../../../types/ocpi/OCPIConnector';
import OCPIEndpoint from '../../../../../types/ocpi/OCPIEndpoint';
import { OCPIEvse } from '../../../../../types/ocpi/OCPIEvse';
import { OCPILocation } from '../../../../../types/ocpi/OCPILocation';
import { OCPIResponse } from '../../../../../types/ocpi/OCPIResponse';
import { OCPIStatusCode } from '../../../../../types/ocpi/OCPIStatusCode';
+import OCPIUtils from '../../../OCPIUtils';
import { ServerAction } from '../../../../../types/Server';
import Site from '../../../../../types/Site';
import SiteArea from '../../../../../types/SiteArea';
+import SiteAreaStorage from '../../../../../storage/mongodb/SiteAreaStorage';
+import { StatusCodes } from 'http-status-codes';
import Tenant from '../../../../../types/Tenant';
-import LoggingHelper from '../../../../../utils/LoggingHelper';
import Utils from '../../../../../utils/Utils';
-import AbstractOCPIService from '../../../AbstractOCPIService';
-import OCPIUtils from '../../../OCPIUtils';
-import AbstractEndpoint from '../../AbstractEndpoint';
-
+import _ from 'lodash';
const MODULE_NAME = 'EMSPLocationsEndpoint';

Use human readable name for OCPI Site Area