From 5c389abe410aa4089378f8fd6a8618ca08708a55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 20 Oct 2020 20:57:30 +0200 Subject: [PATCH] Fix zero value in metervalues charging station templates. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index c1ca553d..f794f1bc 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -548,7 +548,7 @@ class ChargingStation { const connector = self._connectors[connectorId]; // SoC measurand if (sampledValueLcl.sampledValue[index].measurand && sampledValueLcl.sampledValue[index].measurand === 'SoC') { - sampledValueLcl.sampledValue[index].value = sampledValueLcl.sampledValue[index].value ? + sampledValueLcl.sampledValue[index].value = !Utils.isUndefined(sampledValueLcl.sampledValue[index].value) ? sampledValueLcl.sampledValue[index].value : sampledValueLcl.sampledValue[index].value = Utils.getRandomInt(100); if (sampledValueLcl.sampledValue[index].value > 100 || debug) { @@ -556,10 +556,10 @@ class ChargingStation { } // Voltage measurand } else if (sampledValueLcl.sampledValue[index].measurand && sampledValueLcl.sampledValue[index].measurand === 'Voltage') { - sampledValueLcl.sampledValue[index].value = sampledValueLcl.sampledValue[index].value ? sampledValueLcl.sampledValue[index].value : 230; + sampledValueLcl.sampledValue[index].value = !Utils.isUndefined(sampledValueLcl.sampledValue[index].value) ? sampledValueLcl.sampledValue[index].value : 230; // Energy.Active.Import.Register measurand (default) } else if (!sampledValueLcl.sampledValue[index].measurand || sampledValueLcl.sampledValue[index].measurand === 'Energy.Active.Import.Register') { - if (!sampledValueLcl.sampledValue[index].value) { + if (Utils.isUndefined(sampledValueLcl.sampledValue[index].value)) { const measurandValue = Utils.getRandomInt(self._stationInfo.maxPower / 3600000 * interval); // Persist previous value in connector if (connector && connector.lastEnergyActiveImportRegisterValue >= 0) { -- 2.34.1