almottier / TapoP100

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

Failed to initialize protocol AuthProtocol #11

Open OreoOba opened 10 months ago

OreoOba commented 10 months ago

Thanks for solving the problem Just a small add to your comments Be carefull if you combine devices with the old protocol and the new one. 1) Add the preferred_protocol="old" at the inital statement of each old device 2) Don't delete the p100.handshake() and p100.login() for the devices that keep the old protocol

almottier commented 9 months ago

Hello,

  1. Yes you need to add preferred_protocol="old" for all old devices individually
  2. You should not need handshake() or login() , even for old devices. Please share the error if you still have an issue without it.
raucal commented 9 months ago

I still get this error even though I add the "old" argument. MY code:

from PyP100 import PyP110 p110 = PyP110.P110("192.168.1.84", "xxx", "yyy",preferred_protocol="old" ) p110.getEnergyUsage()

Error:

Error: {'error_code': 1003} Failed to initialize protocol OldProtocol Traceback (most recent call last): File "c:\Users\34652\Documents\Python\Domótica\PyP100\PyP100.py", line 32, in _initialize protocol.Initialize() File "c:\Users\34652\Documents\Python\Domótica\PyP100\auth_protocol.py", line 244, in Initialize result = self._request_raw("handshake", {"key": public_key}) File "c:\Users\34652\Documents\Python\Domótica\PyP100\auth_protocol.py", line 173, in _request_raw raise Exception(f"Error code: {data['error_code']}") Exception: Error code: 1003 Traceback (most recent call last): File "c:\Users\34652\Documents\Python\Domótica\prueba.py", line 4, in p110.getEnergyUsage() File "c:\Users\34652\Documents\Python\Domótica\PyP100\PyP100.py", line 106, in getEnergyUsage return self.request("get_energy_usage") File "c:\Users\34652\Documents\Python\Domótica\PyP100\PyP100.py", line 43, in request self._initialize() File "c:\Users\34652\Documents\Python\Domótica\PyP100\PyP100.py", line 39, in _initialize raise Exception("Failed to initialize protocol") Exception: Failed to initialize protocol