fishbigger / TapoP100

A module for controlling the TP-Link Tapo P100 Plugs
MIT License
572 stars 142 forks source link

Timeout when connecting to Tapo P110 smart plug #68

Closed RobertVoorn1977 closed 2 years ago

RobertVoorn1977 commented 2 years ago

Apologies if this is the wrong location to request help on getting this code to work, but could not find any other way on this project page to ask for help. If I overlooked the correct way of asking for help, please let me know the correct way.

I am assuming that the Tapo P110 smart plug is supported by this project.

After installing the dependency with 'pip3 install PyP100', I cannot get the below code to work (taken straight from the README.md page):

from PyP100 import PyP100

p100 = PyP100.P100("192.168.X.X", "email@gmail.com", "Password123") #Creating a P100 plug object

p100.handshake() #Creates the cookies required for further methods
p100.login() #Sends credentials to the plug and creates AES Key and IV for further methods

p100.turnOn() #Sends the turn on request
p100.turnOff() #Sends the turn off request
p100.getDeviceInfo() #Returns dict with all the device info

I have of course substituted the IP address (from the working Tapo android app) and user name and password (the same as what I use to log into the Tapo account). When I run the code, there is a stacktrace suggesting there is a timeout. The Tapo app on my phone works fine.

I have only added the last part of the stack trace because as far as I can see, that is the most important/interesting one

Traceback (most recent call last): File "/Users/robafett/PycharmProjects/BatterySaver/venv/lib/python3.9/site-packages/requests/adapters.py", line 507, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='192.168.5.129', port=80): Max retries exceeded with url: /app (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x10b6b4a90>, 'Connection to 192.168.5.129 timed out. (connect timeout=2)')) python-BaseException

leuchtetgruen commented 2 years ago

I’m experiencing the same Issue. How did you solve it?

RobertVoorn1977 commented 2 years ago

I fixed it by using the correct factory method:

p110 = PyP110.P110(ip_address, user, password)

Simple, really, once you discover this

leuchtetgruen commented 2 years ago

Ah, I missed that mistake in the code that you first posted.

In my case it was enough to unplug and replug the P110, it just for some reason didnt start the HTTP server on the plug itself and was thus really not reachable via the API.

Thank you :)