Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to authenticate to Tapo Plug P110 #113137

Closed
kayg04 opened this issue Mar 12, 2024 · 13 comments
Closed

Unable to authenticate to Tapo Plug P110 #113137

kayg04 opened this issue Mar 12, 2024 · 13 comments

Comments

@kayg04
Copy link

kayg04 commented Mar 12, 2024

The problem

Hey, I got my 4th Tapo Plug P110 but this one has this peculiar problem where I am not able to authenticate with my credentials. I am hit by a:

CleanShot 2024-03-12 at 13 06 17@2x

I have enabled debug logging and this is what I see:

2024-03-12 13:02:24.425 DEBUG (MainThread) [kasa.klaptransport] Created KLAP transport for 10.0.0.177
2024-03-12 13:02:24.425 DEBUG (MainThread) [kasa.smartdevice] Initializing 10.0.0.177 of type <class 'kasa.tapo.tapoplug.TapoPlug'>
2024-03-12 13:02:24.425 DEBUG (MainThread) [kasa.smartprotocol] 10.0.0.177 >> '{"method":"component_nego","params":null,"requestID":1217133100610490368,"request_time_milis":1710228744425,"terminal_uuid":"xP13KpyOc+0UmPXDwSirhw=="}'
2024-03-12 13:02:24.425 DEBUG (MainThread) [kasa.klaptransport] Starting handshake with 10.0.0.177
2024-03-12 13:02:24.589 DEBUG (MainThread) [kasa.klaptransport] Handshake1 posted at 2024-03-12 13:02:24.589537. Host is 10.0.0.177, Responsestatus is 200, Request was 23fd37ac3b44227c6107ce79e7841e9d
2024-03-12 13:02:24.589 DEBUG (MainThread) [kasa.klaptransport] Handshake1 success at 2024-03-12 13:02:24.589637. Host is 10.0.0.177, Server remote_seed is: c55826498b4ee0218546f93ab8d2a8ef, server hash is: 2c3314f4c0aaee28a2fd9939285492b04ac4fd5684853c011db3befdbfb44b32
2024-03-12 13:02:24.589 DEBUG (MainThread) [kasa.klaptransport] Server response doesn't match our challenge on ip 10.0.0.177
2024-03-12 13:02:24.589 DEBUG (MainThread) [kasa.smartprotocol] Unable to authenticate with 10.0.0.177, not retrying

Of course I can login with the same creds on the web as well as on the app.

What version of Home Assistant Core has the issue?

core-2024.3.0

What was the last working version of Home Assistant Core?

core-2024.3.0

What type of installation are you running?

Home Assistant OS

Integration causing the issue

tplink smart home

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tplink

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

Hey there @rytilahti, @TheGardenMonkey, @bdraco, @sdb9696, mind taking a look at this issue as it has been labeled with an integration (tplink) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of tplink can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign tplink Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tplink documentation
tplink source
(message by IssueLinks)

@sdb9696
Copy link
Contributor

sdb9696 commented Mar 12, 2024

Can you tell us the device hardware and firmware version? Would you be able to run discovery against the device via the kasa command line tool that gets installed with the python-kasa library?

@kayg04
Copy link
Author

kayg04 commented Mar 12, 2024

It's the exact same version as the 3 other plugs i have. For example, this is one of the working ones:

Hardware Version
1.0
Firmware Version
1.1.0 Build 230919 Rel.085406

and the one that doesn't work:

Hardware Version
1.0
Firmware Version
1.1.0 Build 230919 Rel.085406

and yes, I'll be able to run commands directly.

@sdb9696
Copy link
Contributor

sdb9696 commented Mar 12, 2024

Apologies if this an obvious question but have you deleted it from HA, restarted HA and then tried adding again?

@kayg04
Copy link
Author

kayg04 commented Mar 12, 2024

Hey, I'm not home yet so i couldn't test with the kasa cli yet but I've tried restarting HA, restarting my router, removing the plug from the tapo app and readding it there. None of that worked.

I didn't remove any of the existing working ones from HA in fear of not being able to add them again.

@kayg04
Copy link
Author

kayg04 commented Mar 12, 2024

On one of the working plugs:

$ kasa --host 10.0.0.164 --username 'bla' --password 'bla'  --device-family SMART.TAPOPLUG --debug off
No --type or --device-family and --encrypt-type defined, discovering..
DEBUG:kasa.discover:[DISCOVERY] 10.0.0.164 >> {'system': {'get_sysinfo': None}}
DEBUG:kasa.discover:Waiting a total of 5 seconds for responses...
DEBUG:kasa.klaptransport:Created KLAP transport for 10.0.0.164
DEBUG:kasa.discover:[DISCOVERY] 10.0.0.164 << {'result': {'device_id': 'badf8db6147a48c79eda05f2a963354e', 'owner': '25518990389A675C868EFAD265EF585D', 'device_type': 'SMART.TAPOPLUG', 'device_model': 'P110(IN)', 'ip': '10.0.0.164', 'mac': '98-25-4A-B9-F1-37', 'is_support_iot_cloud': True, 'obd_src': 'tss', 'factory_default': False, 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'KLAP', 'http_port': 80, 'lv': 2}}, 'error_code': 0}
DEBUG:kasa.smartdevice:Initializing 10.0.0.164 of type <class 'kasa.tapo.tapoplug.TapoPlug'>
Turning off None
DEBUG:kasa.smartprotocol:10.0.0.164 >> '{"method":"set_device_info","params":{"device_on":false},"requestID":1217285921611845632,"request_time_milis":1710265179791,"terminal_uuid":"rhErab5TBHfSGxFJDrwZpQ=="}'
DEBUG:kasa.klaptransport:Starting handshake with 10.0.0.164
DEBUG:kasa.klaptransport:Handshake1 posted at 2024-03-12 17:39:40.110636. Host is 10.0.0.164, Responsestatus is 200, Request was db1aa518063eb33ac3297d0e852efd89
DEBUG:kasa.klaptransport:Handshake1 success at 2024-03-12 17:39:40.110750. Host is 10.0.0.164, Server remote_seed is: f1d0e223e4ad13768d56288d5ed8bf26, server hash is: 0e08264a81eef7ce5271880e1756f80f39bdd188c0c1028682c4e11db7a07851
DEBUG:kasa.klaptransport:handshake1 hashes match with expected credentials
DEBUG:kasa.klaptransport:Handshake2 posted 2024-03-12 17:39:40.269253.  Host is 10.0.0.164, Response status is 200, Request was b524a3cab0223dd153eaee317a58fb844d07c88d680a2ecfe2bd0b20880b8d5a
DEBUG:kasa.klaptransport:Handshake with 10.0.0.164 complete
DEBUG:kasa.klaptransport:Query posted Host is 10.0.0.164, Sequence is 1072426435, Response status is 200, Request was {"method":"set_device_info","params":{"device_on":false},"requestID":1217285921611845632,"request_time_milis":1710265179791,"terminal_uuid":"rhErab5TBHfSGxFJDrwZpQ=="}
DEBUG:kasa.klaptransport:10.0.0.164 << {'error_code': 0}
DEBUG:kasa.smartprotocol:10.0.0.164 << {'error_code': 0}


$ kasa --host 10.0.0.164 --username 'bla' --password 'bla'  --device-family SMART.TAPOPLUG --debug on
No --type or --device-family and --encrypt-type defined, discovering..
DEBUG:kasa.discover:[DISCOVERY] 10.0.0.164 >> {'system': {'get_sysinfo': None}}
DEBUG:kasa.discover:Waiting a total of 5 seconds for responses...
DEBUG:kasa.klaptransport:Created KLAP transport for 10.0.0.164
DEBUG:kasa.discover:[DISCOVERY] 10.0.0.164 << {'result': {'device_id': 'badf8db6147a48c79eda05f2a963354e', 'owner': '25518990389A675C868EFAD265EF585D', 'device_type': 'SMART.TAPOPLUG', 'device_model': 'P110(IN)', 'ip': '10.0.0.164', 'mac': '98-25-4A-B9-F1-37', 'is_support_iot_cloud': True, 'obd_src': 'tss', 'factory_default': False, 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'KLAP', 'http_port': 80, 'lv': 2}}, 'error_code': 0}
DEBUG:kasa.smartdevice:Initializing 10.0.0.164 of type <class 'kasa.tapo.tapoplug.TapoPlug'>
Turning on None
DEBUG:kasa.smartprotocol:10.0.0.164 >> '{"method":"set_device_info","params":{"device_on":true},"requestID":1217285945171251200,"request_time_milis":1710265185408,"terminal_uuid":"84bauc6dG7h10jx/XPcayA=="}'
DEBUG:kasa.klaptransport:Starting handshake with 10.0.0.164
DEBUG:kasa.klaptransport:Handshake1 posted at 2024-03-12 17:39:45.725530. Host is 10.0.0.164, Responsestatus is 200, Request was a29c02737b0b3123deda2fde94002012
DEBUG:kasa.klaptransport:Handshake1 success at 2024-03-12 17:39:45.725641. Host is 10.0.0.164, Server remote_seed is: f3e12bef664571e5635997b7eb11b063, server hash is: 600525b00fc32184fa0c5d6083f7b1e72203931e5dd1cef29b166a13fffb88cb
DEBUG:kasa.klaptransport:handshake1 hashes match with expected credentials
DEBUG:kasa.klaptransport:Handshake2 posted 2024-03-12 17:39:45.884485.  Host is 10.0.0.164, Response status is 200, Request was 34b10d4e57f7579282d5fb98bac437ae916ad0d8769f04c3b01c29f819d31f52
DEBUG:kasa.klaptransport:Handshake with 10.0.0.164 complete
DEBUG:kasa.klaptransport:Query posted Host is 10.0.0.164, Sequence is -1695483638, Response status is 200, Request was {"method":"set_device_info","params":{"device_on":true},"requestID":1217285945171251200,"request_time_milis":1710265185408,"terminal_uuid":"84bauc6dG7h10jx/XPcayA=="}
DEBUG:kasa.klaptransport:10.0.0.164 << {'error_code': 0}
DEBUG:kasa.smartprotocol:10.0.0.164 << {'error_code': 0}

On the new plug:

$ kasa --host 10.0.0.177 --username 'bla' --password 'bla'  --device-family SMART.TAPOPLUG --debug on
No --type or --device-family and --encrypt-type defined, discovering..
DEBUG:kasa.discover:[DISCOVERY] 10.0.0.177 >> {'system': {'get_sysinfo': None}}
DEBUG:kasa.discover:Waiting a total of 5 seconds for responses...
DEBUG:kasa.klaptransport:Created KLAP transport for 10.0.0.177
DEBUG:kasa.discover:[DISCOVERY] 10.0.0.177 << {'result': {'device_id': '7800ecd22f9296d359ca1d9107a41080', 'owner': '25518990389A675C868EFAD265EF585D', 'device_type': 'SMART.TAPOPLUG', 'device_model': 'P110(IN)', 'ip': '10.0.0.177', 'mac': 'F0-A7-31-6A-F0-BB', 'is_support_iot_cloud': True, 'obd_src': 'tss', 'factory_default': False, 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'KLAP', 'http_port': 80, 'lv': 2}}, 'error_code': 0}
DEBUG:kasa.smartdevice:Initializing 10.0.0.177 of type <class 'kasa.tapo.tapoplug.TapoPlug'>
Turning on None
DEBUG:kasa.smartprotocol:10.0.0.177 >> '{"method":"set_device_info","params":{"device_on":true},"requestID":1217286636816175104,"request_time_milis":1710265350309,"terminal_uuid":"u1oNbX/EMTDrSUb+lpyvGg=="}'
DEBUG:kasa.klaptransport:Starting handshake with 10.0.0.177
DEBUG:kasa.klaptransport:Handshake1 posted at 2024-03-12 17:42:30.633265. Host is 10.0.0.177, Responsestatus is 200, Request was 3c3a9fb92ed5137763fe918105e6afb6
DEBUG:kasa.klaptransport:Handshake1 success at 2024-03-12 17:42:30.633421. Host is 10.0.0.177, Server remote_seed is: 152730afa49294a3eca2e2f921b39956, server hash is: cbe55aeb8be2fdc62ae96b2511cb21cc516f87f47a6419804030d93320703bf6
DEBUG:kasa.klaptransport:Server response doesn't match our challenge on ip 10.0.0.177
DEBUG:kasa.smartprotocol:Unable to authenticate with 10.0.0.177, not retrying
Got error: AuthenticationException("Server response doesn't match our challenge on ip 10.0.0.177")
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fe791daec50>
ERROR:asyncio:Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7fe791f3b3f0>, 518341.082107679)]']
connector: <aiohttp.connector.TCPConnector object at 0x7fe791dae710>


$ kasa --host 10.0.0.177 --username 'bla' --password 'bla'  --device-family SMART.TAPOPLUG --debug off
No --type or --device-family and --encrypt-type defined, discovering..
DEBUG:kasa.discover:[DISCOVERY] 10.0.0.177 >> {'system': {'get_sysinfo': None}}
DEBUG:kasa.discover:Waiting a total of 5 seconds for responses...
DEBUG:kasa.klaptransport:Created KLAP transport for 10.0.0.177
DEBUG:kasa.discover:[DISCOVERY] 10.0.0.177 << {'result': {'device_id': '7800ecd22f9296d359ca1d9107a41080', 'owner': '25518990389A675C868EFAD265EF585D', 'device_type': 'SMART.TAPOPLUG', 'device_model': 'P110(IN)', 'ip': '10.0.0.177', 'mac': 'F0-A7-31-6A-F0-BB', 'is_support_iot_cloud': True, 'obd_src': 'tss', 'factory_default': False, 'mgt_encrypt_schm': {'is_support_https': False, 'encrypt_type': 'KLAP', 'http_port': 80, 'lv': 2}}, 'error_code': 0}
DEBUG:kasa.smartdevice:Initializing 10.0.0.177 of type <class 'kasa.tapo.tapoplug.TapoPlug'>
Turning off None
DEBUG:kasa.smartprotocol:10.0.0.177 >> '{"method":"set_device_info","params":{"device_on":false},"requestID":1217286812804976640,"request_time_milis":1710265392268,"terminal_uuid":"XFyJWSpdfT7nI8LwUZ0SqA=="}'
DEBUG:kasa.klaptransport:Starting handshake with 10.0.0.177
DEBUG:kasa.klaptransport:Handshake1 posted at 2024-03-12 17:43:12.583360. Host is 10.0.0.177, Responsestatus is 200, Request was 82701ac4051b62cf5658df53b50f713a
DEBUG:kasa.klaptransport:Handshake1 success at 2024-03-12 17:43:12.583481. Host is 10.0.0.177, Server remote_seed is: 150299f2819f9562cb7c0d9f33492529, server hash is: 3a3037318fe77e2c1c68a0916055b55bb90a2cab7bf85076d99fcc6dab8a05e4
DEBUG:kasa.klaptransport:Server response doesn't match our challenge on ip 10.0.0.177
DEBUG:kasa.smartprotocol:Unable to authenticate with 10.0.0.177, not retrying
Got error: AuthenticationException("Server response doesn't match our challenge on ip 10.0.0.177")
ERROR:asyncio:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f0435283010>
ERROR:asyncio:Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f043540f3f0>, 518383.032207722)]']
connector: <aiohttp.connector.TCPConnector object at 0x7f04352827d0>

@kayg04
Copy link
Author

kayg04 commented Mar 12, 2024

I also checked the boxes of the 4 plugs i have. Two of them were imported in Dec 2023 and two of them were imported in Jan 2024. I've ordered another one just to make sure if this behaviour is consistent.

@sdb9696
Copy link
Contributor

sdb9696 commented Mar 12, 2024

This is very strange.

The device says it was onboarded with "tss". What app did you use to provision the device and on which OS?

You could try running the kasa cli from the master branch just to be sure although I don't think it will work.

Otherwise next thing to try is a factory reset and re-provision the device.

@kayg04
Copy link
Author

kayg04 commented Mar 13, 2024

Tapo app from Play Store on Android, same as the 3 plugs before it. The only difference I've found in the settings is that the new one doesn't have "auto update firmware" turned on.

I'll try doing a factory reset and reprovisioning the device. Thank you for your help so far.

@kayg04
Copy link
Author

kayg04 commented Mar 13, 2024

I left it turned off at night and i plugged it in a different socket now, and it automagically worked....

@kayg04
Copy link
Author

kayg04 commented Mar 13, 2024

The new one got delivered right now and it worked without a problem...

I don't understand what went wrong.

@rytilahti
Copy link
Member

Glad you got it working!

So this error usually happens when the secrets do not match (i.e., either the username or the password is wrong), so it sounds like something caused the device to become unsynchronized. Given it is working now, should we close this issue?

@kayg04
Copy link
Author

kayg04 commented Mar 15, 2024

Hey, i was copy pasting from my password manager so there's no way the secrets didn't match. But yeah, the plugs have been working without an issue. Thank you for your time!

@kayg04 kayg04 closed this as completed Mar 15, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants