Enhanced code + Fixed typo
MODIFY
src/integration/smart-charging/SmartChargingIntegration.ts
src/integration/smart-charging/SmartChargingIntegration.ts
@@ -114,8 +114,7 @@ export default abstract class SmartChargingIntegration<T extends SmartChargingSe
private async handleRefusedChargingProfile(tenantID: string, chargingProfile: ChargingProfile, siteAreaName: string): Promise<boolean> {
// Retry setting the cp 2 more times
- const retries = 3;
- for (let tryCount = 2; tryCount <= retries; tryCount++) {
+ for (let i = 0; i < 2; i++) {
try {
// Set Charging Profile
await OCPPUtils.setAndSaveChargingProfile(this.tenantID, chargingProfile);
@@ -127,14 +126,16 @@ export default abstract class SmartChargingIntegration<T extends SmartChargingSe
source: chargingProfile.chargingStationID,
action: ServerAction.CHARGING_PROFILE_UPDATE,
module: MODULE_NAME, method: 'handleRefusedChargingProfile',
- message: `Setting Charging Profiles for '${chargingProfile.chargingStationID}' failed for the ${tryCount}. time.`,
+ message: 'Setting Charging Profiles failed 3 times.',
detailedMessages: { error: error.message, stack: error.stack }
});
}
}
+ // Remove Charging Station from Smart Charging
const chargingStation = await ChargingStationStorage.getChargingStation(tenantID, chargingProfile.chargingStationID);
chargingStation.excludeFromSmartCharging = true;
await ChargingStationStorage.saveChargingStation(tenantID, chargingStation);
+ // Notify Admins
await NotificationHandler.sendComputeAndApplyChargingProfilesFailed(tenantID,
{ chargeBoxID: chargingProfile.chargingStationID,
siteAreaName: siteAreaName,

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -365,7 +365,7 @@ export enum ServerAction {
MONGO_DB = 'MongoDB',
CHECK_AND_APPLY_SMART_CHARGING = 'CheckAndApplySmartCharging',
- CHECK_AND_APPLY_SMART_CHARGING_FAILED = 'computeAndApplyChargingProfilesFailed',
+ CHECK_AND_APPLY_SMART_CHARGING_FAILED = 'ComputeAndApplyChargingProfilesFailed',
SMART_CHARGING = 'SmartCharging',
INSTANTIATE_DUMMY_MODULE = 'InstantiateDummyModule',

MODIFY
src/types/UserNotifications.ts
src/types/UserNotifications.ts
@@ -64,7 +64,7 @@ export enum UserNotificationType {
BILLING_INVOICE_SYNCHRONIZATION_FAILED = 'BillingInvoiceSynchronizationFailed',
BILLING_NEW_INVOICE = 'BillingNewInvoice',
CAR_CATALOG_SYNCHRONIZATION_FAILED = 'CarCatalogSynchronizationFailed',
- CHECK_AND_APPLY_SMART_CHARGING_FAILED = 'computeAndApplyChargingProfilesFailed',
+ CHECK_AND_APPLY_SMART_CHARGING_FAILED = 'ComputeAndApplyChargingProfilesFailed',
SESSION_NOT_STARTED_AFTER_AUTHORIZE = 'SessionNotStartedAfterAuthorize',
END_USER_ERROR_NOTIFICATION = 'EndUserErrorNotification'
}

Enhanced code + Fixed typo