removed connector id param to get car connector impl
MODIFY
src/integration/car-connector/CarConnectorFactory.ts
src/integration/car-connector/CarConnectorFactory.ts
import { CarConnectorConnectionType, CarConnectorSetting } from '../../types/Setting';
-import { Car } from '../../types/Car';
import CarConnectorIntegration from './CarConnectorIntegration';
import MercedesCarConnectorIntegration from './mercedes-connector/MercedesCarConnectorIntegration';
import SettingStorage from '../../storage/mongodb/SettingStorage';
@@ -9,14 +8,14 @@ import TenantComponents from '../../types/TenantComponents';
import Utils from '../../utils/Utils';
export default class CarConnectorFactory {
- static async getCarConnectorImpl(tenant: Tenant, connectorId: string, car?: Car): Promise<CarConnectorIntegration<CarConnectorSetting>> {
+ static async getCarConnectorImpl(tenant: Tenant, connectorId: string): Promise<CarConnectorIntegration<CarConnectorSetting>> {
// Check if car connector component is active
if (Utils.isTenantComponentActive(tenant, TenantComponents.CAR_CONNECTOR)) {
const settings = await SettingStorage.getCarConnectorSettings(tenant);
if (settings?.carConnector?.connections) {
// Find connection
// Vehicle make will be replaced with specific car information in the car object --> coming with Tronity
- const foundConnection = settings.carConnector.connections.find((connection) => connection.type === (connectorId ?? car?.carCatalog?.vehicleMake?.toLowerCase()));
+ const foundConnection = settings.carConnector.connections.find((connection) => connection.type === connectorId);
if (foundConnection) {
let carConnectorIntegrationImpl: CarConnectorIntegration<CarConnectorSetting> = null;
switch (foundConnection.type) {

MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1672,6 +1672,7 @@ export default class OCPPService {
private async processTransactionCar(tenant: Tenant, transaction: Transaction, chargingStation: ChargingStation, consumption: Consumption, user: User,
action: TransactionAction): Promise<void> {
+ let soc = null;
switch (action) {
case TransactionAction.START:
// Handle car in transaction start
@@ -1697,7 +1698,10 @@ export default class OCPPService {
// Clear
await UserStorage.saveUserLastSelectedCarID(tenant, user.id, null);
// Handle SoC
- transaction.stateOfCharge = (await this.getCurrentSoc(tenant, transaction, chargingStation) ?? transaction.stateOfCharge);
+ soc = await this.getCurrentSoc(tenant, transaction, chargingStation);
+ if (soc) {
+ transaction.stateOfCharge = soc;
+ }
}
break;
case TransactionAction.UPDATE:
@@ -1707,7 +1711,10 @@ export default class OCPPService {
}
// Reassignment not needed anymore with specific connector data in car object --> Coming with Tronity implementation
transaction.car.carCatalog = transaction.carCatalog;
- consumption.stateOfCharge = (await this.getCurrentSoc(tenant, transaction, chargingStation) ?? consumption.stateOfCharge);
+ soc = await this.getCurrentSoc(tenant, transaction, chargingStation);
+ if (soc) {
+ consumption.stateOfCharge = soc;
+ }
break;
}
}
@@ -1715,7 +1722,7 @@ export default class OCPPService {
private async getCurrentSoc(tenant: Tenant, transaction: Transaction, chargingStation: ChargingStation): Promise<number> {
if (Utils.isTenantComponentActive(tenant, TenantComponents.CAR_CONNECTOR) && !Utils.isNullOrUndefined(transaction.car) &&
Utils.getChargingStationCurrentType(chargingStation, null, transaction.connectorId) === CurrentType.AC) {
- const carImplementation = await CarConnectorFactory.getCarConnectorImpl(tenant, null, transaction.car);
+ const carImplementation = await CarConnectorFactory.getCarConnectorImpl(tenant, transaction.car?.carCatalog?.vehicleMake?.toLowerCase());
if (carImplementation) {
try {
return await carImplementation.getCurrentSoC(transaction.userID, transaction.car);

removed connector id param to get car connector impl