Lint remarks changed
MODIFY
src/client/oicp/CpoOICPClient.ts
src/client/oicp/CpoOICPClient.ts
@@ -1170,10 +1170,10 @@ export default class CpoOICPClient extends OICPClient {
const response = await this.axiosInstance.post(fullUrl, payload);
console.log('Success! sendChargingNotificationError: ', response); // Will be removed
notificationErrorResponse = response.data;
- } catch (error) {
- console.log('Error! sendChargingNotificationError: ', error.response); // Will be removed
- notificationErrorResponse = error.response?.data;
- requestError = error;
+ } catch (errors) {
+ console.log('Error! sendChargingNotificationError: ', errors.response); // Will be removed
+ notificationErrorResponse = errors.response?.data;
+ requestError = errors;
}
if (!notificationErrorResponse?.Result || notificationErrorResponse?.Result !== true) {
Logging.logError({
@@ -1193,21 +1193,6 @@ export default class CpoOICPClient extends OICPClient {
return notificationErrorResponse;
}
- // Get ChargeBoxIds with new status notifications
- private async getChargeBoxIDsWithNewStatusNotifications(): Promise<string[]> {
- // Get last job
- const lastPatchJobOn = this.oicpEndpoint.lastPatchJobOn ? this.oicpEndpoint.lastPatchJobOn : new Date();
- // Build params
- const params = { 'dateFrom': lastPatchJobOn };
- // Get last status notifications
- const statusNotificationsResult = await OCPPStorage.getStatusNotifications(this.tenant.id, params, Constants.DB_PARAMS_MAX_LIMIT);
- // Loop through notifications
- if (statusNotificationsResult.count > 0) {
- return statusNotificationsResult.result.map((statusNotification) => statusNotification.chargeBoxID);
- }
- return [];
- }
-
/**
* Ping OICP Endpoint
*/
@@ -1270,4 +1255,20 @@ export default class CpoOICPClient extends OICPClient {
}
return false;
}
+
+ // Get ChargeBoxIds with new status notifications
+ private async getChargeBoxIDsWithNewStatusNotifications(): Promise<string[]> {
+ // Get last job
+ const lastPatchJobOn = this.oicpEndpoint.lastPatchJobOn ? this.oicpEndpoint.lastPatchJobOn : new Date();
+ // Build params
+ const params = { 'dateFrom': lastPatchJobOn };
+ // Get last status notifications
+ const statusNotificationsResult = await OCPPStorage.getStatusNotifications(this.tenant.id, params, Constants.DB_PARAMS_MAX_LIMIT);
+ // Loop through notifications
+ if (statusNotificationsResult.count > 0) {
+ return statusNotificationsResult.result.map((statusNotification) => statusNotification.chargeBoxID);
+ }
+ return [];
+ }
+
}

MODIFY
src/client/oicp/OICPClient.ts
src/client/oicp/OICPClient.ts
@@ -117,8 +117,6 @@ export default abstract class OICPClient {
return registerResult;
}
- public abstract ping();
-
protected getEndpointUrl(service: string, action: ServerAction): string {
if (this.oicpEndpoint.availableEndpoints) {
const baseURL = this.oicpEndpoint.baseUrl;
@@ -184,4 +182,6 @@ export default abstract class OICPClient {
});
return httpsAgent;
}
+
+ public abstract ping();
}

MODIFY
src/server/oicp/OICPUtils.ts
src/server/oicp/OICPUtils.ts
@@ -205,25 +205,17 @@ export default class OICPUtils {
// CPO
if (roamingSettings.oicp.cpo?.key !== oicpSetting.cpo.key) {
oicpSetting.cpo.key = sanitize(Cypher.encrypt(oicpSetting.cpo.key));
- } else {
- oicpSetting.cpo.key = oicpSetting.cpo.key;
}
if (roamingSettings.oicp.cpo?.cert !== oicpSetting.cpo.cert) {
oicpSetting.cpo.cert = sanitize(Cypher.encrypt(oicpSetting.cpo.cert));
- } else {
- oicpSetting.cpo.cert = oicpSetting.cpo.cert;
}
// EMSP
if (roamingSettings.oicp.emsp?.key !== oicpSetting.emsp.key) {
oicpSetting.emsp.key = sanitize(Cypher.encrypt(oicpSetting.emsp.key));
- } else {
- oicpSetting.emsp.key = oicpSetting.emsp.key;
}
if (roamingSettings.oicp.emsp?.cert !== oicpSetting.emsp.cert) {
oicpSetting.emsp.cert = sanitize(Cypher.encrypt(oicpSetting.emsp.cert));
- } else {
- oicpSetting.emsp.cert = oicpSetting.emsp.cert;
}
}

MODIFY
src/server/oicp/oicp-services-impl/oicp-2.3.0/OICPMapping.ts
src/server/oicp/oicp-services-impl/oicp-2.3.0/OICPMapping.ts
@@ -24,25 +24,6 @@ const MODULE_NAME = 'OICPMapping';
* Mainly contains helper functions to convert internal entity to OICP 2.3.0 Entity
*/
export default class OICPMapping {
- /**
- * Convert ChargingStation to Multiple EVSEs
- * @param {Tenant} tenant
- * @param {*} chargingStation
- * @return Array of OICP EVSEs
- */
- private static convertChargingStation2MultipleEvses(tenant: Tenant, siteArea: SiteArea, chargingStation: ChargingStation, chargePoint: ChargePoint, options: { countryID: string; partyID: string; addChargeBoxID?: boolean}): OICPEvseDataRecord[] {
- // Loop through connectors and send one evse per connector
- let connectors: Connector[];
- if (chargePoint) {
- connectors = Utils.getConnectorsFromChargePoint(chargingStation, chargePoint);
- } else {
- connectors = chargingStation.connectors.filter((connector) => connector !== null);
- }
- const evses = connectors.map((connector) => OICPMapping.convertConnector2Evse(tenant, siteArea, chargingStation, connector, options));
- // Return all evses
- return evses;
- }
-
/**
* Get EVSE by connectorID
* @param {Tenant} tenant
@@ -51,7 +32,7 @@ export default class OICPMapping {
*/
public static getEvseByConnectorId(tenant: Tenant, siteArea: SiteArea, chargingStation: ChargingStation, connectorId: number, options: { countryID: string; partyID: string; addChargeBoxID?: boolean}): OICPEvseDataRecord {
// Loop through connectors and send one evse per connector
- const connector = chargingStation.connectors.find((connector) => (connector !== null) && (connector.connectorId === connectorId));
+ const connector = chargingStation.connectors.find((conn) => (conn !== null) && (conn.connectorId === connectorId));
if (connector) {
return OICPMapping.convertConnector2Evse(tenant, siteArea, chargingStation, connector, options);
@@ -59,71 +40,6 @@ export default class OICPMapping {
return null;
}
- /**
- * Convert Connector to OICP EVSE
- * @param {Tenant} tenant
- * @param {*} connector
- * @return EVSE
- */
- private static convertConnector2Evse(tenant: Tenant, siteArea: SiteArea, chargingStation: ChargingStation, connector: Connector, options: { countryID: string; partyID: string; addChargeBoxID?: boolean}): OICPEvseDataRecord {
- const evseID = RoamingUtils.buildEvseID(options.countryID, options.partyID, chargingStation, connector);
- const evse: OICPEvseDataRecord = {} as OICPEvseDataRecord;
- evse.deltaType; // Optional
- evse.lastUpdate; // Optional
- evse.EvseID = evseID;
- evse.ChargingPoolID = OICPMapping.buildEChargingPoolID(options.countryID, options.partyID, siteArea.id); // Optional
- evse.ChargingStationID = chargingStation.id; // Optional
- evse.ChargingStationNames = [
- {
- lang: 'en',
- value: chargingStation.id
- }
- ];
- evse.HardwareManufacturer = chargingStation.chargePointVendor; // Optional
- evse.ChargingStationImage; // Optional
- evse.SubOperatorName; // Optional
- evse.Address = OICPMapping.getOICPAddressIso19773FromSiteArea(siteArea, options.countryID);
- evse.GeoCoordinates = OICPMapping.convertCoordinates2OICPGeoCoordinates(chargingStation.coordinates, OICPGeoCoordinatesResponseFormat.DecimalDegree); // Optional
- evse.Plugs = [OICPMapping.convertConnector2OICPPlug(connector)];
- evse.DynamicPowerLevel; // Optional
- evse.ChargingFacilities = [OICPMapping.convertConnector2OICPChargingFacility(chargingStation, connector)];
- evse.RenewableEnergy = false; // No information found for mandatory field
- evse.EnergySource; // Optional
- evse.EnvironmentalImpact; // Optional
- evse.CalibrationLawDataAvailability = OICPCalibrationLawDataAvailability.NotAvailable; // No information found for mandatory field
- evse.AuthenticationModes = [OICPAuthenticationMode.NfcRfidClassic]; // No information found for mandatory field
- evse.MaxCapacity; // Optional
- evse.PaymentOptions = [OICPPaymentOption.Contract]; // No information found for mandatory field
- evse.ValueAddedServices = [OICPValueAddedService.None]; // No information found for mandatory field
- evse.Accessibility = OICPAccessibility.FreePubliclyAccessible;
- evse.AccessibilityLocation; // Optional
- evse.HotlinePhoneNumber = '+49123123123123'; // No information found for mandatory field
- evse.AdditionalInfo; // Optional
- evse.ChargingStationLocationReference; // Optional
- evse.GeoChargingPointEntrance; // Optional
- evse.IsOpen24Hours = true; // No information found for mandatory field
- evse.OpeningTimes; // Optional
- evse.ClearinghouseID; // Optional
- evse.IsHubjectCompatible = true;
- evse.DynamicInfoAvailable = OICPDynamicInfoAvailable.auto;
- // Return evse
- return evse;
- }
-
- /**
- * Convert ChargingStation to Multiple EVSE Statuses
- * @param {Tenant} tenant
- * @param {*} chargingStation
- * @return Array of OICP EVSE Statuses
- */
- private static convertChargingStation2MultipleEvseStatuses(tenant: Tenant, chargingStation: ChargingStation, options: { countryID: string; partyID: string; addChargeBoxID?: boolean}): OICPEvseStatusRecord[] {
- // Loop through connectors and send one evse per connector
- const connectors = chargingStation.connectors.filter((connector) => connector !== null);
- const evseStatuses = connectors.map((connector) => OICPMapping.convertConnector2EvseStatus(tenant, chargingStation, connector, options));
- // Return all EVSE Statuses
- return evseStatuses;
- }
-
/**
* Convert Connector to EVSE Status
* @param {Tenant} tenant
@@ -167,79 +83,6 @@ export default class OICPMapping {
return evses;
}
- /**
- * Get EVSE Statuses from SiteArea
- * @param {Tenant} tenant
- * @param {SiteArea} siteArea
- * @param options
- * @return Array of OICP EVSE Statuses
- */
- private static async getEvseStatusesFromSiteaArea(tenant: Tenant, siteArea: SiteArea, options: { countryID: string; partyID: string; addChargeBoxID?: boolean }): Promise<OICPEvseStatusRecord[]> {
- // Build evses array
- const evseStatuses: OICPEvseStatusRecord[] = [];
- // Convert charging stations to evse status(es)
- for (const chargingStation of siteArea.chargingStations) {
- if (chargingStation.issuer && chargingStation.public) {
- evseStatuses.push(...OICPMapping.convertChargingStation2MultipleEvseStatuses(tenant, chargingStation, options));
- }
- }
- // Return evses
- return evseStatuses;
- }
-
- /**
- * Get evse statuses from Site
- * @param {Tenant} tenant
- * @param {Site} site
- * @param options
- * @return Array of OICP EVSE Statuses
- */
- private static async getEvseStatusesFromSite(tenant: Tenant, site: Site, options: { countryID: string; partyID: string; addChargeBoxID?: boolean }): Promise<OICPEvseStatusRecord[]> {
- // Build evses array
- const evseStatuses: OICPEvseStatusRecord[] = [];
- const siteAreas = await SiteAreaStorage.getSiteAreas(tenant.id,
- {
- withOnlyChargingStations: true,
- withChargingStations: true,
- siteIDs: [site.id],
- issuer: true
- },
- Constants.DB_PARAMS_MAX_LIMIT);
- for (const siteArea of siteAreas.result) {
- // Get charging station statuses from SiteArea
- evseStatuses.push(...await OICPMapping.getEvseStatusesFromSiteaArea(tenant, siteArea, options));
- }
- // Return evse statuses
- return evseStatuses;
- }
-
- /**
- * Get evses from Site
- * @param {Tenant} tenant
- * @param {Site} site
- * @param options
- * @return Array of OICP EVSEs
- */
- private static async getEvsesFromSite(tenant: Tenant, site: Site, options: { countryID: string; partyID: string; addChargeBoxID?: boolean }): Promise<OICPEvseDataRecord[]> {
- // Build evses array
- const evses = [];
- const siteAreas = await SiteAreaStorage.getSiteAreas(tenant.id,
- {
- withOnlyChargingStations: true,
- withChargingStations: true,
- withSite: true,
- siteIDs: [site.id],
- issuer: true
- },
- Constants.DB_PARAMS_MAX_LIMIT);
- for (const siteArea of siteAreas.result) {
- // Get charging stations from SiteArea
- evses.push(...await OICPMapping.getEvsesFromSiteaArea(tenant, siteArea, options));
- }
- // Return evses
- return evses;
- }
-
/**
* Get All OICP Evses from given tenant
* @param {Tenant} tenant
@@ -450,4 +293,161 @@ export default class OICPMapping {
return OICPEvseStatus.Unknown;
}
}
+
+ /**
+ * Get EVSE Statuses from SiteArea
+ * @param {Tenant} tenant
+ * @param {SiteArea} siteArea
+ * @param options
+ * @return Array of OICP EVSE Statuses
+ */
+ private static async getEvseStatusesFromSiteaArea(tenant: Tenant, siteArea: SiteArea, options: { countryID: string; partyID: string; addChargeBoxID?: boolean }): Promise<OICPEvseStatusRecord[]> {
+ // Build evses array
+ const evseStatuses: OICPEvseStatusRecord[] = [];
+ // Convert charging stations to evse status(es)
+ for (const chargingStation of siteArea.chargingStations) {
+ if (chargingStation.issuer && chargingStation.public) {
+ evseStatuses.push(...OICPMapping.convertChargingStation2MultipleEvseStatuses(tenant, chargingStation, options));
+ }
+ }
+ // Return evses
+ return evseStatuses;
+ }
+
+ /**
+ * Get evse statuses from Site
+ * @param {Tenant} tenant
+ * @param {Site} site
+ * @param options
+ * @return Array of OICP EVSE Statuses
+ */
+ private static async getEvseStatusesFromSite(tenant: Tenant, site: Site, options: { countryID: string; partyID: string; addChargeBoxID?: boolean }): Promise<OICPEvseStatusRecord[]> {
+ // Build evses array
+ const evseStatuses: OICPEvseStatusRecord[] = [];
+ const siteAreas = await SiteAreaStorage.getSiteAreas(tenant.id,
+ {
+ withOnlyChargingStations: true,
+ withChargingStations: true,
+ siteIDs: [site.id],
+ issuer: true
+ },
+ Constants.DB_PARAMS_MAX_LIMIT);
+ for (const siteArea of siteAreas.result) {
+ // Get charging station statuses from SiteArea
+ evseStatuses.push(...await OICPMapping.getEvseStatusesFromSiteaArea(tenant, siteArea, options));
+ }
+ // Return evse statuses
+ return evseStatuses;
+ }
+
+ /**
+ * Get evses from Site
+ * @param {Tenant} tenant
+ * @param {Site} site
+ * @param options
+ * @return Array of OICP EVSEs
+ */
+ private static async getEvsesFromSite(tenant: Tenant, site: Site, options: { countryID: string; partyID: string; addChargeBoxID?: boolean }): Promise<OICPEvseDataRecord[]> {
+ // Build evses array
+ const evses = [];
+ const siteAreas = await SiteAreaStorage.getSiteAreas(tenant.id,
+ {
+ withOnlyChargingStations: true,
+ withChargingStations: true,
+ withSite: true,
+ siteIDs: [site.id],
+ issuer: true
+ },
+ Constants.DB_PARAMS_MAX_LIMIT);
+ for (const siteArea of siteAreas.result) {
+ // Get charging stations from SiteArea
+ evses.push(...await OICPMapping.getEvsesFromSiteaArea(tenant, siteArea, options));
+ }
+ // Return evses
+ return evses;
+ }
+
+ /**
+ * Convert ChargingStation to Multiple EVSEs
+ * @param {Tenant} tenant
+ * @param {*} chargingStation
+ * @return Array of OICP EVSEs
+ */
+ private static convertChargingStation2MultipleEvses(tenant: Tenant, siteArea: SiteArea, chargingStation: ChargingStation, chargePoint: ChargePoint, options: { countryID: string; partyID: string; addChargeBoxID?: boolean}): OICPEvseDataRecord[] {
+ // Loop through connectors and send one evse per connector
+ let connectors: Connector[];
+ if (chargePoint) {
+ connectors = Utils.getConnectorsFromChargePoint(chargingStation, chargePoint);
+ } else {
+ connectors = chargingStation.connectors.filter((connector) => connector !== null);
+ }
+ const evses = connectors.map((connector) => OICPMapping.convertConnector2Evse(tenant, siteArea, chargingStation, connector, options));
+ // Return all evses
+ return evses;
+ }
+
+ /**
+ * Convert ChargingStation to Multiple EVSE Statuses
+ * @param {Tenant} tenant
+ * @param {*} chargingStation
+ * @return Array of OICP EVSE Statuses
+ */
+ private static convertChargingStation2MultipleEvseStatuses(tenant: Tenant, chargingStation: ChargingStation, options: { countryID: string; partyID: string; addChargeBoxID?: boolean}): OICPEvseStatusRecord[] {
+ // Loop through connectors and send one evse per connector
+ const connectors = chargingStation.connectors.filter((connector) => connector !== null);
+ const evseStatuses = connectors.map((connector) => OICPMapping.convertConnector2EvseStatus(tenant, chargingStation, connector, options));
+ // Return all EVSE Statuses
+ return evseStatuses;
+ }
+
+ /**
+ * Convert Connector to OICP EVSE
+ * @param {Tenant} tenant
+ * @param {*} connector
+ * @return EVSE
+ */
+ private static convertConnector2Evse(tenant: Tenant, siteArea: SiteArea, chargingStation: ChargingStation, connector: Connector, options: { countryID: string; partyID: string; addChargeBoxID?: boolean}): OICPEvseDataRecord {
+ const evseID = RoamingUtils.buildEvseID(options.countryID, options.partyID, chargingStation, connector);
+ const evse: OICPEvseDataRecord = {} as OICPEvseDataRecord;
+ evse.deltaType; // Optional
+ evse.lastUpdate; // Optional
+ evse.EvseID = evseID;
+ evse.ChargingPoolID = OICPMapping.buildEChargingPoolID(options.countryID, options.partyID, siteArea.id); // Optional
+ evse.ChargingStationID = chargingStation.id; // Optional
+ evse.ChargingStationNames = [
+ {
+ lang: 'en',
+ value: chargingStation.id
+ }
+ ];
+ evse.HardwareManufacturer = chargingStation.chargePointVendor; // Optional
+ evse.ChargingStationImage; // Optional
+ evse.SubOperatorName; // Optional
+ evse.Address = OICPMapping.getOICPAddressIso19773FromSiteArea(siteArea, options.countryID);
+ evse.GeoCoordinates = OICPMapping.convertCoordinates2OICPGeoCoordinates(chargingStation.coordinates, OICPGeoCoordinatesResponseFormat.DecimalDegree); // Optional
+ evse.Plugs = [OICPMapping.convertConnector2OICPPlug(connector)];
+ evse.DynamicPowerLevel; // Optional
+ evse.ChargingFacilities = [OICPMapping.convertConnector2OICPChargingFacility(chargingStation, connector)];
+ evse.RenewableEnergy = false; // No information found for mandatory field
+ evse.EnergySource; // Optional
+ evse.EnvironmentalImpact; // Optional
+ evse.CalibrationLawDataAvailability = OICPCalibrationLawDataAvailability.NotAvailable; // No information found for mandatory field
+ evse.AuthenticationModes = [OICPAuthenticationMode.NfcRfidClassic]; // No information found for mandatory field
+ evse.MaxCapacity; // Optional
+ evse.PaymentOptions = [OICPPaymentOption.Contract]; // No information found for mandatory field
+ evse.ValueAddedServices = [OICPValueAddedService.None]; // No information found for mandatory field
+ evse.Accessibility = OICPAccessibility.FreePubliclyAccessible;
+ evse.AccessibilityLocation; // Optional
+ evse.HotlinePhoneNumber = '+49123123123123'; // No information found for mandatory field
+ evse.AdditionalInfo; // Optional
+ evse.ChargingStationLocationReference; // Optional
+ evse.GeoChargingPointEntrance; // Optional
+ evse.IsOpen24Hours = true; // No information found for mandatory field
+ evse.OpeningTimes; // Optional
+ evse.ClearinghouseID; // Optional
+ evse.IsHubjectCompatible = true;
+ evse.DynamicInfoAvailable = OICPDynamicInfoAvailable.auto;
+ // Return evse
+ return evse;
+ }
}

MODIFY
src/server/rest/v1/service/TenantService.ts
src/server/rest/v1/service/TenantService.ts
@@ -329,7 +329,7 @@ export default class TenantService {
private static async updateSettingsWithComponents(tenant: Partial<Tenant>, req: Request): Promise<void> {
// Check if OICP component is activated or deactivated and create/activate/deactivate virtual user (and Badges) accordingly
- OICPUtils.checkOICPComponent(tenant);
+ await OICPUtils.checkOICPComponent(tenant);
// Create settings
for (const componentName in tenant.components) {
// Get the settings

Lint remarks changed