Rule Examples/en: различия между версиями
Matveevrj (обсуждение | вклад) (Новая страница: «In the example, the motion sensor is connected to the "dry contact" input, control type "switch". The siren is connected to the built-in Wiren Board relay, and the lamp is connected to the relay box via Modbus. When the "dry contact" input (motion sensor output) is closed, "1" is supplied to the lamp and the relay, and "0" when it is off.») |
Matveevrj (обсуждение | вклад) (Новая страница: «} });») |
||
Строка 9: | Строка 9: | ||
In the example, the motion sensor is connected to the "dry contact" input, control type "switch". The siren is connected to the built-in Wiren Board relay, and the lamp is connected to the relay box via Modbus. When the "dry contact" input (motion sensor output) is closed, "1" is supplied to the lamp and the relay, and "0" when it is off. | In the example, the motion sensor is connected to the "dry contact" input, control type "switch". The siren is connected to the built-in Wiren Board relay, and the lamp is connected to the relay box via Modbus. When the "dry contact" input (motion sensor output) is closed, "1" is supplied to the lamp and the relay, and "0" when it is off. | ||
The rule is triggered every time the control value "D1_IN" of the device "wb-gpio" is changed. The new value of this control is passed to the rule code as a variable newValue. | |||
<syntaxhighlight lang="ecmascript"> | <syntaxhighlight lang="ecmascript"> | ||
defineRule({ | defineRule({ | ||
whenChanged: "wb-gpio/D1_IN", | whenChanged: "wb-gpio/D1_IN", | ||
Строка 23: | Строка 18: | ||
dev["wb-gpio"]["Relay_2"] = newValue; | dev["wb-gpio"]["Relay_2"] = newValue; | ||
dev["wb-mrm2_6"]["Relay 1"] = newValue; | dev["wb-mrm2_6"]["Relay 1"] = newValue; | ||
} | |||
} | |||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<div lang="ru" dir="ltr" class="mw-content-ltr"> | <div lang="ru" dir="ltr" class="mw-content-ltr"> |