TapoP100 icon indicating copy to clipboard operation
TapoP100 copied to clipboard

P100 - Failed to initialize protocol AuthProtocol

Open saepien opened this issue 11 months ago • 10 comments

I have a P115 Smart Plug

Failed to initialize protocol AuthProtocol Traceback (most recent call last): File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/PyP100/PyP100.py", line 35, in _initialize protocol.Initialize() ~~~~~~~~~~~~~~~~~~~^^ File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/PyP100/auth_protocol.py", line 110, in Initialize raise Exception("Failed to authenticate") Exception: Failed to authenticate Error: {'error_code': 1003} Failed to initialize protocol OldProtocol Traceback (most recent call last): File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/PyP100/PyP100.py", line 35, in _initialize protocol.Initialize() ~~~~~~~~~~~~~~~~~~~^^ File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/PyP100/auth_protocol.py", line 244, in Initialize result = self._request_raw("handshake", {"key": public_key}) File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/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 "", line 1, in p100.turnOn() ~~~~~~~~~~~^^ File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/PyP100/PyP100.py", line 95, in turnOn return self.set_status(True) ~~~~~~~~~~~~~~~^^^^^^ File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/PyP100/PyP100.py", line 92, in set_status return self._set_device_info({"device_on": status}) ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/PyP100/PyP100.py", line 64, in _set_device_info return self.request("set_device_info", params) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/PyP100/PyP100.py", line 46, in request self._initialize() ~~~~~~~~~~~~~~~~^^ File "/Users/storm/dev/sandbox/tapo/env/lib/python3.13/site-packages/PyP100/PyP100.py", line 42, in _initialize raise Exception("Failed to initialize protocol") Exception: Failed to initialize protocol

saepien avatar Dec 25 '24 22:12 saepien

Could you make sure your credentials are correct using the official website: https://tapo.tplinkcloud.com/tapo_web/#/login/signIn

almottier avatar Jan 11 '25 11:01 almottier

I have the same issue with one of my 4 P100s which was recently commissioned. My login is working in the link above.

Failed to initialize protocol AuthProtocol
Traceback (most recent call last):
  File "/share/tapo/venv/lib/python3.9/site-packages/PyP100/PyP100.py", line 35, in _initialize
    protocol.Initialize()
  File "/share/tapo/venv/lib/python3.9/site-packages/PyP100/auth_protocol.py", line 110, in Initialize
    raise Exception("Failed to authenticate")
Exception: Failed to authenticate
Error: {'error_code': 1003}
Failed to initialize protocol OldProtocol
Traceback (most recent call last):
  File "/share/tapo/venv/lib/python3.9/site-packages/PyP100/PyP100.py", line 35, in _initialize
    protocol.Initialize()
  File "/share/tapo/venv/lib/python3.9/site-packages/PyP100/auth_protocol.py", line 244, in Initialize
    result = self._request_raw("handshake", {"key": public_key})
  File "/share/tapo/venv/lib/python3.9/site-packages/PyP100/auth_protocol.py", line 173, in _request_raw
    raise Exception(f"Error code: {data['error_code']}")
Exception: Error code: 1003

I am also having a "KLAP handshake failed" error using this homebridge plugin. All other P100s are working with this as well.

danricho avatar Mar 19 '25 22:03 danricho

Same issue with tapo version 1.4.0 build 250901 rel. 175625. I had automatic updates on, and the new release hangs the connection...

Error: {'error_code': 1003} Failed to initialize protocol OldProtocol

Could be "OldProtocol" is the cause of error? and how can I switch to the NewProtocol?

Thank you in advance

JanusHL avatar Oct 17 '25 11:10 JanusHL

Umm, I have check the new protocol and I receive the same error...

It seems the error is caused by "requests" module...

raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://192.168.20.103/app/handshake1

JanusHL avatar Oct 17 '25 11:10 JanusHL

check this if you are using version 1.4.0 : https://github.com/almottier/TapoP100/issues/35#issue-3523292729

almottier avatar Oct 17 '25 11:10 almottier

I don't see this option in my config, only Alexa, google Samsung and something named IFTTT...

JanusHL avatar Oct 17 '25 11:10 JanusHL

I don't see this option in my config, only Alexa, google Samsung and something named IFTTT...

try to update the Tapo app

almottier avatar Oct 17 '25 12:10 almottier

I've updated the app and now appears the option and finally the script works...

Thank you almottier.

JanusHL

JanusHL avatar Oct 17 '25 12:10 JanusHL

Thanks for the solution altmottier!, it was just so damn hard to find again.

I used your repository before, eventually installed multiple different versions and none worked, only to search for a version that contains the "get_status()" function, leading me back here. Still didn't work, until in a comment I found that the "3rd party connections" need to be allowed in the "Tapo App". Long story short, one damn setting can lead you down a rabbit hole, and I would love to help others avoid that dilemma.

Therefore I would like to ask @almottier to please include the fact that the repository works with "Tapo P100 plugs firmware 1.4.0" ONLY if the "Third-Party Compatibility" is activated. The setting can be found in the "TAPO App" under "Me > Third-Party-Services > Third-Party Compatibility".

I take no credit here, as the information is essentially already spread out over the issues, but that sadly made it impossible to find the solution (search engines, even AI won't find the associated facts here), which is sad.

So please add the collected information in one place, for future searches.

Best regards, Patrick

Xylvier avatar Oct 23 '25 13:10 Xylvier

Hello @Xylvier, I updated the project readme, thanks.

almottier avatar Oct 23 '25 13:10 almottier