Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Merge pull request #2651 from sap-labs-france/master-qa
Browse files Browse the repository at this point in the history
Merge master-qa
  • Loading branch information
LucasBrazi06 authored Jul 8, 2021
2 parents 24799bb + 892621a commit 5948b24
Show file tree
Hide file tree
Showing 37 changed files with 217 additions and 500 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ev-server",
"version": "2.4.74",
"version": "2.4.75",
"engines": {
"node": "14.x.x",
"npm": "6.x.x"
Expand Down
2 changes: 1 addition & 1 deletion src/assets/charging-station-templates
2 changes: 1 addition & 1 deletion src/assets/config-template-http.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"debug": false
},
"ChargingStation": {
"heartbeatIntervalOCPPSSecs": 180,
"heartbeatIntervalOCPPSSecs": 60,
"heartbeatIntervalOCPPJSecs": 3600,
"notifBeforeEndOfChargeEnabled": true,
"notifBeforeEndOfChargePercent": 85,
Expand Down
2 changes: 1 addition & 1 deletion src/assets/config-template-https.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"debug": false
},
"ChargingStation": {
"heartbeatIntervalOCPPSSecs": 180,
"heartbeatIntervalOCPPSSecs": 60,
"heartbeatIntervalOCPPJSecs": 3600,
"notifBeforeEndOfChargeEnabled": true,
"notifBeforeEndOfChargePercent": 85,
Expand Down
2 changes: 1 addition & 1 deletion src/assets/configs-aws
4 changes: 2 additions & 2 deletions src/client/oicp/CpoOICPClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export default class CpoOICPClient extends OICPClient {
}
// Save
const executionDurationSecs = Utils.createDecimal(new Date().getTime()).minus(startTime).div(1000).toNumber();
await OICPEndpointStorage.saveOicpEndpoint(this.tenant.id, this.oicpEndpoint);
await OICPEndpointStorage.saveOicpEndpoint(this.tenant, this.oicpEndpoint);
await Logging.logOicpResult(this.tenant.id, ServerAction.OICP_PUSH_EVSE_DATA,
MODULE_NAME, 'sendEVSEs', result,
`{{inSuccess}} EVSE(s) were successfully patched in ${executionDurationSecs}s`,
Expand Down Expand Up @@ -444,7 +444,7 @@ export default class CpoOICPClient extends OICPClient {
}
// Save
const executionDurationSecs = (new Date().getTime() - startTime) / 1000;
await OICPEndpointStorage.saveOicpEndpoint(this.tenant.id, this.oicpEndpoint);
await OICPEndpointStorage.saveOicpEndpoint(this.tenant, this.oicpEndpoint);
await Logging.logOicpResult(this.tenant.id, ServerAction.OICP_PUSH_EVSE_STATUSES,
MODULE_NAME, 'sendEVSEStatuses', result,
`{{inSuccess}} EVSE Status(es) were successfully patched in ${executionDurationSecs}s`,
Expand Down
4 changes: 2 additions & 2 deletions src/client/oicp/OICPClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default abstract class OICPClient {
try {
// Save endpoint
this.oicpEndpoint.status = OICPRegistrationStatus.UNREGISTERED;
await OICPEndpointStorage.saveOicpEndpoint(this.tenant.id, this.oicpEndpoint);
await OICPEndpointStorage.saveOicpEndpoint(this.tenant, this.oicpEndpoint);
// Send success
unregisterResult.statusCode = StatusCodes.OK;
unregisterResult.statusText = ReasonPhrases.OK;
Expand All @@ -99,7 +99,7 @@ export default abstract class OICPClient {
try {
// Save endpoint
this.oicpEndpoint.status = OICPRegistrationStatus.REGISTERED;
await OICPEndpointStorage.saveOicpEndpoint(this.tenant.id, this.oicpEndpoint);
await OICPEndpointStorage.saveOicpEndpoint(this.tenant, this.oicpEndpoint);
// Send success
registerResult.statusCode = StatusCodes.OK;
registerResult.statusText = ReasonPhrases.OK;
Expand Down
2 changes: 1 addition & 1 deletion src/client/oicp/OICPClientFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class OICPClientFactory {
}

static async getAvailableOicpClient(tenant: Tenant, oicpRole: string): Promise<OICPClient> {
const oicpEndpoints = await OICPEndpointStorage.getOicpEndpoints(tenant.id, { role: oicpRole }, Constants.DB_PARAMS_MAX_LIMIT);
const oicpEndpoints = await OICPEndpointStorage.getOicpEndpoints(tenant, { role: oicpRole }, Constants.DB_PARAMS_MAX_LIMIT);
for (const oicpEndpoint of oicpEndpoints.result) {
if (oicpEndpoint.status === OICPRegistrationStatus.REGISTERED) {
const client = await OICPClientFactory.getOicpClient(tenant, oicpEndpoint);
Expand Down
5 changes: 4 additions & 1 deletion src/integration/billing/stripe/StripeBillingIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1396,13 +1396,16 @@ export default class StripeBillingIntegration extends BillingIntegration {
}

public async deleteUser(user: User): Promise<void> {
if (FeatureToggles.isFeatureActive(Feature.BILLING_PREVENT_CUSTOMER_DELETION)) {
// To be on the SAFE side - we preserve the customer on the STRIPE side
return Promise.resolve();
}
// Check Stripe
await this.checkConnection();
// const customer = await this.getCustomerByEmail(user.email);
const customerID = user.billingData?.customerID;
const customer = await this.getStripeCustomer(customerID);
if (customer && customer.id) {
// TODO - ro be clarified - is this allowed when the user has some invoices
await this.stripe.customers.del(
customer.id
);
Expand Down
2 changes: 1 addition & 1 deletion src/integration/smart-charging/sap-smart-charging
2 changes: 1 addition & 1 deletion src/migration/tasks/AddCompanyIDToChargingStationsTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class AddCompanyIDToChargingStationsTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
module: MODULE_NAME, method: 'migrateTenant',
action: ServerAction.MIGRATION,
message: `${updated} Transactions(s) have been updated with Company ID in Tenant ${Utils.buildTenantName(tenant)}`
message: `${updated} Charging Station(s) have been updated with Company ID in Tenant ${Utils.buildTenantName(tenant)}`
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/migration/tasks/AddCompanyIDToTransactionsTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class AddCompanyIDToTransactionsTask extends MigrationTask {
tenantID: Constants.DEFAULT_TENANT,
module: MODULE_NAME, method: 'migrateTenant',
action: ServerAction.MIGRATION,
message: `${updated} Charging Station(s) have been updated with Company ID in Tenant ${Utils.buildTenantName(tenant)}`
message: `${updated} Transaction(s) have been updated with Company ID in Tenant ${Utils.buildTenantName(tenant)}`
});
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/scheduler/tasks/CheckOfflineChargingStationsTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export default class CheckOfflineChargingStationsTask extends SchedulerTask {
let ocppHeartbeatConfiguration: OCPPGetConfigurationCommandResult;
// Check if charging station is still connected
try {
const ocppParamHeartbeatKeys = ['HeartBeatInterval', 'HeartbeatInterval'];
ocppHeartbeatConfiguration = await OCPPUtils.requestChargingStationOcppParameters(tenant, chargingStation, { key: ocppParamHeartbeatKeys });
ocppHeartbeatConfiguration = await OCPPUtils.requestChargingStationOcppParameters(
tenant, chargingStation, { key: Constants.OCPP_HEARTBEAT_KEYS as string[] });
} catch (error) {
// Charging Station is offline!
continue;
Expand All @@ -47,6 +47,7 @@ export default class CheckOfflineChargingStationsTask extends SchedulerTask {
action: ServerAction.OFFLINE_CHARGING_STATION,
module: MODULE_NAME, method: 'processTenant',
message: 'Offline charging station responded successfully to an OCPP command and will be ignored',
detailedMessages: { ocppHeartbeatConfiguration }
});
// Update lastSeen
await ChargingStationStorage.saveChargingStationLastSeen(tenant.id, chargingStation.id,
Expand Down
4 changes: 2 additions & 2 deletions src/scheduler/tasks/LoggingDatabaseTableCleanupTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class LoggingDatabaseTableCleanupTask extends SchedulerTask {
if (await LockingManager.acquire(logsCleanUpLock)) {
try {
// Delete Standard Logs
const deleteUpToDate = moment().subtract(config.retentionPeriodWeeks, 'w').startOf('week').toDate();
const deleteUpToDate = moment().subtract(config.retentionPeriodWeeks, 'w').toDate();
// Delete
let result = await LoggingStorage.deleteLogs(tenantID, deleteUpToDate);
// Ok?
Expand Down Expand Up @@ -89,7 +89,7 @@ export default class LoggingDatabaseTableCleanupTask extends SchedulerTask {
if (await LockingManager.acquire(performanceCleanUpLock)) {
try {
// Delete Performance Records (keep only 2 weeks)
const deleteUpToDate = moment().subtract(2, 'w').startOf('week').toDate();
const deleteUpToDate = moment().subtract(2, 'w').toDate();
// Delete
const result = await PerformanceStorage.deletePerformanceRecords({ deleteUpToDate });
// Ok?
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/tasks/oicp/OICPPushEvseDataTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class OICPPushEvseDataTask extends SchedulerTask {
// Check if OICP component is active
if (Utils.isTenantComponentActive(tenant, TenantComponents.OICP)) {
// Get all available endpoints
const oicpEndpoints = await OICPEndpointStorage.getOicpEndpoints(tenant.id, { role: OICPRole.CPO }, Constants.DB_PARAMS_MAX_LIMIT);
const oicpEndpoints = await OICPEndpointStorage.getOicpEndpoints(tenant, { role: OICPRole.CPO }, Constants.DB_PARAMS_MAX_LIMIT);
for (const oicpEndpoint of oicpEndpoints.result) {
await this.processOICPEndpoint(tenant, oicpEndpoint, config);
}
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/tasks/oicp/OICPPushEvseStatusTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class OICPPushEvseStatusTask extends SchedulerTask {
// Check if OICP component is active
if (Utils.isTenantComponentActive(tenant, TenantComponents.OICP)) {
// Get all available endpoints
const oicpEndpoints = await OICPEndpointStorage.getOicpEndpoints(tenant.id, { role: OICPRole.CPO }, Constants.DB_PARAMS_MAX_LIMIT);
const oicpEndpoints = await OICPEndpointStorage.getOicpEndpoints(tenant, { role: OICPRole.CPO }, Constants.DB_PARAMS_MAX_LIMIT);
for (const oicpEndpoint of oicpEndpoints.result) {
await this.processOICPEndpoint(tenant, oicpEndpoint, config);
}
Expand Down
6 changes: 3 additions & 3 deletions src/server/ocpp/json/WSConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default abstract class WSConnection {
this.wsConnection = wsConnection;
this.initialized = false;
this.wsServer = wsServer;
Logging.logDebug({
void Logging.logDebug({
tenantID: Constants.DEFAULT_TENANT,
action: ServerAction.WS_CONNECTION_OPENED,
module: MODULE_NAME, method: 'constructor',
Expand Down Expand Up @@ -86,7 +86,7 @@ export default abstract class WSConnection {
logMsg = `Charging Station connection attempts with URL: '${req.url}'`;
action = ServerAction.WS_JSON_CONNECTION_OPENED;
}
Logging.logDebug({
void Logging.logDebug({
tenantID: this.tenantID,
source: this.chargingStationID,
action: action,
Expand All @@ -101,7 +101,7 @@ export default abstract class WSConnection {
message: `The Charging Station ID is invalid: '${this.chargingStationID}'`
});
// Log in the right Tenants
Logging.logException(
void Logging.logException(
backendError,
ServerAction.WS_CONNECTION,
Constants.CENTRAL_SERVER,
Expand Down
32 changes: 13 additions & 19 deletions src/server/ocpp/services/OCPPService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1910,26 +1910,20 @@ export default class OCPPService {
setTimeout(async () => {
let result: OCPPChangeConfigurationCommandResult;
// Synchronize heartbeat interval OCPP parameter for charging stations that do not take into account its value in the boot notification response
// Set OCPP 'HeartBeatInterval'
let heartBeatIntervalSettingFailure = false;
result = await OCPPUtils.requestChangeChargingStationOcppParameter(tenant, chargingStation, {
key: 'HeartBeatInterval',
value: heartbeatIntervalSecs.toString()
}, false);
if (result.status !== OCPPConfigurationStatus.ACCEPTED) {
heartBeatIntervalSettingFailure = true;
}
// Set OCPP 'HeartbeatInterval'
result = await OCPPUtils.requestChangeChargingStationOcppParameter(tenant, chargingStation, {
key: 'HeartbeatInterval',
value: heartbeatIntervalSecs.toString()
}, false);
let heartbeatIntervalSettingFailure = false;
if (result.status !== OCPPConfigurationStatus.ACCEPTED) {
heartbeatIntervalSettingFailure = true;
let heartbeatIntervalOcppParamSet = false;
// Change one of the key
for (const heartbeatOcppKey of Constants.OCPP_HEARTBEAT_KEYS) {
result = await OCPPUtils.requestChangeChargingStationOcppParameter(tenant, chargingStation, {
key: heartbeatOcppKey,
value: heartbeatIntervalSecs.toString()
}, false);
if (result.status === OCPPConfigurationStatus.ACCEPTED ||
result.status === OCPPConfigurationStatus.REBOOT_REQUIRED) {
heartbeatIntervalOcppParamSet = true;
break;
}
}
// Check
if (heartBeatIntervalSettingFailure && heartbeatIntervalSettingFailure) {
if (!heartbeatIntervalOcppParamSet) {
await Logging.logError({
tenantID: tenant.id,
action: ServerAction.BOOT_NOTIFICATION,
Expand Down
4 changes: 2 additions & 2 deletions src/server/ocpp/utils/OCPPUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ export default class OCPPUtils {
});
continue;
}
if (parameter === 'HeartBeatInterval' || parameter === 'HeartbeatInterval') {
if (Constants.OCPP_HEARTBEAT_KEYS.includes(parameter)) {
await Logging.logWarning({
tenantID: tenant.id,
source: chargingStation.id,
Expand Down Expand Up @@ -2032,7 +2032,7 @@ export default class OCPPUtils {
});
continue;
}
if (parameter === 'HeartBeatInterval' || parameter === 'HeartbeatInterval') {
if (Constants.OCPP_HEARTBEAT_KEYS.includes(parameter)) {
await Logging.logWarning({
tenantID: tenant.id,
source: chargingStation.id,
Expand Down
Loading

0 comments on commit 5948b24

Please sign in to comment.