Smart charging refuse handling - Fix site area limit
MODIFY
src/integration/smart-charging/SmartChargingIntegration.ts
src/integration/smart-charging/SmartChargingIntegration.ts
@@ -24,6 +24,8 @@ export default abstract class SmartChargingIntegration<T extends SmartChargingSe
}
public async computeAndApplyChargingProfiles(siteArea: SiteArea, retry = false): Promise<ActionsResponse> {
+ // Helper to keep original site area limit
+ const originalSiteAreaMaximumPower = siteArea.maximumPower;
const actionsResponse: ActionsResponse = {
inSuccess: 0,
inError: 0
@@ -31,7 +33,7 @@ export default abstract class SmartChargingIntegration<T extends SmartChargingSe
// Call the charging plans
const chargingProfiles: ChargingProfile[] = await this.buildChargingProfiles(siteArea, this.excludedChargingStations);
if (!chargingProfiles) {
- Logging.logInfo({
+ await Logging.logInfo({
tenantID: this.tenantID,
action: ServerAction.CHARGING_PROFILE_UPDATE,
module: MODULE_NAME, method: 'computeAndApplyChargingProfiles',
@@ -53,7 +55,7 @@ export default abstract class SmartChargingIntegration<T extends SmartChargingSe
}
actionsResponse.inError++;
// Log failed
- Logging.logError({
+ await Logging.logError({
tenantID: this.tenantID,
source: chargingProfile.chargingStationID,
action: ServerAction.CHARGING_PROFILE_UPDATE,
@@ -64,7 +66,7 @@ export default abstract class SmartChargingIntegration<T extends SmartChargingSe
}
}
// Log
- Logging.logActionsResponse(this.tenantID, ServerAction.CHECK_AND_APPLY_SMART_CHARGING,
+ await Logging.logActionsResponse(this.tenantID, ServerAction.CHECK_AND_APPLY_SMART_CHARGING,
MODULE_NAME, 'computeAndApplyChargingProfiles', actionsResponse,
'{{inSuccess}} charging plan(s) were successfully pushed',
'{{inError}} charging plan(s) failed to be pushed',
@@ -72,6 +74,8 @@ export default abstract class SmartChargingIntegration<T extends SmartChargingSe
'No charging plans have been pushed'
);
if (actionsResponse.inError > 0 && retry === false) {
+ // Reset Site Area Limit from last run
+ siteArea.maximumPower = originalSiteAreaMaximumPower;
await this.computeAndApplyChargingProfiles(siteArea, retry = true);
}
return actionsResponse;
@@ -122,7 +126,7 @@ export default abstract class SmartChargingIntegration<T extends SmartChargingSe
return true;
} catch (error) {
// Log failed
- Logging.logError({
+ await Logging.logError({
tenantID: this.tenantID,
source: chargingProfile.chargingStationID,
action: ServerAction.CHARGING_PROFILE_UPDATE,

Smart charging refuse handling - Fix site area limit