Guest User

Untitled

a guest
Oct 25th, 2024
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // K1 - Up, K2 - Down!
  2.  
  3. var yourdevice = "ssr8_cover";
  4. //var ssr8_id = "wb-mio-gpio_116:1/";
  5. var ssr8_id = "wb-gpio/EXT1_";
  6.  
  7. defineVirtualDevice(yourdevice, {
  8.     title: yourdevice ,
  9.     cells: {
  10.       Up1: {
  11.         title: "Up 1",
  12.         type: "pushbutton",
  13.         value: "false"
  14.         },
  15.       Stop1: {
  16.         title: "Stop 1",
  17.         type: "pushbutton",
  18.         value: "false"
  19.         },
  20.       Down1: {
  21.         title: "Down 1",
  22.         type: "pushbutton",
  23.         value: "false"
  24.         },
  25.       Up2: {
  26.         title: "Up 2",
  27.         type: "pushbutton",
  28.         value: "false"
  29.         },
  30.       Stop2: {
  31.         title: "Stop 2",
  32.         type: "pushbutton",
  33.         value: "false"
  34.         },
  35.       Down2: {
  36.         title: "Down 2",
  37.         type: "pushbutton",
  38.         value: "false"
  39.         },
  40.       Up3: {
  41.         title: "Up 3",
  42.         type: "pushbutton",
  43.         value: "false"
  44.         },
  45.       Stop3: {
  46.         title: "Stop 3",
  47.         type: "pushbutton",
  48.         value: "false"
  49.         },
  50.       Down3: {
  51.         title: "Down 3",
  52.         type: "pushbutton",
  53.         value: "false"
  54.         },
  55.       Up4: {
  56.         title: "Up 4",
  57.         type: "pushbutton",
  58.         value: "false"
  59.         },
  60.       Stop4: {
  61.         title: "Stop 4",
  62.         type: "pushbutton",
  63.         value: "false"
  64.         },
  65.       Down4: {
  66.         title: "Down 4",
  67.         type: "pushbutton",
  68.         value: "false"
  69.         },
  70.     }
  71. })
  72.  
  73. // 1
  74.  
  75. defineRule({
  76.   whenChanged: [yourdevice + "/Up 1"],
  77.     then: function (newValue, devName, cellName) {
  78.     dev[ssr8_id + "K1"] = true;
  79.     setTimeout(function () {
  80.       dev[ssr8_id + "K1"] = false;
  81.     }, 500);
  82.   }
  83. })
  84.  
  85. defineRule({
  86.   whenChanged: [yourdevice + "/Stop 1"],
  87.     then: function (newValue, devName, cellName) {
  88.     dev[ssr8_id + "K2"] = true;
  89.     dev[ssr8_id + "K1"] = true;
  90.     setTimeout(function () {
  91.       dev[ssr8_id + "K2"] = false;
  92.       dev[ssr8_id + "K1"] = false;
  93.     }, 500);
  94.   }
  95. })
  96.  
  97. defineRule({
  98.   whenChanged: [yourdevice + "/Down 1"],
  99.     then: function (newValue, devName, cellName) {
  100.     dev[ssr8_id + "K2"] = true;
  101.     setTimeout(function () {
  102.       dev[ssr8_id + "K2"] = false;
  103.     }, 500);
  104.   }
  105. })
  106.  
  107. // 2
  108.  
  109. defineRule({
  110.   whenChanged: [yourdevice + "/Up 2"],
  111.     then: function (newValue, devName, cellName) {
  112.     dev[ssr8_id + "K3"] = true;
  113.     setTimeout(function () {
  114.       dev[ssr8_id + "K3"] = false;
  115.     }, 500);
  116.   }
  117. })
  118.  
  119. defineRule({
  120.   whenChanged: [yourdevice + "/Stop 2"],
  121.     then: function (newValue, devName, cellName) {
  122.     dev[ssr8_id + "K4"] = true;
  123.     dev[ssr8_id + "K3"] = true;
  124.     setTimeout(function () {
  125.       dev[ssr8_id + "K4"] = false;
  126.       dev[ssr8_id + "K3"] = false;
  127.     }, 500);
  128.   }
  129. })
  130.  
  131. defineRule({
  132.   whenChanged: [yourdevice + "/Down 2"],
  133.     then: function (newValue, devName, cellName) {
  134.     dev[ssr8_id + "K4"] = true;
  135.     setTimeout(function () {
  136.       dev[ssr8_id + "K4"] = false;
  137.     }, 500);
  138.   }
  139. })
  140.  
  141. // 3
  142.  
  143. defineRule({
  144.   whenChanged: [yourdevice + "/Up 3"],
  145.     then: function (newValue, devName, cellName) {
  146.     dev[ssr8_id + "K5"] = true;
  147.     setTimeout(function () {
  148.       dev[ssr8_id + "K5"] = false;
  149.     }, 500);
  150.   }
  151. })
  152.  
  153. defineRule({
  154.   whenChanged: [yourdevice + "/Stop 3"],
  155.     then: function (newValue, devName, cellName) {
  156.     dev[ssr8_id + "K6"] = true;
  157.     dev[ssr8_id + "K5"] = true;
  158.     setTimeout(function () {
  159.       dev[ssr8_id + "K6"] = false;
  160.       dev[ssr8_id + "K5"] = false;
  161.     }, 500);
  162.   }
  163. })
  164.  
  165. defineRule({
  166.   whenChanged: [yourdevice + "/Down 3"],
  167.     then: function (newValue, devName, cellName) {
  168.     dev[ssr8_id + "K6"] = true;
  169.     setTimeout(function () {
  170.       dev[ssr8_id + "K6"] = false;
  171.     }, 500);
  172.   }
  173. })
  174.  
  175. // 4
  176.  
  177. defineRule({
  178.   whenChanged: [yourdevice + "/Up 4"],
  179.     then: function (newValue, devName, cellName) {
  180.     dev[ssr8_id + "K7"] = true;
  181.     setTimeout(function () {
  182.       dev[ssr8_id + "K7"] = false;
  183.     }, 500);
  184.   }
  185. })
  186.  
  187. defineRule({
  188.   whenChanged: [yourdevice + "/Stop 4"],
  189.     then: function (newValue, devName, cellName) {
  190.     dev[ssr8_id + "K8"] = true;
  191.     dev[ssr8_id + "K7"] = true;
  192.     setTimeout(function () {
  193.       dev[ssr8_id + "K8"] = false;
  194.       dev[ssr8_id + "K7"] = false;
  195.     }, 500);
  196.   }
  197. })
  198.  
  199. defineRule({
  200.   whenChanged: [yourdevice + "/Down 4"],
  201.     then: function (newValue, devName, cellName) {
  202.     log(yourdevice + "/Down 4 was pressed");
  203.     dev[ssr8_id + "K8"] = true;
  204.     setTimeout(function () {
  205.       dev[ssr8_id + "K8"] = false;
  206.     }, 500);
  207.   }
  208. })
Advertisement
Add Comment
Please, Sign In to add comment