12 063
правки
(Новая страница: «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", // | 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) { // | if ( newValue > 30) { //if the sensor temperature value is more than 30 degrees | ||
dev["wb-mrm2_130"]["Relay 1"] = 0; // | 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; // | dev["wb-mrm2_130"]["Relay 1"] = 1; //set Relay 1 of WB-MRM2 module with address 130 in "on" state | ||
} | } | ||
} | } |
правки