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

Новая страница: «</syntaxhighlight> *The first line is the code word ''defineRule'' and the name of the rule *The second line is the code word for determining when the rule is exe…»
(Новая страница: «defineRule("heater_control", { //rule name is arbitrary whenChanged: "wb-w1/28-0115a48fcfff", //when the state of 1-Wire sensor with ID 28-0115a48fcfff changes…»)
(Новая страница: «</syntaxhighlight> *The first line is the code word ''defineRule'' and the name of the rule *The second line is the code word for determining when the rule is exe…»)
Строка 46: Строка 46:


</syntaxhighlight>
</syntaxhighlight>
*Первая строка - кодовое слово ''defineRule'' и название правила
*The first line is the code word ''defineRule'' and the name of the rule
*Вторая строка - кодовое слово для определения, когда выполняется правило, - ''whenChanged'' - "при изменении параметра", далее название параметра, при изменении которого запустится правило - температура с датчика 1-Wire. Название параметра записывается в виде "Device/Control", где названия ''Device'' и ''Control'' для каждого параметра можно найти на странице ''Settings'' веб-интерфейса в таблице ''MQTT Channels''.
*The second line is the code word for determining when the rule is executed-whenChanged - "when the parameter changes", then the name of the parameter, when changing which the rule will start - the temperature from the 1-Wire sensor. The parameter name is written as "Device/Control", where the device and Control names for each parameter can be found on the Settings page of the web interface in the ''MQTT Channels'' table.
*Третья строка - начало функции, которая будет исполняться
*The third line is the beginning of the function to be executed
*Затем идёт условие - "если значение температуры больше порогового, то ...". Значение параметра записывается в виде ''dev[Device][Control]'' - заметьте, оно отличается от вида записи параметра, при изменении которого запускается правило, потому что там речь идёт о ''параметре'', а здесь - о ''значении'' того же параметра.
*Then there is a condition - "if the temperature is greater than the threshold, then ...". The value of the parameter is written as dev[Device][Control] - note that it differs from the type of parameter recording, when changing which the rule is run, because there it is a parameter, and here - the value of the same parameter.
*Затем мы выставляем значения для реле в каждом случае - ''0'' - "выключено", ''1'' - "включено". Названия ''Device'' и ''Control'' для реле смотрим всё в той же таблице ''MQTT Channels'' на странице ''Settings'' веб-интерфейса.
*Then we set the values for the relay in each case - 0 - "off", 1 - "on". The names of the Device and Control for the relay look all in the same table MQTT Channels on the ''Settings'' page of the web interface.




12 063

правки