The secret and iv is returned after the private key sent to the plug at the really first step.
The returned message is encrypted with the public key and should be decrypted by your private key and then split to two byte arrays, secret and iv. (It is not just straight base64 encoded as many would think with RSA.)
Sorry! Iāve written python implementation too fast and Iāve made really stupid errors.
Iāve updated my python code and it is working now (handshake, login and changing state)!
I would suggest using my repository for the pip package because it already works and only needs some cleanup / further implementation.
@K4CZP3R and @fishbigger thank you so much for all the hard work putted into this I cloned @K4CZP3R repo, yesterday night and Iām currently trying to get it to work with my plugs Correct me if Iām wrong, but only the main.py file needs to be customized? Iāll try to interpret the code, but tbh my programming and python skills arenāt awesome!
Once again thanks for all your hard work!
Iāve updated my python repo, if it still does not work: try to use java implementation (for this one, Iām 100% sure itās handles encryption the same way as android app)
@K4CZP3R I have made a fork where I added a method to get the device state. Unsurprisingly, the method to call is āget_device_infoā.
The method can return a lot of interesting stuff, like the firmware version, how long the plug is turned on, if itās overheating, etc. For now I only added a method to check if the plug is turned on to the P100 class.
Unfortunatelly Iām still getting the same error code.
Iāve even switched one of my outlets to a new tplink account but I still get the same result.
Out of curiosity, which firmware versions do you guys have on your p100?
100% sure, even changed password and created a new TP-Link ID and associated one of my extra plugs to it just to make sure that it was not an account issue
@dsoklic Another further step on troubleshooting tried to add the devices to my account via Android application instead of iOS application but unfortunately the result is exactly the same.
Will try to dig a bit further, but Iām actually running out of ideas