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

Материал из Wiren Board
(Новая страница: «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...»)
 
 
Строка 3: Строка 3:
     then: function (newValue, devName, cellName) {
     then: function (newValue, devName, cellName) {
         if (newValue) {
         if (newValue) {
             dev["wb-gpio"]["Relay_1"] = true;
             dev["wb-gpio/Relay_1"] = true;
             if (motion_timer_1_id) {
             if (motion_timer_1_id) {
                 clearTimeout(motion_timer_1_id);
                 clearTimeout(motion_timer_1_id);
             }
             }
             motion_timer_1_id = setTimeout(function () {
             motion_timer_1_id = setTimeout(function () {
                 dev["wb-gpio"]["Relay_1"] = false;
                 dev["wb-gpio/Relay_1"] = false;
                 motion_timer_1_id = null;
                 motion_timer_1_id = null;
             }, motion_timer_1_timeout_ms);
             }, motion_timer_1_timeout_ms);

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

Определение сообщения (Rule Examples)
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_timer_1_timeout_ms);
       }
   },
});
</syntaxhighlight>

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_timer_1_timeout_ms);
       }
   },

}); </syntaxhighlight>