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

Навигация

Rule Examples/en: различия между версиями

Новая страница: «<syntaxhighlight lang="ecmascript"> var motion_timer_1_timeout_ms = 5 * 1000; var motion_timer_1_id = null; defineRule("motion_detector_1", { whenChanged: "wb-gpio/A1_IN", then: function (newValue, devName, cellName) { var date = new Date();»
(Новая страница: «defineRule("motion_detector_1", { whenChanged: "wb-gpio/D2_IN", then: function (newValue, devName, cellName) { if (newValue) { dev["wb-gpio"]["Relay_1"] = true; if (motion_timer_1_id) { clearTimeout(motion_timer_1_id); } motion_timer_1_id = setTimeout(function () { dev["wb-gpio"]["Relay_1"] = false; motion_timer_1_id = null; }, motion_t...»)
(Новая страница: «<syntaxhighlight lang="ecmascript"> var motion_timer_1_timeout_ms = 5 * 1000; var motion_timer_1_id = null; defineRule("motion_detector_1", { whenChanged: "wb-gpio/A1_IN", then: function (newValue, devName, cellName) { var date = new Date();»)
Строка 110: Строка 110:
=== Activate the rule only at a certain time ===
=== Activate the rule only at a certain time ===


<div lang="ru" dir="ltr" class="mw-content-ltr">
The rule is the same as in the previous section, but only runs from 9:30 am to 5:10 pm UTC.
Правило как в предыдущем разделе, но выполняется только с 9:30 до 17:10 по UTC.
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
<syntaxhighlight lang="ecmascript">
<syntaxhighlight lang="ecmascript">
var motion_timer_1_timeout_ms = 5 * 1000;
var motion_timer_1_timeout_ms = 5 * 1000;
Строка 123: Строка 120:
   then: function (newValue, devName, cellName) {
   then: function (newValue, devName, cellName) {
     var date = new Date();
     var date = new Date();
</div>


     <div lang="ru" dir="ltr" class="mw-content-ltr">
     // time point marking the beginning of the interval
// time point marking the beginning of the interval
     // i.e. "today, at HH:MM". All dates are in UTC!
     // i.e. "today, at HH:MM". All dates are in UTC!
     var date_start = new Date(date);
     var date_start = new Date(date);
     date_start.setHours(9);
     date_start.setHours(9);
     date_start.setMinutes(30);
     date_start.setMinutes(30);
</div>


     <div lang="ru" dir="ltr" class="mw-content-ltr">
     // time point marking the end of the interval
// time point marking the end of the interval
     var date_end = new Date(date);
     var date_end = new Date(date);
     date_end.setHours(17);
     date_end.setHours(17);
Строка 157: Строка 150:
});
});
</syntaxhighlight>
</syntaxhighlight>
</div>


<div lang="ru" dir="ltr" class="mw-content-ltr">
<div lang="ru" dir="ltr" class="mw-content-ltr">
translator, wb_editors
4344

правки