timbru31

mqtt_sonoff_toggle

May 17th, 2018
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 3.68 KB | None | 0 0
  1. [
  2.   {
  3.     "id": "d319586a.ea3e68",
  4.     "type": "mqtt in",
  5.     "z": "d844580f.e9f548",
  6.     "name": "Sonoff T1",
  7.     "topic": "cmnd/sonoff-t1-toggle/POWER",
  8.     "qos": "2",
  9.     "broker": "f2b2a376.09292",
  10.     "x": 120,
  11.     "y": 160,
  12.     "wires": [
  13.       [
  14.         "3f20b519.7714ba"
  15.       ]
  16.     ]
  17.   },
  18.   {
  19.     "id": "c3c5bd72.d3596",
  20.     "type": "http request",
  21.     "z": "d844580f.e9f548",
  22.     "name": "Send characteristics update",
  23.     "method": "PUT",
  24.     "ret": "txt",
  25.     "url": "http://192.168.178.xx:51826/characteristics",
  26.     "tls": "",
  27.     "x": 880,
  28.     "y": 240,
  29.     "wires": [
  30.       []
  31.     ]
  32.   },
  33.   {
  34.     "id": "963466b4.1efe38",
  35.     "type": "change",
  36.     "z": "d844580f.e9f548",
  37.     "name": "Construct payload",
  38.     "rules": [
  39.       {
  40.         "t": "set",
  41.         "p": "payload",
  42.         "pt": "msg",
  43.         "to": "{ \t\"characteristics\": [ \t\t{ \t\t\t\"aid\": 45, \t\t\t\"siid\": 8, \t\t\t\"iid\": 10, \t\t\t\"value\": false \t\t}, \t\t{ \t\t\t\"aid\": 22, \t\t\t\"siid\": 8, \t\t\t\"iid\": 10, \t\t\t\"value\": true \t\t} \t] }",
  44.         "tot": "json"
  45.       },
  46.       {
  47.         "t": "set",
  48.         "p": "payload.characteristics[0].value",
  49.         "pt": "msg",
  50.         "to": "isOn",
  51.         "tot": "msg"
  52.       },
  53.       {
  54.         "t": "set",
  55.         "p": "payload.characteristics[1].value",
  56.         "pt": "msg",
  57.         "to": "isOn",
  58.         "tot": "msg"
  59.       }
  60.     ],
  61.     "action": "",
  62.     "property": "",
  63.     "from": "",
  64.     "to": "",
  65.     "reg": false,
  66.     "x": 390,
  67.     "y": 240,
  68.     "wires": [
  69.       [
  70.         "6eabc434.be916c"
  71.       ]
  72.     ]
  73.   },
  74.   {
  75.     "id": "6eabc434.be916c",
  76.     "type": "change",
  77.     "z": "d844580f.e9f548",
  78.     "name": "Add HTTP headers",
  79.     "rules": [
  80.       {
  81.         "t": "set",
  82.         "p": "headers",
  83.         "pt": "msg",
  84.         "to": "{\"Content-type\" : \"application/json\",\"Authorization\": \"871-13-321\"}",
  85.         "tot": "json"
  86.       }
  87.     ],
  88.     "action": "",
  89.     "property": "",
  90.     "from": "",
  91.     "to": "",
  92.     "reg": false,
  93.     "x": 610,
  94.     "y": 240,
  95.     "wires": [
  96.       [
  97.         "c3c5bd72.d3596"
  98.       ]
  99.     ]
  100.   },
  101.   {
  102.     "id": "2768fb24.a3e014",
  103.     "type": "function",
  104.     "z": "d844580f.e9f548",
  105.     "name": "isOn",
  106.     "func": "const isOn = msg.payload.accessories.find(v => v.aid === 22).services.find(v => v.characteristics.find(x => x.iid === 10)).characteristics.find(v => v.iid === 10).value;\nreturn {\n    isOn: !isOn\n}",
  107.     "outputs": 1,
  108.     "noerr": 0,
  109.     "x": 610,
  110.     "y": 140,
  111.     "wires": [
  112.       [
  113.         "963466b4.1efe38"
  114.       ]
  115.     ]
  116.   },
  117.   {
  118.     "id": "3f20b519.7714ba",
  119.     "type": "http request",
  120.     "z": "d844580f.e9f548",
  121.     "name": "Fetch current state",
  122.     "method": "GET",
  123.     "ret": "obj",
  124.     "url": "http://192.168.178.xx:51826/accessories",
  125.     "tls": "",
  126.     "x": 400,
  127.     "y": 140,
  128.     "wires": [
  129.       [
  130.         "2768fb24.a3e014"
  131.       ]
  132.     ]
  133.   },
  134.   {
  135.     "id": "1a213476.892b7c",
  136.     "type": "inject",
  137.     "z": "d844580f.e9f548",
  138.     "name": "Manual trigger",
  139.     "topic": "",
  140.     "payload": "",
  141.     "payloadType": "date",
  142.     "repeat": "",
  143.     "crontab": "",
  144.     "once": false,
  145.     "onceDelay": 0.1,
  146.     "x": 130,
  147.     "y": 100,
  148.     "wires": [
  149.       [
  150.         "3f20b519.7714ba"
  151.       ]
  152.     ]
  153.   },
  154.   {
  155.     "id": "f2b2a376.09292",
  156.     "type": "mqtt-broker",
  157.     "z": "",
  158.     "name": "localhost",
  159.     "broker": "localhost",
  160.     "port": "1883",
  161.     "clientid": "",
  162.     "usetls": false,
  163.     "compatmode": true,
  164.     "keepalive": "60",
  165.     "cleansession": true,
  166.     "willTopic": "",
  167.     "willQos": "0",
  168.     "willPayload": "",
  169.     "birthTopic": "",
  170.     "birthQos": "0",
  171.     "birthPayload": ""
  172.   }
  173. ]
Advertisement
Add Comment
Please, Sign In to add comment