TP-Link Tapo P100

I see you don’t have the terminalUUID in your request, but I don’t know if that is the cause.

1 Like

Yeh that was the first thought I had after posting. Sadly though it still came back with the same error. However I did put in the get_device_info method and it worked. I’m not sure what’s going on with the turn on and off commands but I will keep looking :slight_smile:

1 Like

I think the method should be “set_device_info”, not “set_device_state” :slight_smile:

3 Likes

I’m so stupid!!! Thank you so much :grinning: Finally it works!

All my code is now on github!!! https://github.com/fishbigger/TapoP100
I have also created a pip package which can be installed using

pip3 install PyP100

All the documentation is on the github readme or at https://pypi.org/project/PyP100/

I will start work on a home assistant intergration soon!!

4 Likes

@fishbigger Great work man, already installed your module, unfortunately I`m still having the same issues as before :frowning:

Hmmmm, strange.
Can you confirm that the error message is this when performing the login request

Exception: Error Code: -1501, Invalid Request or Credentials

Also, I know you have tried many accounts but have you actually toggled the plug from the app in these accounts as this will authenticate those credentials.

Finally, I am using firmware version 1.1.8 Build 20200408 Rel. 64448 and hardware version 1.0.0

Hello Guys, amazing work congratulations!!!

I have been testing the module and it seems to work after a few fixes in the @fishbigger module. I noticed that on the turnon and turnoff functions you had your plugs IP and MAC adresses, after changing it to mine it works.

I also had the same issue as pnmoliveira, but i dont know how it seems fixed now. Be careful putting your IP email and password inside the " ".

Thank you for the work, specially to @K4CZP3R and all the people that has worked on this post.

1 Like

Thanks, I will change that later the invalid MAC address could be the cause of the invalid credentials error but I will do some more tests :slight_smile:

Ok I have updated the package which should fix all of the immediate bugs. I am now working on the integration which should be out soon.

@fishbigger so now you also need to push the mac address when calling

p100 = PyP100.P100("192.168.X.X", "[email protected]", "Password123")

Or it’s a hardcoded parameter?
I’ll try to upgrade the pip package and test then :wink:

I think you also get the MAC address when you retrieve the plug info, so the user doesn’t need to know it.

My tests showed that the request works fine without the mac address but raised errors with an incorrect mac address. If the error still persists I can do as @dsoklic suggested by getting the device info.

Hi
I’ve been following this thread with interest. I’ve got a P100 also with firmware 1.1.8 Build 20200408 Rel. 64448.
I’ve installed the pyP100 module via pip and getting the same error as pnmoliveira, although the full error message is:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/PyP100/PyP100.py", line 155, in login
    self.token = ast.literal_eval(decryptedResponse)["result"]["token"]
KeyError: 'result'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tapotest.py", line 7, in <module>
    p.login()
  File "/usr/local/lib/python3.6/dist-packages/PyP100/PyP100.py", line 159, in login
    raise Exception(f"Error Code: {errorCode}, {errorMessage}")
Exception: Error Code: -1501, Invalid Request or Credentials

In case it makes any difference, this is Ubuntu 18.04 with Python 3.6.9.

I have logged into the Tapo app with the same credentials and cycled a bulb ok.

What is your full script?

#!/usr/bin/env python3
from PyP100 import PyP100

p = PyP100.P100('192.168.1.157', 'xxxxx', 'xxxxxx')

p.handshake()
p.login()
p.turnOn()
p.getDeviceInfo()

Sniffing the traffic I can see the Handshake and receiving the TP_SESSIONID and I can see the securepassthrough request (I presume is initiated by the login()) and I can see the response received.

{"error_code":0,"result":{"response":"SBrm0p3lTggkXcT+26LMpTu/U02WHNODMblXuCh/NGg="}

I installed the latest version from @fishbigger module and now is working flawlessly :slight_smile: just tested it on my 3 plugs and everything is working :slight_smile:

1 Like

Glad to hear that it works!! Most of the work came from @K4CZP3R though :slight_smile: Hopefully I can get the integration sorted soon.

2 Likes

@fishbigger sorry to bother does the .getDeviceInfo() returns anything automatically or do you need to assign it to var to print the result?
I’m asking because i’m not getting anything from it.

You need to use

print (p100.getDeviceInfo())

or assign it to a variable then print it like this:

deviceInfo = p100.getDeviceInfo()
print(deviceInfo)

or you could take out specific info like this:

deviceInfo = p100.getDeviceInfo()
print(deviceInfo["fw_ver"]) #Prints out current firmware version

:slight_smile:

1 Like