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

Invalid authentication #122

Closed
petretiandrea opened this issue Jan 25, 2022 · 216 comments
Closed

Invalid authentication #122

petretiandrea opened this issue Jan 25, 2022 · 216 comments
Labels
bug Something isn't working help wanted Extra attention is needed stale

Comments

@petretiandrea
Copy link
Owner

petretiandrea commented Jan 25, 2022

Version of the custom_component

Any

Describe the bug

A lot of people receive an "Invalid authentication" error message. Thanks to #120 and @mostlyvirtual, we have found an issue regarding username with capital letters. As reported by the user, in Tapo App settings is shown the email address, if this address contains capital letter, you probably receive "Invalid authentication" error from integration. In #120 they resolved by creating another account using an email all lower-case. In this way, the integration works.

So actually, only lower case E-mail works. I will investigate on this and fix asap

EDIT: Thanks to @rfnunes. When entering email, use the same case as seen in Tapo App.

@petretiandrea petretiandrea added bug Something isn't working help wanted Extra attention is needed labels Jan 25, 2022
@rfnunes
Copy link
Contributor

rfnunes commented Feb 2, 2022

My email address contains upper case letters and I was able to login after entering the email address case-sensitive, that is, using the exact same case as seen in the Tapo app. That worked for me as workaround and it's way more simple than creating another account.

@GrzegorzZajac000
Copy link

GrzegorzZajac000 commented Feb 4, 2022

I don't have any capital letters in my email address (only lower case, dot and numbers), but still I can't authorize with this component in my HomeAssistant.
I even changed my e-mail address, my username for camera and nothing works

@petretiandrea
Copy link
Owner Author

@GrzegorzZajac000 Can you try to execute this snippet of code and report here the output?

import asyncio
from plugp100 import TapoApiClient


async def main():
    # create generic tapo api
    sw = TapoApiClient("<ip>", "<email>", "<passwd>")
    await sw.login()
    print(await sw.get_state())

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.run_until_complete(asyncio.sleep(0.1))
loop.close()

@chconil
Copy link

chconil commented Feb 16, 2022

Hi there,
Not sure it helps, but maybe it will :-) I remember from I-don't-know-where, that the devices store the password when they first get added to the Tapo App. If you change your password later, it's still the initial one in the device!
Deleting/re-adding the devices in the app updates the password to the latest one.
Good luck!
Christophe

@francesco-bonassi
Copy link

Hello,
Thanks for this integration.
I encounter an ''Invalid authentication'' (my email is all lower case).

I would like to use my Home Assistant (located in my house) to control a P100 switch (located in my office).
Does this integration work via cloud?
Or does it need to work in the same LAN?
Thank you,

@gpbicego
Copy link

Hello
I had an "Invalid Authentication" problem with version 1.2.8, but v1.2.4 works fine.
image

@petretiandrea
Copy link
Owner Author

petretiandrea commented Feb 22, 2022

Thanks for your report, but as you can see here: v1.2.4...v1.2.8, there are no changes between the two version about authentication step. So retry the latest version and check if now works.

N.B. A user on home assistant community forum says that changing the password for tapo account will not refresh the password changed on the already associated devices until you remove and re-add the device from tapo app. @gpbicego @francesco-bonassi

@petretiandrea
Copy link
Owner Author

Hello, Thanks for this integration. I encounter an ''Invalid authentication'' (my email is all lower case).

I would like to use my Home Assistant (located in my house) to control a P100 switch (located in my office). Does this integration work via cloud? Or does it need to work in the same LAN? Thank you,

For authentication issue, see the comment above. Regarding your question about "remote" control, this integration work on local polling, so you can't control it from an external home assistant instance. (Where external is intended as different network, like your office and home. So if you install home assistant on your home and the tapo is in your office, you can't control it. The only way is to install home assistant in your office and expose home assistant on "internet" and access to it from your home)

@francesco-bonassi
Copy link

Thanks Andrea.
It would be useful to be able to manage this integration in Cloud Polling.
Thank's for your job

@geidorei
Copy link

geidorei commented Mar 5, 2022

Auth issue as well - p/w and ID all lower case.

@rfnunes
Copy link
Contributor

rfnunes commented Mar 5, 2022 via email

@geidorei
Copy link

geidorei commented Mar 6, 2022

After further investigation it would add some devices, some failed. However, rebooting HA in-between adding it eventually allowed me to add all devices - weird, no idea.

@petretiandrea
Copy link
Owner Author

This has stopped working for me too. In my case, after updating to HA 2022.3. Have tried removing and installing the integration, changing cam's user password, user and password...

No luck at all. Haven't seen logs about the error.

Any idea on what to try?

Why are you talking about cams? This integration doesn't support cameras

@luixal
Copy link

luixal commented Mar 7, 2022

My bad, just got to the wrong repo.

Sorry!

@vindbrann
Copy link

Hello,

I've installed this in order to manage my L900. Today it stops working so I decided to remove the L900 and add it again.
I can't add the L900 back with the authentication error. (No capital in my email adress).
I removed the intergration, installed back and it works.

@dannycjones
Copy link

dannycjones commented May 3, 2022

I'm seeing transient failure here too. My e-mail contains a +.

I tried reaching the device using the plugp100 package directly. When it wasn't working, I'd get:

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.1.153:80 ssl:default [Connect call failed ('191.168.1.153', 80)]

After a few retries, it starts working fine for both that client and the Home Assistant integration. Then 10 minutes later I'm getting unavailable data.

@chrisuk-web
Copy link

chrisuk-web commented May 4, 2022

I am having the same problem. What is the value of the host field? Is this the IP address of home assistant or the Tapo device? I've tried both and in the error below am trying with the device.

image

This is in home-assistant.log:

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.1.53:80 ssl:default [Connect call failed ('192.168.1.53', 80)]

@chrisuk-web
Copy link

chrisuk-web commented May 4, 2022

Ok it worked - didn't seem to like an upper case letter in the password. IP address was that of the device.

@josecarlospaulo
Copy link

Hi guys i am newbie with home assistant but its giving to me a “invalid authentication” when i am trying to put the host, username and the password and i already change the code on configuration.yaml to this
“switch:
platform: tapo_p100_control
ip_address: 192.168.x.x
email: email@gmail.com
password: Password123”
Putting the ip of p100 my personal email and a new password and i already restart the HA and nothing changed still having the same error.
Btw i downloaded from here “GitHub - petretiandrea/home-assistant-tapo-p100: A custom integration to control Tapo devices from home assistant. 1”.
And i am using the home assistant core on ubuntu lastest version btw.
Thanks for the help.
image

@richard-scott
Copy link

I found that removing and re-adding my devices and auth started to work. I also noticed that the IP in the Tapo Mobile app assigned to a device was different to the actual IP the device had now. I could not use the IP that my DHCP server told me the device had, so I don't know if I was suffering from a stale password on the device or something else.

@viba1
Copy link

viba1 commented Jun 17, 2022

Previously same problem.
Fixed using the last 1.2.12 version.

Configuration :

  • Home Assistant Core 2022.6.6 installed via docker method
  • home-assistant-tapo-p100 1.2.12 installed via "Manual way"
  • TAPO L530 in both 1.0 (with 1.2.2 firmware) and 2.0 (with 1.0.8 firmware)

What works:

  • after reloading the home assistant container, "Tapo Controller" is well recognized and seems functional (GUI loads)
    host: 192.168.x.x
    username: xxx@xxx.xxx (no special character, no uppercase)
    password: xxxx (no special constraint identified)

Thanks for this update and your great job!

@jackielegs98
Copy link

Also I have found that similar to other sorts of devices such as Tuya, ensure that you do not have the app open on another device. That was my fix anyway.

@Hobiano
Copy link
Contributor

Hobiano commented Jun 26, 2022

Hey guys, thanks for this integration, but I can't connect to a server, it takes a lot of time to request and then shows this error:
Config flow could not be loaded: undefined
Any suggestions?

@stain3565
Copy link

stain3565 commented Jun 27, 2022

In my case, I have 8 plugs under the same Tapo account. 5 added successfully. 3 get the invalid authentication. Obviously, the userid and password cannot be the issue as they work fine for the other 5. I have double checked the ip addresses I am entering and they are correct. All plugs are working fine in the Tapo app. I have in the past used the manual TP100 Control github to implement these plugs but have changed over entirely to this TAPO CONTROLLER integration now, so it is possible something is left over in the depths of HA for these plugs but nothing showing in the UI.

UPDATE

Removing and Re-adding these 3 to the Tapo app and ensuring I made no amendments to the name or any other aspect, meant that these could then be added to TAPO CONTROLLER although not first time for all. So a little confusing but currently working.

ANOTHER UPDATE BUT LESS POSITIVE

All 8 of my plugs were correctly showing in the Integration until I restarted Home Assistant (no integration updates, just some unrelated yaml changes).
Now, 5 have not connected in the integration. I have tried reloading but to no avail. The plugs are working in the Tapo app so the issue is in the Home Assistant integration. I did want to add 4 more plugs but these are failing too.
I had not changed any of the existing plugs in the app (editing did seem to be some form of issue before) so now am struggling to logically explain the reason why some work and some don't.

The logs are below (after a reload - same every time):

`Logger: homeassistant.config_entries
Source: config_entries.py:370
First occurred: 23:02:28 (18 occurrences)
Last logged: 23:32:36

Config entry 'Z-Wave JS' for zwave_js integration not ready yet: Cannot connect to host core-zwave-js:3000 ssl:default [Connect call failed ('172.30.33.2', 3000)]; Retrying in background
Config entry 'Tapo 5' for tapo integration not ready yet: None; Retrying in background
Config entry 'Tapo 1 - TV2' for tapo integration not ready yet: None; Retrying in background
Config entry 'Tapo 4' for tapo integration not ready yet: None; Retrying in background
Config entry 'Tapo 7 - TV1' for tapo integration not ready yet: None; Retrying in background`

@petretiandrea
Copy link
Owner Author

Hey guys, thanks for this integration, but I can't connect to a server, it takes a lot of time to request and then shows this error:
Config flow could not be loaded: undefined
Any suggestions?

Pc os? Architecture?

@Hobiano
Copy link
Contributor

Hobiano commented Jul 5, 2022

Hey guys, thanks for this integration, but I can't connect to a server, it takes a lot of time to request and then shows this error:
Config flow could not be loaded: undefined
Any suggestions?

Pc os? Architecture?

sorry iam a noob here, i just use this https://github.com/home-assistant/operating-system/releases/download/8.2/haos_rpi4-64-8.2.img.xz on raspberry pi, and its works fine after update hass os or core.
That's my hass info:
Version | core-2022.8.0.dev20220705
Installation Type | Home Assistant OS
Development | true
Supervisor | true
Docker | true
User | root
Virtual Environment | false
Python Version | 3.10.5
Operating System Family | Linux
Operating System Version | 5.15.32-v8
CPU Architecture | aarch64
Timezone | Africa/Cairo

can i add log details for ERROR here?
Thank u

@nithikalisamy
Copy link

nithikalisamy commented Jul 7, 2022

Hi Guys, Thanks for this wonderful integration and I was using the Tapo P110 device with this integration for the last 3 months without any issues. But today evening I upgraded HA Core and Supervisor to 2022.7.0 but then I lost access to the device.

It's still accessible via the Tapo app but I could control it as it was the device was not available. Tapo Integration showed "Retiring setup: None". So I removed the existing installation and added it again.

But then after that, I am getting "Invalid Authentication", I couldn't pass this step and got stuck.

Now I tried everything it was suggested above,

  1. Removed the device and added it again to the existing email.
  2. Even though my email had lower cases, I created a new email id for the Tapo account and configured the device.
  3. Changed pwd to lower cases too and tried but no luck.
  4. Changed the device host IP to a different one.

I am not sure what else has gone wrong wiht this integration. All other integrations including TP-link add on is working fine.

Can someone please help with this issue?

Update:

After trying everything, I restored it back to Home Assistant Core: 2022.6.7 from 2022.7.0 and it just started working again without any modifications. Not sure what changes are breaking this integration.

Now my HA versions are,
Home Assistant Core: 2022.6.7
Home Assistant Supervisor: 2022.7.0

@aialenti
Copy link

aialenti commented Jul 8, 2022

I am also having issues authenticating (obtaining "invalid credentials").

I tried to disable the error handing to see what was the actual exception, and I've got the following:

Traceback (most recent call last):
  File "/config/custom_components/tapo/config_flow.py", line 58, in async_step_user
    entry_metadata = await self._validate_input(user_input)
  File "/config/custom_components/tapo/config_flow.py", line 91, in _validate_input
    tapo_api = await self._test_credentials(
  File "/config/custom_components/tapo/config_flow.py", line 110, in _test_credentials
    await client.login()
  File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 84, in login
    await self._handshake()
  File "/usr/local/lib/python3.10/site-packages/plugp100/api.py", line 157, in _handshake
    resp_dict = await response.json()
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1103, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://192.168.x.x/app')

It looks like something that should be handled in the library that calls the API

@mdcostas
Copy link

Same problem also for me, new P115

@voloda22
Copy link

Hi, I am also getting the "Failed to connect" error when adding H200 with T110. I've tried to use only lowercase, no special characters, both in the email and password, disabled 2 factor auth., nothing helps. Adding the log:

`2023-10-22 17:34:39.676 ERROR (MainThread) [custom_components.tapo.config_flow] Failed to setup cannot connect
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
sock = await self._connect_sock(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 628, in sock_connect
return await fut
^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 668, in _sock_connect_cb
raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('192.168.XYZ.XYZ', 80)

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 215, in _try_setup_api
await client.initialize()
File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_client.py", line 62, in initialize
await self._guess_protocol()
File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_client.py", line 218, in _guess_protocol
response = await self.execute_raw_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_client.py", line 71, 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/passthrough_protocol.py", line 42, in send_request
response = await self._send_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/passthrough_protocol.py", line 62, in _send_request
await self._login_with_version(self._credential)
File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/passthrough_protocol.py", line 81, in _login_with_version
session_or_error = await self._passthrough.handshake(self._url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/plugp100/protocol/securepassthrough_transport.py", line 70, in handshake
response = await self._http.async_make_post(url, json=request_body)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/plugp100/common/utils/http_client.py", line 18, in async_make_post
async with self.session.post(
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in aenter
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1209, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.XYZ.XYZ:80 ssl:default [Connect call failed ('192.168.XYZ.XYZ', 80)]

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 118, in async_step_user
tapo_client = await self._try_setup_api(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tapo/config_flow.py", line 220, in _try_setup_api
raise CannotConnect from error
custom_components.tapo.errors.CannotConnect`

@prpicivan
Copy link

Issue still happening.
I have setup Tapo integration with couple of L510 bulbs over 9 months ago. Everything was functioning properly (diferent morning/evening automations), manual switching on/off. Yesterday one L510 bulb stoped communicating with HA (continued working in Tapo application). The same L510 bulb was updated by me to 1.3 firmware and after that update I am receiving Auth failed error.
I have replaced that bulb with new one (but didnt upgrade firmware) and everything is working again as it should.
Unofrtunately there are no clear steps (or at least I wasnt able to preform them) how to fully reset existing bulb to factory settings (and also remove current firmware).

@miqueet
Copy link

miqueet commented Nov 14, 2023

I am also having this issue with the L900 lights. I have tried everything in this thread.

@crawlingcity
Copy link

Tried some things that were here in the comments and nothing worked. But i solved my problem. Here's how:

I went to this website https://tapo.tplinkcloud.com and couldn't login, same error as in Home Assistant, invalid credentials.
Reset password, set new password and... done.

I can now add my devices flawlessly.

@cmefli
Copy link

cmefli commented Nov 24, 2023

Same "failed to connect" issue as others.
I have a P110 and L900 registered in the tapo app, HA can see and talk with the P110, but not the L900 (same creds). Both devices previously worked fine, but about a month ago the L900 appeared unavailable. Removed from HA and attempted to re-add, now getting the below error.

Have not removed the P110 and attempted to re-add, as would like to keep this working.

Logger: custom_components.tapo.config_flow
Source: custom_components/tapo/config_flow.py:60
Integration: tapo_p100 (documentation, issues)
First occurred: 12:36:59 PM (4 occurrences)
Last logged: 12:47:05 PM

Failed to setup cannot connect
Traceback (most recent call last):
File "/config/custom_components/tapo/config_flow.py", line 109, in _try_setup_api
await client.login()
File "/usr/local/lib/python3.11/site-packages/plugp100/api/tapo_api_client.py", line 41, in login
await self.client.login()
File "/usr/local/lib/python3.11/site-packages/plugp100/tapo_protocol/tapo_protocol_client.py", line 36, in login
await self._handshake()
File "/usr/local/lib/python3.11/site-packages/plugp100/tapo_protocol/tapo_protocol_client.py", line 97, in _handshake
self._validate_response(resp_dict)
File "/usr/local/lib/python3.11/site-packages/plugp100/tapo_protocol/tapo_protocol_client.py", line 154, in _validate_response
raise TapoException.from_error_code(resp['error_code'])
plugp100.domain.tapo_exception.TapoException: Returned unknown error_code: 1003

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 60, in async_step_user
api = await self._try_setup_api(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tapo/config_flow.py", line 112, in _try_setup_api
self._raise_from_tapo_exception(error)
File "/config/custom_components/tapo/config_flow.py", line 121, in _raise_from_tapo_exception
raise CannotConnect from exception
custom_components.tapo.config_flow.CannotConnect

@derdodga
Copy link

It works for me with capital letter in Password AND email (first letter) with P110. But it will only work when writing the email exactly as in the app in the tapo integration.

@cmefli
Copy link

cmefli commented Dec 8, 2023

Pulled the lastest version, replaced the folder in custom_components folder, reloaded HA and was able to add the L900 strip.
Did notice there are 2 new check boxes without any info...
image

@ChrissDeejay
Copy link

Hello,
I have the exact same issue as above when trying to connect a TAPO P100 ... the very strange thing is that I have two of these plugs, one worked pairing but the second one has the "Failed to connect" issue.

image

@Adivor
Copy link

Adivor commented Jan 8, 2024

Same problem my cameras ...auth error and rtmp link work correctly.

C310
C200

@christofnolden
Copy link

„Failed to connect“ problem with:

H200 with 9x T315 sensors and 1x D230 connected

@RegisCorbet
Copy link

Same here, with multiple C200 and C500 on two different HA instances

@chicknwinner
Copy link

i was having this issue with my p100, removed it and re-added it to home assistant and now it works

@daniel-asenov
Copy link

@chicknwinner, how to remove it if it fails to be added in the first place?

@falkeye71
Copy link

I have the same issue with not beeing able to connect H200 and T100 to HA.
Tried everything I can find regarding this issue but no success.
H200 firmware: 1.2.25 Build 20231205 rel:59009
Integration Tapo release: 2.13.0

@ClementNerma
Copy link

Got errors here with Tapo P110 plugs. Both HA and the plugs are on their latest version.

@kartalsmart
Copy link

"Failed to connect" error - it seems this should be removed until it's fixed.

@fatihitu
Copy link

"Failed to connect" error for P110.
When I browse the IP, I get an OK message: "200 OK"
I am typing only IP address without http or https: 192.168.1.112; the email and password are all lowercase.

HA version: 2024.2.1
HACS version: latest version

image

HA Log:

2024-02-20 23:42:10.126 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 194, in _get_first_data_from_api
    .get_or_raise()
     ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/common/functional/tri.py", line 159, in get_or_raise
    raise self.value
Exception: Server response doesn't match our challenge on ip ('http', '192.168.1.112', 80)

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

@Seaniefield
Copy link

"Failed to connect" error for P110. When I browse the IP, I get an OK message: "200 OK" I am typing only IP address without http or https: 192.168.1.112; the email and password are all lowercase.

HA version: 2024.2.1 HACS version: latest version

image HA Log:
2024-02-20 23:42:10.126 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 194, in _get_first_data_from_api
    .get_or_raise()
     ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/common/functional/tri.py", line 159, in get_or_raise
    raise self.value
Exception: Server response doesn't match our challenge on ip ('http', '192.168.1.112', 80)

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

Got errors here with Tapo P110 plugs. Both HA and the plugs are on their latest version.

Hi, I'm a completed newcomer to this but was able to resolve. My mesh WIFI was not in Access Point mode "AP mode". I tried this and the plug connected fine. Might help other new users.

@delize
Copy link

delize commented Mar 8, 2024

Same issues, with a P110 and a P300

Version of the integration

v2.14.0 & v3.0.0

With v3.0.0 however, the username and password field are blank.

Configuration

$ cat /mnt/docker/homeassistant/configuration.yaml                                                                                                                                                                                      [21:17:43]

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

homeassistant:
  internal_url: "http://192.168.50.2:8123"
  external_url: "https://homeassistant.domain.com"

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.16.0.0/12
    - 162.158.0.0/15
    - 192.168.0.0/16
  ip_ban_enabled: true
  login_attempts_threshold: 3


Describe the bug

When attempting to connect, I get "Failed to connect", username/email is all lowercase.
Unable to add Tapo devices.

Debug log

2024-03-07 21:11:20.785 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 194, in _get_first_data_from_api
    .get_or_raise()
     ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/common/functional/tri.py", line 159, in get_or_raise
    raise self.value
Exception: Server response doesn't match our challenge on ip ('http', '192.168.50.206', 80)

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
2024-03-07 21:11:36.948 DEBUG (MainThread) [custom_components.tapo.coordinators] Finished fetching tapo data in 0.126 seconds (success: True)
2024-03-07 21:11:36.963 DEBUG (MainThread) [custom_components.tapo.coordinators] Finished fetching tapo data in 0.120 seconds (success: True)
2024-03-07 21:11:50.938 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 194, in _get_first_data_from_api
    .get_or_raise()
     ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/common/functional/tri.py", line 159, in get_or_raise
    raise self.value
Exception: Server response doesn't match our challenge on ip ('http', '192.168.50.206', 80)

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


@ZeroDotNet
Copy link

ZeroDotNet commented Mar 20, 2024

I was able to avoid the authentication issue after finding this:

  1. If the Camera is inserted microSD card and subscribed Tapo Care, its RTSP stream will fail. You need to remove microSD card or cancel Tapo Care to get its RTSP stream.

Source: https://www.tapo.com/uk/faq/34/

@JimmyPaige18
Copy link

Trying to add my P110 plugs and get the same error
IMG_3731

@KronFacer
Copy link

I was experiencing the same issues.

My tapo registered email address has both upper and lower case characters.
On android:-
Enter the app > "Me" lower right corner
You will see your registered email address.

You must enter this exactly as seen into the TAPO HACS Controller when adding a new device.

@harobertocpf
Copy link

Exactly the same thing happens to me. I can't connect and I have entered the correct data.

@scornflake
Copy link

I have similar auth issue (maybe invalid credentials, Failed to setup cannot connect)
Tapo: 3.1.2
Plug: P100 (verified the IP and that I can login to the plug itself OK via the tapo app)

`
This error originated from a custom integration.

Logger: DeviceFactory
Source: custom_components/tapo/config_flow.py:314
integration: tapo (documentation, issues)
First occurred: 1:54:47 PM (2 occurrences)
Last logged: 1:55:21 PM

None of available protocol is working, maybe invalid credentials

`

and also:

`
This error originated from a custom integration.

Logger: custom_components.tapo.config_flow
Source: custom_components/tapo/config_flow.py:143
integration: tapo (documentation, issues)
First occurred: 1:54:47 PM (2 occurrences)
Last logged: 1:55:21 PM

Failed to setup cannot connect
Traceback (most recent call last):
  File "/config/custom_components/tapo/config_flow.py", line 314, in _async_get_device
    device = await connect(config=config, session=session)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/new/device_factory.py", line 43, in connect
    protocol = await _get_or_guess_protocol(config, session)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/new/device_factory.py", line 65, in _get_or_guess_protocol
    return await _guess_protocol(config, session)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/new/device_factory.py", line 102, in _guess_protocol
    raise InvalidAuthentication(config.host, config.device_type)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/plugp100/new/errors/invalid_authentication.py", line 3, in __init__
    super(f"Invalid authentication error for ${host}, ${device_type}")
TypeError: super() argument 1 must be a type, not str

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 143, in async_step_user
    device = await self._async_get_device(user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tapo/config_flow.py", line 322, in _async_get_device
    raise CannotConnect from error
custom_components.tapo.errors.CannotConnect

`

@xlixivia
Copy link

xlixivia commented Apr 23, 2024

works whit p110 but no work whit h100 hub:

2024-04-23 23:44:26.027 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 317, in _async_get_device
await device.update()
File "/usr/local/lib/python3.12/site-packages/plugp100/new/tapodevice.py", line 79, in update
await component.update(state)
File "/usr/local/lib/python3.12/site-packages/plugp100/new/components/hub_children_component.py", line 47, in update
await child_device.update()
File "/usr/local/lib/python3.12/site-packages/plugp100/new/tapodevice.py", line 79, in update
await component.update(state)
File "/usr/local/lib/python3.12/site-packages/plugp100/new/components/smart_door_component.py", line 15, in update
self.is_open = current_state["is_open"]
~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'is_open'

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 231, in async_step_discovery_auth_confirm
device = await self._async_get_device_from_discovered(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tapo/config_flow.py", line 295, in _async_get_device_from_discovered
return await self._async_get_device(config | {CONF_HOST: discovered.ip}, discovered)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/tapo/config_flow.py", line 322, in _async_get_device
raise CannotConnect from error
custom_components.tapo.errors.CannotConnect

@eirikelv
Copy link

I had a similar issue, but I discovered that TP-Link had capitalized the first letter of my email address, which was not visible on the app where all letters were small. This issue was only visible when I logged into the TP-Link Cloud website. The issue was resolved once I changed the email in the code to the capitalized first letter. This problem occurred while using the Tapo PyPi library based on petretiandera on a Smartplug P115.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed stale
Projects
None yet
Development

No branches or pull requests