fixed car selection bug + unit test
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1697,17 +1697,17 @@ export default class OCPPService {
// Clear
await UserStorage.saveUserLastSelectedCarID(tenant, user.id, null);
// Handle SoC
- transaction.stateOfCharge = await this.getCurrentSoc(tenant, transaction, chargingStation);
+ transaction.stateOfCharge = (await this.getCurrentSoc(tenant, transaction, chargingStation) ?? transaction.stateOfCharge);
}
break;
case TransactionAction.UPDATE:
// Handle SoC
- // Reassignment not needed anymore with specific connector data in car object --> Coming with Tronity implementation
if (Utils.isNullOrUndefined(transaction.car) || Utils.isNullOrUndefined(consumption)) {
return;
}
+ // 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 = (await this.getCurrentSoc(tenant, transaction, chargingStation) ?? consumption.stateOfCharge);
break;
}
}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1804,17 +1804,15 @@ export default class ChargingStationService {
}
// Check Charging Station
Authorizations.isChargingStationValidInOrganization(action, req.tenant, chargingStation);
- // Execute it
- const result = await ChargingStationService.executeChargingStationCommand(
- req.tenant, req.user, chargingStation, action, command, { tagID: tag.id, connectorId: filteredRequest.args.connectorId });
// Save Car selection
if (Utils.isComponentActiveFromToken(req.user, TenantComponents.CAR)) {
- if (result?.status === OCPPRemoteStartStopStatus.ACCEPTED) {
if (filteredRequest.carID && filteredRequest.carID !== user.lastSelectedCarID) {
await UserStorage.saveUserLastSelectedCarID(req.tenant, user.id, filteredRequest.carID);
}
}
- }
+ // Execute it
+ const result = await ChargingStationService.executeChargingStationCommand(
+ req.tenant, req.user, chargingStation, action, command, { tagID: tag.id, connectorId: filteredRequest.args.connectorId });
return result;
}

fixed car selection bug + unit test