I'm trying to turn on my TP-Link HS110 from AWS Lambda. I'm using Python 3.6. I imported json and requests into Lambda, this seems to work fine. Its actually performing the request, but the TP-Link Cloud Api is responding with [error_code:-20651, msg:Token expired]. But the token is working (double checked), if I use cURL so thats not the problem. Also generated a new token but stil not working in Lambda. Does anyone see an error in the code or knows about this issue?
url = 'https://eu-wap.tplinkcloud.com/?token=token HTTP/1.1'
payload = {
"method":"passthrough",
"params":
{ "deviceId": "abc",
"requestData": "{\"system\":{\"set_relay_state\":{\"state\":1}}}"
}
}
payload = json.dumps(payload)
response = requests.post(url,payload,{'Content-Type': 'application/json'})