Created
July 7, 2019 11:33
-
-
Save adumont/dbc679320ca68f6c1a149c2f4fe9a439 to your computer and use it in GitHub Desktop.
TP-Link Cloud API subflow for HS100 in Node-Red
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id":"577621a6.54f19", | |
"type":"http request", | |
"z":"cc2c159c.fd5868", | |
"name":"login", | |
"method":"POST", | |
"ret":"obj", | |
"url":"https://wap.tplinkcloud.com", | |
"tls":"", | |
"x":634.0000152587891, | |
"y":379.00003719329834, | |
"wires":[ | |
[ | |
"474031f2.7a4c1" | |
] | |
] | |
}, | |
{ | |
"id":"ff6681c3.3a6dd", | |
"type":"function", | |
"z":"cc2c159c.fd5868", | |
"name":"login payload", | |
"func":"//msg.state=msg.req.body.state\nmsg.state=parseInt(msg.payload)\n\nmsg.headers = {\n 'Content-Type': 'application/json'\n};\n\nmsg.payload = {\n \"method\":\"login\",\n \"params\":\n {\"appType\":\"Kasa_Android\",\n \"cloudPassword\":\"PASSWORD\",\n \"cloudUserName\":\"USERNAME\",\n \"terminalUUID\":\"\"\n }\n};\nreturn msg;\n", | |
"outputs":1, | |
"noerr":0, | |
"x":434.00001525878906, | |
"y":379.00003719329834, | |
"wires":[ | |
[ | |
"577621a6.54f19" | |
] | |
] | |
}, | |
{ | |
"id":"40c629d2.6cf4d8", | |
"type":"inject", | |
"z":"cc2c159c.fd5868", | |
"name":"", | |
"topic":"", | |
"payload":"1", | |
"payloadType":"str", | |
"repeat":"", | |
"crontab":"", | |
"once":false, | |
"onceDelay":"", | |
"x":196.00000762939453, | |
"y":178.00004196166992, | |
"wires":[ | |
[ | |
"c2124ad9.902e58" | |
] | |
] | |
}, | |
{ | |
"id":"474031f2.7a4c1", | |
"type":"function", | |
"z":"cc2c159c.fd5868", | |
"name":"prep getDevice", | |
"func":"// global.set(\"TOKEN\",msg.payload.result.token);\n\nmsg.token=msg.payload.result.token; // {{token}}\nmsg.payload = {\"method\":\"getDeviceList\"};\nmsg.headers = {\n 'Content-Type': 'application/json'\n};\n\nreturn msg;", | |
"outputs":1, | |
"noerr":0, | |
"x":424.00001525878906, | |
"y":479.00003719329834, | |
"wires":[ | |
[ | |
"6638bac4.1709a4" | |
] | |
] | |
}, | |
{ | |
"id":"6638bac4.1709a4", | |
"type":"http request", | |
"z":"cc2c159c.fd5868", | |
"name":"getDevices", | |
"method":"POST", | |
"ret":"obj", | |
"url":"https://wap.tplinkcloud.com?token={{token}}", | |
"tls":"", | |
"x":654.0000152587891, | |
"y":479.00003719329834, | |
"wires":[ | |
[ | |
"207c0e02.e8af12" | |
] | |
] | |
}, | |
{ | |
"id":"207c0e02.e8af12", | |
"type":"function", | |
"z":"cc2c159c.fd5868", | |
"name":"prep set_relay_state", | |
"func":"msg.url=msg.payload.result.deviceList[0].appServerUrl + \"/?token=\" + msg.token\nmsg.deviceId=msg.payload.result.deviceList[0].deviceId\n\nmsg.headers = {\n 'Content-Type': 'application/json'\n};\n\nvar requestData = {\"system\":{\"set_relay_state\":{\"state\": msg.state }}}\n\nmsg.payload = {\n \"method\":\"passthrough\",\n \"params\": {\n \"deviceId\": msg.deviceId,\n \"requestData\": JSON.stringify(requestData)\n }\n};\n\nreturn msg;", | |
"outputs":1, | |
"noerr":0, | |
"x":404.00001525878906, | |
"y":579.0000371932983, | |
"wires":[ | |
[ | |
"65bad848.96e478" | |
] | |
] | |
}, | |
{ | |
"id":"65bad848.96e478", | |
"type":"http request", | |
"z":"cc2c159c.fd5868", | |
"name":"set_relay_state", | |
"method":"POST", | |
"ret":"obj", | |
"url":"", | |
"tls":"", | |
"x":664.0000152587891, | |
"y":579.0000371932983, | |
"wires":[ | |
[ | |
] | |
] | |
}, | |
{ | |
"id":"7eb71a77.652674", | |
"type":"comment", | |
"z":"cc2c159c.fd5868", | |
"name":"!!!creds here!!!", | |
"info":"", | |
"x":434.00001525878906, | |
"y":339.00003719329834, | |
"wires":[ | |
] | |
}, | |
{ | |
"id":"d00c2796.33c448", | |
"type":"inject", | |
"z":"cc2c159c.fd5868", | |
"name":"", | |
"topic":"", | |
"payload":"0", | |
"payloadType":"num", | |
"repeat":"", | |
"crontab":"", | |
"once":false, | |
"onceDelay":"", | |
"x":197.0000114440918, | |
"y":224.00004291534424, | |
"wires":[ | |
[ | |
"c2124ad9.902e58" | |
] | |
] | |
}, | |
{ | |
"id":"c2124ad9.902e58", | |
"type":"rbe", | |
"z":"cc2c159c.fd5868", | |
"name":"", | |
"func":"rbe", | |
"gap":"", | |
"start":"", | |
"inout":"out", | |
"property":"payload", | |
"x":374.00001525878906, | |
"y":199.00003719329834, | |
"wires":[ | |
[ | |
"ff6681c3.3a6dd" | |
] | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment