function sensorListener(weightRef, sensor) {
  weightRef.once('value').then(function (weightSnap) {
    let weight = weightSnap.val();
    let one = weight.empty - weight.full || 1;
    let part = weight.empty - weight.current || 1;
    // console.log(part + " / " + one);
    weightRef.update({
      current: sensor.value,
      percent: Math.round((part / one) * 100),
    });
  });
};

module.exports = sensorListener;

@@ -97,18 +97,20 @@
 ) %7B%0A    
-le
+cons
 t weight
@@ -134,18 +134,20 @@
 ();%0A    
-le
+cons
 t one = 
@@ -183,18 +183,20 @@
  1;%0A    
-le
+cons
 t part =
@@ -215,69 +215,268 @@
 y - 
-weight.current %7C%7C 1
+sensor.value %7C%7C 1;%0A    const basisPoint = Math.round((part / one) * 10000);%0A    const percent = Math.min(100, basisPoint / 100)
 ;%0A   
- //
  cons
-ole.log(part + %22 / %22 + one);%0A
+t diff = Math.round(Math.abs(percent - weight.percent) * 100) / 100;%0A%0A    if(percent != weight.percent && diff %3E 0.01) %7B%0A  
     
@@ -500,16 +500,18 @@
 %7B%0A      
+ 
+ 
 current:
@@ -535,56 +535,34 @@
     
+  
 percent
-: Math.round((part / one) * 100),
+,%0A      %7D);
 %0A    %7D
-);
 %0A  %7D

Improve weight update algorithm