From: Jérôme Benoit Date: Sat, 31 Dec 2022 21:34:23 +0000 (+0100) Subject: Handle null or undefined meterStart and meterStop properly X-Git-Tag: v1.1.89~45 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2040a613fd09c3476094e671a103131b99d08a8b;p=e-mobility-charging-stations-simulator.git Handle null or undefined meterStart and meterStop properly Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index 25d8dcdf..040850a3 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -698,7 +698,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { meterValue.sampledValue.push( OCPP16ServiceUtils.buildSampledValue( sampledValueTemplate, - Utils.roundTo(meterStart / unitDivider, 4), + Utils.roundTo((meterStart ?? 0) / unitDivider, 4), MeterValueContext.TRANSACTION_BEGIN ) ); @@ -723,7 +723,7 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { meterValue.sampledValue.push( OCPP16ServiceUtils.buildSampledValue( sampledValueTemplate, - Utils.roundTo(meterStop / unitDivider, 4), + Utils.roundTo((meterStop ?? 0) / unitDivider, 4), MeterValueContext.TRANSACTION_END ) );