petretiandrea / home-assistant-tapo-p100

A custom integration to control Tapo devices from home assistant.
MIT License
818 stars 102 forks source link

Server response doesn't match our challenge on ip %s #658

Closed Smoot178 closed 9 months ago

Smoot178 commented 10 months ago

Home Assistant Core 2023.12.3, Supervisor 2023.12.0, Operating System 11.2, Frontend 20231208.2 Tapo Controller 2.12.2 Tapo S500D 1.1.0 Build 230906 Rel. 141935

Unable to add my first Tapo device. Receiving log entry:

Logger: homeassistant.components.switch
Source: helpers/entity_platform.py:361
Integration: Switch ([documentation](https://www.home-assistant.io/integrations/switch), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+switch%22))
First occurred: 9:58:41 PM (1 occurrences)
Last logged: 9:58:41 PM

Error while setting up tapo platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 361, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/tapo/switch.py", line 32, in async_setup_platform
    coordinator = await setup_from_platform_config(hass, config)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo/setup_helpers.py", line 74, in setup_from_platform_config
    return await create_coordinator(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo/coordinators.py", line 67, in create_coordinator
    device_info = (await client.get_device_info()).map(lambda x: TapoDeviceInfo(**x))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_client.py", line 92, in get_device_info
    return await self.execute_raw_request(get_info_request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_client.py", line 78, in execute_raw_request
    return (await self._protocol.send_request(request)).map(lambda x: x.result)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 49, in send_request
    response = await self._send_request(request, retry)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 59, in _send_request
    new_session = await self.perform_handshake()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 104, in perform_handshake
    seeds = await self.perform_handshake1(new_local_seed)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 198, in perform_handshake1
    "Server response doesn't match our challenge on ip %s"
TypeError: not all arguments converted during string formatting

Also seeing the following:

Logger: plugp100.api.tapo_client
Source: custom_components/tapo/coordinators.py:67
Integration: TP-Link Tapo ([documentation](https://github.com/petretiandrea/home-assistant-tapo-p100), [issues](https://github.com/petretiandrea/home-assistant-tapo-p100/issues))
First occurred: 9:58:41 PM (1 occurrences)
Last logged: 9:58:41 PM

Default protocol not working, fallback to KLAP ;)
michlalp commented 10 months ago

Hi, same here...

develeon commented 10 months ago

Same here (P115)

petretiandrea commented 9 months ago

Solved in 2.13.0 with automatic retry

RohanM commented 9 months ago

On 2.13.0 I'm seeing something very similar. When I upgrade from 2.11.0, two of my L530B lights show the error "Failed setup, will retry", with the hover text "not all arguments converted during string formatting". Other lights of the same model continue working just fine.

When I remove one of the non-functioning light devices and attempt to re-add it, I see this error in the debug log:

2024-02-04 11:04:25.383 ERROR (MainThread) [custom_components.tapo.config_flow] Failed to setup cannot connect 
Traceback (most recent call last):
  File "/config/custom_components/tapo/config_flow.py", line 192, in _get_first_data_from_api
    (await tapo_client.get_device_info())
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_client.py", line 92, in get_device_info
    return await self.execute_raw_request(get_info_request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_client.py", line 78, in execute_raw_request
    return (await self._protocol.send_request(request)).map(lambda x: x.result)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 49, in send_request
    response = await self._send_request(request, retry)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 59, in _send_request
    new_session = await self.perform_handshake()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 104, in perform_handshake
    seeds = await self.perform_handshake1(new_local_seed)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/klap_protocol.py", line 176, in perform_handshake1
    "Server response doesn't match our expected hash on ip %s but an authentication with blank credentials matched"
TypeError: not all arguments converted during string formatting

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/tapo/config_flow.py", line 119, in async_step_user
    device_data = await self._get_first_data_from_api(tapo_client)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo/config_flow.py", line 199, in _get_first_data_from_api
    raise CannotConnect from error
custom_components.tapo.errors.CannotConnect

Device info:

Puzzlingly, the lights that continued working show exactly the same device info as above.

Software info:

GitSlinger commented 5 months ago

Has anyone had any success with this? I'm not able to add any of my P100 or P110 and just get "Invalid authentication: Server response doesn't match our challenge on ip" any time I submit my login details when getting to add a device

Budgiebrain994 commented 4 months ago

Same issue here. It was fine intiially, but after I switched the device's WiFi network and changed its name, I am no longer able to set up the device again.

xerosilence commented 3 months ago

have the same problem, getting error message:

Invalid authentication: Server response doesn't match our challenge on ip 192.168.1.xxx

Mandel82 commented 3 months ago

Budgiebrain994I also have the same problem as you. did you solve it?

Budgiebrain994 commented 3 months ago

Budgiebrain994I also have the same problem as you. did you solve it?

Yes, I solved this issue.

I reset my Tapo/TP-link password in their app, and used the new password to log in through Home Assistant again. (I had to delete and re-add the integration.) It worked.

Budgiebrain994 commented 3 months ago

Also, don't let the auto-discovery system add your device! Go manually into TP-Link, scroll down and tap "add device". On the setup page, don't add a host, just tap Submit and use those ones discovered.

kylewintaur commented 3 months ago

Also, don't let the auto-discovery system add your device! Go manually into TP-Link, scroll down and tap "add device". On the setup page, don't add a host, just tap Submit and use those ones discovered.

This is what worked for me. Don't do any of the "easy" add options, going into Add Device > Plugs > selecting P100M and letting it search for the plug worked every time.

p-afraz commented 2 months ago

For me nothing but changing the password on Tapo app worked. To make it easier, and not to re-configure all devices after changing password, I just set the new password to the same old password in Tapo app. This somehow (maybe because Tapo server invalidates all active sessions after changing password) made the HA integration work again without need to re-configure older devices.

Overdrivendev commented 1 month ago

Hmm, I've just set up Home Assistant for the first time (coming from just using Google for controlling my devices which they all worked fine with). All my bulbs are generating this same error and none of the fixes suggested here seem to work (although I'm not sure how to stop the auto-discovery mentioned above yet). I have a mix of 510 and 530 bulbs. My TP-Link plugs all worked fine, but they're the older Kasa branded devices so that's probably why.

Edit: Came back a few days later and now all devices are connecting fine. I changed nothing so maybe just a caching issue with the bulbs/cloud after changing the password?

niveknow commented 3 weeks ago

@p-afraz suggestion above was the winner for me. Changed password from current to current allowed HA to immediately Add my TP115 outlets. Didn't need a reboot or anything. Thanks.