Перейти к содержанию

Навигация

Движок правил wb-rules/en: различия между версиями

Новая страница: «defineRule("heater_control", { //rule name is arbitrary whenChanged: "wb-w1/28-0115a48fcfff", //when the state of 1-Wire sensor with ID 28-0115a48fcfff changes…»
(Новая страница: «To begin with, we will analyze a simple rule - when the temperature is exceeded, turn off the heater. The temperature is obtained from the 1-Wire s…»)
(Новая страница: «defineRule("heater_control", { //rule name is arbitrary whenChanged: "wb-w1/28-0115a48fcfff", //when the state of 1-Wire sensor with ID 28-0115a48fcfff changes…»)
Строка 34: Строка 34:
<syntaxhighlight lang="ecmascript">
<syntaxhighlight lang="ecmascript">


defineRule("heater_control", { //название правила - "контроль обогревателя", может быть произвольным
defineRule("heater_control", { //rule name is arbitrary
   whenChanged: "wb-w1/28-0115a48fcfff", //при изменении состояния датчика 1-Wire с идентификатором 28-0115a48fcfff
   whenChanged: "wb-w1/28-0115a48fcfff", //when the state of 1-Wire sensor with ID 28-0115a48fcfff changes
   then: function (newValue, devName, cellName) { //выполняй следующие действия
   then: function (newValue, devName, cellName) { //execute
     if ( newValue > 30) { //если температура датчика больше 30 градусов
     if ( newValue > 30) { //if the sensor temperature value is more than 30 degrees
       dev["wb-mrm2_130"]["Relay 1"] = 0; //установи Реле 1 модуля WB-MRM2 с адресом 130 в состояние "выключено"
       dev["wb-mrm2_130"]["Relay 1"] = 0; //set the Relay 1 of WB-MRM2 module with address 130 in "off" state
     } else {
     } else {
       dev["wb-mrm2_130"]["Relay 1"] = 1; //установи Реле 1 модуля WB-MRM2 с адресом 130 в состояние "включено"
       dev["wb-mrm2_130"]["Relay 1"] = 1; //set Relay 1 of WB-MRM2 module with address 130 in "on" state
     }
     }
   }
   }
12 063

правки