Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [{"id":"a0ec199.d7c79e8","type":"server-events","z":"5eb3594f.d294b8","name":"","server":"ef067c6f.620e6","event_type":"deconz_event","x":244,"y":1360,"wires":[["96f94e56.3bcf2"]]},{"id":"96f94e56.3bcf2","type":"function","z":"5eb3594f.d294b8","name":"","func":"const code = msg.payload.event.event;\nlet action;\n\nconst codes = { \n    \"slide\": [1000, 2000, 3000, 4000, 5000, 6000],\n    \"double tap\": [1001, 2002, 3003, 4004, 5005, 6006],\n    \"flip180\": [1006, 2005, 3004, 4003, 5002, 6001],\n    \"flip90\": [1002, 1003, 1004, 1005, 2001, 2003, 2004, 2006, 3001, 3002, 3005, 3006, 4001, 4002, 4005, 4006, 5001, 5003, 5004, 5006, 6002, 6003, 6004, 6005],\n    \"shake\": [7007],\n    \"fall\": [7008],\n    \"wake\": [7000]\n};\n\nfor (let a in codes) {\n    if(codes[a].includes(code)) {\n        action = a;\n        break;\n    }\n}\n\nif (!action) {\n    const strCode = String(code);\n    if (strCode.substr(1,2) !== \"00\" || strCode.length !== 4) {\n        action = code > 0 ? \"rotate cw\" : \"rotate ccw\";\n    }\n}\n\nmsg.payload = action || \"\";\n\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":1360,"wires":[["5846c38a.09bd6c"]]},{"id":"5846c38a.09bd6c","type":"switch","z":"5eb3594f.d294b8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"slide","vt":"str"},{"t":"eq","v":"double tap","vt":"str"},{"t":"eq","v":"flip180","vt":"str"},{"t":"eq","v":"flip90","vt":"str"},{"t":"eq","v":"shake","vt":"str"},{"t":"eq","v":"fall","vt":"str"},{"t":"eq","v":"wake","vt":"str"},{"t":"eq","v":"rotate cw","vt":"str"},{"t":"eq","v":"rotate ccw","vt":"str"}],"checkall":"false","repair":false,"outputs":9,"x":572,"y":1360,"wires":[[],[],[],[],[],[],[],[],[]]}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement