If you have followed my series on how to control the TP-Link HS100 smart plug by communicating with TP-Link Cloud services, you might have seen that there are some common issues related to the URL one need to point the requests to.
I’ve found out a way to know what is the URL, no more hit and miss needed any more!
The only thing that you’ll need is your TP-Link token (see how to get it). In a terminal, run the following command:
curl -s --request POST "https://wap.tplinkcloud.com?token=YOUR_TOKEN_HERE HTTP/1.1" \
--data '{"method":"getDeviceList"}' \
--header "Content-Type: application/json"
As an alternative, you can use hurl.it, an online version of curl, like shown on the picture below:
As Parameters use simply this:
{"method":"getDeviceList"}
As the name of the method implies, this will list all your HS100 devices (maybe other, please tell me what you see!). You should get something like this:
{ "result" : { "deviceList" : [ { "appServerUrl" : "https://eu-wap.tplinkcloud.com", "isSameRegion" : true, "deviceMac" : "", "status" : 1, "hwId" : "XXXX....", "deviceId" : "XXXX....", "oemId" : "XXXX....", "fwVer" : "1.0.8 Build 151101 Rel.24452", "deviceType" : "IOT.SMARTPLUGSWITCH", "alias" : "My Smart Plug", "fwId" : "BFF24826FBC561803E49379DBE74FD71", "deviceName" : "Wi-Fi Smart Plug", "deviceHwVer" : "1.0", "role" : 0, "deviceModel" : "HS100(EU)" } ] }, "error_code" : 0 }
In the results above, we’ll get a list of all our TPLink devices, with their alias (the custom name we have given it), the deviceId, and the appServerUrl.
The appServerUrl is the one we’ll need to use in further POST requests, to control the plug.