Fix zero value in metervalues charging station templates.
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 20 Oct 2020 18:57:30 +0000 (20:57 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 20 Oct 2020 18:57:30 +0000 (20:57 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.js

index c1ca553d365228842c6001b5df497d3d59c292c5..f794f1bc1276edd72b6c422b1094f082cb90e563 100644 (file)
@@ -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) {