translator, wb_editors
4544
правки
Matveevrj (обсуждение | вклад) (Новая страница: «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...») |
Matveevrj (обсуждение | вклад) (Новая страница: «<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 === | ||
The rule is the same as in the previous section, but only runs from 9:30 am to 5:10 pm UTC. | |||
<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(); | ||
// 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); | ||
// 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 lang="ru" dir="ltr" class="mw-content-ltr"> | <div lang="ru" dir="ltr" class="mw-content-ltr"> |