fishbigger / TapoP100

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

Unable to setup a session/ handshake with TpLink Tapo bulb #123

Open Shakthi-Dhar opened 12 months ago

Shakthi-Dhar commented 12 months ago
File "python/site-packages/PyP100/PyP100.py", line 129, in handshake
encryptedKey = r.json()["result"]["key"]
KeyError: 'result'

I checked the response and it happens to be: {'error_code': 1003}

I am trying to set a connection with my TpLink Tapo L530 bulb and run this code to turn it on and off:

from PyP100 import PyL530

l530 = PyL530.L530("IP Address", "Mail ID", "Password")

l530.handshake()
l530.login()

l530.turnOn()
l530.turnOff()
l530.turnOn()

How do I tackle this issue?

cokeperez commented 11 months ago

Same problem here.

2x Tapo L530 Firmware: 1.1.0 Build 230721 Rel.224802 Hardware: 2.0

OrangeMedia commented 11 months ago

It appears a recent firmware update has broken any integration.

https://www.infosecurity-magazine.com/news/tplink-smart-bulb-wifi-passwords/

Shakthi-Dhar commented 11 months ago

So there is no way to establish communication with the bulb until there is a new firmware update to fix it?

timothy-holmes commented 11 months ago

Another package has fixed this: https://github.com/petretiandrea/plugp100/blob/main/plugp100/protocol/klap_protocol.py#L96

Shakthi-Dhar commented 11 months ago

Another package has fixed this: https://github.com/petretiandrea/plugp100/blob/main/plugp100/protocol/klap_protocol.py#L96

@timothy-holmes do you have any example code on how I can perform actions like color and brightness change, on and off? Thank you.

bunbunet commented 11 months ago

I'm new to python and have little experience in coding, however through Tapo L530, a microphone and this libraries I built a system that give light feedback to control the noise generated by the customers of winery. This system represented an important point of equilibrium between the winery and my condo after month of frictions.. but it is now broken! Is there any chance that these libraries will be fixed? Or alternatively can anybody suggest me an alternative? Thank you very much for any help!

vasishta-kanthi commented 11 months ago

Hi ,

I have the exact same response for the P100 plug device. Until today, 2023/09/12, I was able to utilize the package and create a wrapper class to control the switch. Now I get the same error when executing the handshake() function, as the JSON response I get is:

{'error_code' : 1003}

@fishbigger , I hope it is okay to tag you for this >.<

timothy-holmes commented 11 months ago

Another package has fixed this: https://github.com/petretiandrea/plugp100/blob/main/plugp100/protocol/klap_protocol.py#L96

@timothy-holmes do you have any example code on how I can perform actions like color and brightness change, on and off? Thank you.

I haven't tested this so may have some errrors, but it would probably go something like:

from plugp100.api.tapo_client import TapoClient, AuthCredential
from plugp100.api.light_device import LightDevice

credential = AuthCredential('<tapo_email>', '<tapo_password>')
client = await TapoClient.connect(credential, '<ip_address>')
light = LightDevice(client, "<device-ip>")
await light.on()
await light.off()
await light.set_hue_saturation(hue=120, saturation=100)

(of course, you'll need to install it beforehand with pip install plugp100)

bunbunet commented 11 months ago

Dear, @timothy-holmes, thank you very much for your help! I installed the package and tried your code, the example code on the project page but I'm already stuck at library import. I assume the modules that should be imported may be in some other form or order... Moreover it is not clear to me why I should indicate two different ip adress, one for the TapoClient and one for Light device, but I suppose it should be the same. thank you very much for any additional help.. if possible! Federico

StephenBerlin commented 11 months ago

Tried getting plugp100 working using the code from @timothy-holmes, but no luck. Do we know if someone is planning to update the existing PyP100 module so that this works again? Thank you!

manuhakala98 commented 10 months ago

Im also interester if someone could fix this issue asap. KeyError result also here.

istvan73 commented 10 months ago

Same thing here, getting KeyError, and I've already bought 5 of them to control an escape room :'D Some hero of coding please help us!

manuhakala98 commented 10 months ago

Same thing here, getting KeyError, and I've already bought 5 of them to control an escape room :'D Some hero of coding please help us!

I got it to work by using this library: https://github.com/petretiandrea/plugp100/tree/main

Just rebember to use python 3.9. And when you get TypeError check 3rd topic from Issues page.

Cosik commented 10 months ago

Hi, in general I think that lib is dead, author is not responding, many PRs are hanging without response from @fishbigger

almottier commented 10 months ago

Hello, I forked the project and added the new auth support. I tested it with P100 version 1.2.1 and it works great.

Let me know if it works for you.

m-mihaly commented 10 months ago

Hi @almottier,

Thanks for the great work, but please check again PyL530.py and PyP110.py, it says:

from TapoP100.PyP100.PyP100 import ...

If I install it with pip, there's no TapoP100 package. When I change it like this, it works:

from PyP100.PyP100 import ...

almottier commented 10 months ago

Hello @m-mihaly , Thanks, it should be fixed now. I also added support for old firmware using a fallback to the old authentication mechanism.

StephenBerlin commented 10 months ago

Thank you @almottier!!!

All my P100's are working again... both hw version 1.20.0 + fw 1.5.5, and hw version 2.0 + fw 1.2.1 are all working.

Thank you!!

kayakingJeff commented 8 months ago

Thank you @almottier for fixing this. I really appreciate it.