Add an util method to check if it's charging with 3 phases
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -377,17 +377,11 @@ export default class OCPPService {
// Save Charging Station
await ChargingStationStorage.saveChargingStation(headers.tenantID, chargingStation);
// First Meter Value and no Car -> Trigger Smart Charging to adjust the single phase Car
- if (transaction.numberOfMeterValues === 1 && !transaction.carID) {
- const currentType = Utils.getChargingStationCurrentType(chargingStation, null, transaction.connectorId);
- // Single Phase car?
- if (currentType === CurrentType.AC &&
- transaction.currentInstantAmpsL1 > 0 &&
- transaction.currentInstantAmpsL2 === 0 &&
- transaction.currentInstantAmpsL3 === 0) {
+ if (transaction.numberOfMeterValues === 1 && !transaction.carID &&
+ !Utils.isTransactionInProgressOnThreePhases(chargingStation, transaction)) {
// Yes: Trigger Smart Charging
await this.triggerSmartCharging(headers.tenantID, chargingStation);
}
- }
// Log
Logging.logInfo({
tenantID: headers.tenantID,

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -16,7 +16,7 @@ import ConnectorStats from '../types/ConnectorStats';
import Constants from './Constants';
import Cypher from './Cypher';
import { HTTPError } from '../types/HTTPError';
-import { InactivityStatus } from '../types/Transaction';
+import Transaction, { InactivityStatus } from '../types/Transaction';
import Logging from './Logging';
import OCPIEndpoint from '../types/ocpi/OCPIEndpoint';
import { ObjectID } from 'mongodb';
@@ -48,6 +48,18 @@ const _tenants = [];
const MODULE_NAME = 'Utils';
export default class Utils {
+ public static isTransactionInProgressOnThreePhases(chargingStation: ChargingStation, transaction: Transaction): boolean {
+ const currentType = Utils.getChargingStationCurrentType(chargingStation, null, transaction.connectorId);
+ let threePhases = true;
+ if (currentType === CurrentType.AC &&
+ transaction.currentInstantAmpsL1 > 0 &&
+ transaction.currentInstantAmpsL2 === 0 &&
+ transaction.currentInstantAmpsL3 === 0) {
+ threePhases = false;
+ }
+ return threePhases;
+ }
+
public static getEndOfChargeNotificationIntervalMins(chargingStation: ChargingStation, connectorId: number): number {
let intervalMins = 0;
if (!chargingStation || !chargingStation.connectors) {

Add an util method to check if it's charging with 3 phases