Format numbers
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1500,7 +1500,7 @@ export default class OCPPService {
module: MODULE_NAME, method: 'updateChargingStationWithTransaction',
action: ServerAction.CONSUMPTION,
user: transaction.userID,
- message: `Connector '${foundConnector.connectorId}' > Transaction ID '${foundConnector.activeTransactionID}' > Instant: ${foundConnector.currentConsumption / 1000} kW, Total: ${foundConnector.totalConsumption / 1000} kW.h${foundConnector.currentStateOfCharge ? ', SoC: ' + foundConnector.currentStateOfCharge + ' %' : ''}`
+ message: `Connector '${foundConnector.connectorId}' > Transaction ID '${foundConnector.activeTransactionID}' > Instant: ${Utils.getRoundedNumberToTwoDecimals(foundConnector.currentConsumption / 1000)} kW, Total: ${Utils.getRoundedNumberToTwoDecimals(foundConnector.totalConsumption / 1000)} kW.h${foundConnector.currentStateOfCharge ? ', SoC: ' + foundConnector.currentStateOfCharge + ' %' : ''}`
});
// Cleanup connector transaction data
} else if (foundConnector) {

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -566,6 +566,10 @@ export default class Utils {
return 0;
}
+ public static getRoundedNumberToTwoDecimals(numberToRound: number): number {
+ return Math.round(numberToRound * 100) / 100;
+ }
+
public static getNumberOfConnectedPhases(chargingStation: ChargingStation,
chargePoint?: ChargePoint, connectorId = 0): number {
if (chargingStation) {

Format numbers