Translations:Rule Examples/195/en: различия между версиями

Материал из Wiren Board
(Новая страница: «defineRule("water_meter_1", { whenChanged: "wb-mcm8_29/Input 1 counter", then: function(newValue, devName, cellName) { if(newValue){ dev["water_meters"]["water_meter_1"] = ((parseInt(newValue) - counterCorrection) * inpulseValue) + meterCorrection; // We multiply the value of the counter by the number of liters / pulse and add the correction value. } } }); </syntaxhighlight>»)
 
 
Строка 3: Строка 3:
     then: function(newValue, devName, cellName) {
     then: function(newValue, devName, cellName) {
       if(newValue){
       if(newValue){
       dev["water_meters"]["water_meter_1"] = ((parseInt(newValue) - counterCorrection) * inpulseValue) + meterCorrection; // We multiply the value of the counter by the number of liters / pulse and add the correction value.
       dev["water_meters/water_meter_1"] = ((parseInt(newValue) - counterCorrection) * inpulseValue) + meterCorrection; // We multiply the value of the counter by the number of liters / pulse and add the correction value.
       }
       }
     }
     }
});
});
</syntaxhighlight>
</syntaxhighlight>

Текущая версия на 21:55, 21 сентября 2022

Определение сообщения (Rule Examples)
defineRule("water_meter_1", {
   whenChanged: "wb-mcm8_29/Input 1 counter",
   then: function(newValue, devName, cellName) {
     if(newValue){
     dev["water_meters/water_meter_1"] = ((parseInt(newValue) - counterCorrection) * inpulseValue) + meterCorrection; // Умножаем значение счетчика на количество литров/импульс и прибавляем корректировочное значение.
     }
   }
});
</syntaxhighlight>

defineRule("water_meter_1", {

   whenChanged: "wb-mcm8_29/Input 1 counter",
   then: function(newValue, devName, cellName) {
     if(newValue){
     dev["water_meters/water_meter_1"] = ((parseInt(newValue) - counterCorrection) * inpulseValue) + meterCorrection; // We multiply the value of the counter by the number of liters / pulse and add the correction value.
     }
   }

}); </syntaxhighlight>