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

Материал из Wiren Board
(Новая страница: «<syntaxhighlight lang="ecmascript"> function makeMotionDetector(name, timeout_ms, detector_control, relay_control) { var motion_timer_id = null; defineRule(name, { whenChanged: "wb-gpio/" + detector_control, then: function(newValue, devName, cellName) { if (!newValue) { dev["wb-gpio"][relay_control] = true; if (motion_timer_id) { clearTimeout(motion_timer_id); }»)
 
 
Строка 6: Строка 6:
       then: function(newValue, devName, cellName) {
       then: function(newValue, devName, cellName) {
           if (!newValue) {
           if (!newValue) {
               dev["wb-gpio"][relay_control] = true;
               dev["wb-gpio/relay_control"] = true;
               if (motion_timer_id) {
               if (motion_timer_id) {
                   clearTimeout(motion_timer_id);
                   clearTimeout(motion_timer_id);
               }
               }

Текущая версия на 21:54, 21 сентября 2022

Определение сообщения (Rule Examples)
<syntaxhighlight lang="ecmascript">
 function makeMotionDetector(name, timeout_ms, detector_control, relay_control) {
  var motion_timer_id = null;
  defineRule(name, {
     whenChanged: "wb-gpio/" + detector_control,
     then: function(newValue, devName, cellName) {
         if (!newValue) {
             dev["wb-gpio/relay_control"] = true;
             if (motion_timer_id) {
                 clearTimeout(motion_timer_id);
             }

<syntaxhighlight lang="ecmascript">

function makeMotionDetector(name, timeout_ms, detector_control, relay_control) {
 var motion_timer_id = null;
 defineRule(name, {
     whenChanged: "wb-gpio/" + detector_control,
     then: function(newValue, devName, cellName) {
         if (!newValue) {
             dev["wb-gpio/relay_control"] = true;
             if (motion_timer_id) {
                 clearTimeout(motion_timer_id);
             }