Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": "d319586a.ea3e68",
- "type": "mqtt in",
- "z": "d844580f.e9f548",
- "name": "Sonoff T1",
- "topic": "cmnd/sonoff-t1-toggle/POWER",
- "qos": "2",
- "broker": "f2b2a376.09292",
- "x": 120,
- "y": 160,
- "wires": [
- [
- "3f20b519.7714ba"
- ]
- ]
- },
- {
- "id": "c3c5bd72.d3596",
- "type": "http request",
- "z": "d844580f.e9f548",
- "name": "Send characteristics update",
- "method": "PUT",
- "ret": "txt",
- "url": "http://192.168.178.xx:51826/characteristics",
- "tls": "",
- "x": 880,
- "y": 240,
- "wires": [
- []
- ]
- },
- {
- "id": "963466b4.1efe38",
- "type": "change",
- "z": "d844580f.e9f548",
- "name": "Construct payload",
- "rules": [
- {
- "t": "set",
- "p": "payload",
- "pt": "msg",
- "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] }",
- "tot": "json"
- },
- {
- "t": "set",
- "p": "payload.characteristics[0].value",
- "pt": "msg",
- "to": "isOn",
- "tot": "msg"
- },
- {
- "t": "set",
- "p": "payload.characteristics[1].value",
- "pt": "msg",
- "to": "isOn",
- "tot": "msg"
- }
- ],
- "action": "",
- "property": "",
- "from": "",
- "to": "",
- "reg": false,
- "x": 390,
- "y": 240,
- "wires": [
- [
- "6eabc434.be916c"
- ]
- ]
- },
- {
- "id": "6eabc434.be916c",
- "type": "change",
- "z": "d844580f.e9f548",
- "name": "Add HTTP headers",
- "rules": [
- {
- "t": "set",
- "p": "headers",
- "pt": "msg",
- "to": "{\"Content-type\" : \"application/json\",\"Authorization\": \"871-13-321\"}",
- "tot": "json"
- }
- ],
- "action": "",
- "property": "",
- "from": "",
- "to": "",
- "reg": false,
- "x": 610,
- "y": 240,
- "wires": [
- [
- "c3c5bd72.d3596"
- ]
- ]
- },
- {
- "id": "2768fb24.a3e014",
- "type": "function",
- "z": "d844580f.e9f548",
- "name": "isOn",
- "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}",
- "outputs": 1,
- "noerr": 0,
- "x": 610,
- "y": 140,
- "wires": [
- [
- "963466b4.1efe38"
- ]
- ]
- },
- {
- "id": "3f20b519.7714ba",
- "type": "http request",
- "z": "d844580f.e9f548",
- "name": "Fetch current state",
- "method": "GET",
- "ret": "obj",
- "url": "http://192.168.178.xx:51826/accessories",
- "tls": "",
- "x": 400,
- "y": 140,
- "wires": [
- [
- "2768fb24.a3e014"
- ]
- ]
- },
- {
- "id": "1a213476.892b7c",
- "type": "inject",
- "z": "d844580f.e9f548",
- "name": "Manual trigger",
- "topic": "",
- "payload": "",
- "payloadType": "date",
- "repeat": "",
- "crontab": "",
- "once": false,
- "onceDelay": 0.1,
- "x": 130,
- "y": 100,
- "wires": [
- [
- "3f20b519.7714ba"
- ]
- ]
- },
- {
- "id": "f2b2a376.09292",
- "type": "mqtt-broker",
- "z": "",
- "name": "localhost",
- "broker": "localhost",
- "port": "1883",
- "clientid": "",
- "usetls": false,
- "compatmode": true,
- "keepalive": "60",
- "cleansession": true,
- "willTopic": "",
- "willQos": "0",
- "willPayload": "",
- "birthTopic": "",
- "birthQos": "0",
- "birthPayload": ""
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment