Rule Examples/en: различия между версиями
Matveevrj (обсуждение | вклад) (Новая страница: «The lighting is connected via a built-in relay corresponding to the <code>wb-gpio/Relay_1</code> channel.») |
Matveevrj (обсуждение | вклад) (Новая страница: «The rule works like this: * when movement appears, the light turns on. If a thirty-second "off" timer was previously started, this timer is disabled; * when motion is lost, a thirty second "off" timer is started. If he manages to reach the end, the light turns off.») |
||
Строка 53: | Строка 53: | ||
The lighting is connected via a built-in relay corresponding to the <code>wb-gpio/Relay_1</code> channel. | The lighting is connected via a built-in relay corresponding to the <code>wb-gpio/Relay_1</code> channel. | ||
The rule works like this: | |||
* when movement appears, the light turns on. If a thirty-second "off" timer was previously started, this timer is disabled; | |||
* | * when motion is lost, a thirty second "off" timer is started. If he manages to reach the end, the light turns off. | ||
* | |||
<syntaxhighlight lang="ecmascript"> | <syntaxhighlight lang="ecmascript"> | ||
var motion_timer_1_timeout_ms = 30 * 1000; | var motion_timer_1_timeout_ms = 30 * 1000; | ||
var motion_timer_1_id = null; | var motion_timer_1_id = null; | ||
defineRule("motion_detector_1", { | defineRule("motion_detector_1", { | ||
whenChanged: "wb-gpio/D2_IN", | whenChanged: "wb-gpio/D2_IN", | ||
Строка 82: | Строка 77: | ||
}); | }); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<div lang="ru" dir="ltr" class="mw-content-ltr"> | <div lang="ru" dir="ltr" class="mw-content-ltr"> |