petretiandrea / home-assistant-tapo-p100

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

Tapo P110 devices connect failed #681

Open peruggini opened 8 months ago

peruggini commented 8 months ago

Version of the integration

2.13.0

Configuration

Tapo P110, Firmware 1.3.0

Describe the bug

Unable to add all 3 tapo devices with the same Connection error. IP is correct and in the same network of HA. Pinging 1 of 3 (just for example) devices is OK: userland@localhost:~$ ping 192.168.1.61 PING 192.168.1.61 (192.168.1.61) 56(84) bytes of data. 64 bytes from 192.168.1.61: icmp_seq=1 ttl=255 time=76.4 ms 64 bytes from 192.168.1.61: icmp_seq=2 ttl=255 time=19.5 ms 64 bytes from 192.168.1.61: icmp_seq=3 ttl=255 time=11.4 ms

HA is core running under Debian in Android Userland

Debug log

2024-01-12 16:02:19.282 ERROR (MainThread) [custom_components.tapo.config_flow] Failed to setup cannot connect Traceback (most recent call last):

...skipping 1 line return await self._loop.create_connection(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/baseevents.py", line 1099, in create connection raise exceptions[0] File "/usr/local/lib/python3.12/asyncio/baseevents.py", line 1081, in create connection sock = await self._connect_sock( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/base_events.py", line 984, in _connect _sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 647, in sock _connect return await fut ^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 687, in _soc k_connect_cb raise OSError(err, f'Connect call failed {address}') OSError: [Errno 113] Connect call failed ('192.168.1.61', 80)

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

...skipping 1 line File "/home/userland/.homeassistant/custom_components/tapo/config_flow.py", li ne 192, in _get_first_data_from_api (await tapo_client.get_device_info()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/plugp100/api/tapo_clien t.py", line 92, in get_device_info return await self.execute_raw_request(get_info_request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/plugp100/api/tapo_clien t.py", line 77, in execute_raw_request await self._initialize_protocol_if_needed() File "/home/userland/hass/lib/python3.12/site-packages/plugp100/api/tapo_clien t.py", line 71, in _initialize_protocol_if_needed await self._guess_protocol() File "/home/userland/hass/lib/python3.12/site-packages/plugp100/api/tapo_clien t.py", line 221, in _guess_protocol response = await self.get_component_negotiation() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/plugp100/api/tapo_clien t.py", line 81, in get_component_negotiation return (await self.execute_raw_request(TapoRequest.component_negotiation())) .map( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...skipping 1 line return (await self._protocol.send_request(request)).map(lambda x: x.result) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/plugp100/protocol/passt hrough_protocol.py", line 41, in send_request response = await self._send_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/plugp100/protocol/passt hrough_protocol.py", line 61, in _send_request await self._login_with_version(self._credential) File "/home/userland/hass/lib/python3.12/site-packages/plugp100/protocol/passt hrough_protocol.py", line 80, in _login_with_version session_or_error = await self._passthrough.handshake(self._url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/plugp100/protocol/secur epassthrough_transport.py", line 70, in handshake response = await self._http.async_make_post(url, json=request_body) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/plugp100/common/utils/h ttp_client.py", line 18, in async_make_post async with self.session.post( File "/home/userland/hass/lib/python3.12/site-packages/aiohttp/client.py", lin e 1187, in aenter self._resp = await self._coro

...skipping 1 line File "/home/userland/hass/lib/python3.12/site-packages/aiohttp/client.py", lin e 574, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/aiohttp/connector.py", line 911, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/aiohttp/connector.py", line 1235, in _create_direct_connection raise last_exc File "/home/userland/hass/lib/python3.12/site-packages/aiohttp/connector.py", line 1204, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/userland/hass/lib/python3.12/site-packages/aiohttp/connector.py", line 1000, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.1

...skipping 1 line The above exception was the direct cause of the following exception:

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

TheMitch commented 8 months ago

Same issue applies to the p115

dye87 commented 8 months ago

I have also the issue with my p110's

Kamil3001 commented 8 months ago

Hi, I am having the same issue with P110 but not all of them. 3/7 have this issue.

EDIT: I have managed to fix this by relinking the plugs with the Tapo app. Hold the power button for 10+ seconds and then re-add the device in the app. Then immediately add it to HA

jnsw commented 8 months ago

Having the same issue, stating "Failed to connect" but I managed to add 2 devices, sometimes mutilple tries help, but its really painful always to fill out the fields

someone into that issue? logs saying:

Bildschirmfoto 2024-01-21 um 19 52 16

EDIT: issue resolved, just had to update my tapo plugin from hacs

achie188 commented 8 months ago

I'm having the same issues - have reinstalled the tapo integration through HACs as well as readding devices in the Tapo app itself.

NathanPeake commented 8 months ago

image

installed did the setup was working fine for a few hrs restarted HA and now its not working as expected. just looping on the retry.

alx-xlx commented 8 months ago

I am having the same issue, the device had previously worked well. Now I have readded the device on the Tapo app with another name and then trying to add it to HA on the same previous IP address and I am unable to connect

I get this error, I have no idea what to do next

Logger: custom_components.tapo.config_flow
Source: custom_components/tapo/config_flow.py:119
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: 6:04:35 PM (1 occurrences)
Last logged: 6:04:35 PM

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 "/config/lsiopy/lib/python3.11/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.0.163', 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
Rusketh commented 8 months ago

I got new Tapo P110s this week and none of them can be connected to by Home Assistant but I can ping them from Home Assistant.

omega015 commented 8 months ago

Same here, new P110's home assistant (all latest versions) cannot connect. "Failed to connect" error.

Logger: custom_components.tapo.config_flow Source: custom_components/tapo/config_flow.py:119 Integration: TP-Link Tapo (documentation, issues) First occurred: 21:15:45 (3 occurrences) Last logged: 21:17:38 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.11/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.0.102', 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

hwharwig commented 8 months ago

Same here, 2.3.0. 1x P110 was working other 3 not yet connected. Now connected all 4 and updated firmware on all 4 to 1.3.0. All 4: "Failed to connect".

Babacooll commented 7 months ago

Same here with all P110 😞

peruggini commented 7 months ago

I don't know what happened, just gived a "desperated" try and one device was added successfully. Then the other two, ok with them, too! Is there something I can do to provide useful data?

peruggini commented 7 months ago

HomeAssistant restart and issue appeared again

jc12col commented 7 months ago

Same issue here "Failed to Connect" Although I will add that I have some tapo cameras, and having the same issue.......... searched high and low for answers on how to get these working again, but getting to the point where I may just go to a different brand, any suggestions?

EDIT - I am an absolute beginner with HA - so struggle with most things!

whoisthedaddy commented 7 months ago

Hi all, not sure if this is helpful and a bit of a ramble I'm afraid but I have 23 x P110 connected via the integration and they have been flawless so can't help thinking it may not be the integration but something else within the system? I did encounter problems when ticking the box 'track by MAC address (experimental) so I now leave this unchecked. I also assign static IPs to all my P110's. I also had some issues with the KASA and TAPO apps (still have a few HS100s) but it turned out they each had different email addresses associated with them and as soon as I changed this those issues disappeared. My process to add is to connect them via the Tapo app - they are all called 'Socket: xxxx' - then update the firmware (the last one I did last night after the integration update as it shows Hardware version 1, Firmware 1.3.0 Build 230905 Ref 152200. Take a note of the MAC/IP address and assign this as static on the router and then add into HA. I'm running HA on a RP4. I also have them alll on their own IOT network. Although the logs might suggest otherwise based on the above I can't help thinking there may be a conflict elsewhere - as an example I've had all sorts of problems recently with HA 'randomly' restarting and each log was different, I tried disabling integrations, add-ons etc but ultimately the problem was that the PSU for my PI wasn't sufficient - upgraded this and no random restarts anymore.

jc12col commented 7 months ago

Hi all, So, I still cannot get this to work and agree that it is probably not the integration.

I have just deleted all previous Tapo integrations on my HA. I have set up a new Tapo account on a different email, (all lowercase) in the app and added a P110 plug device - successful.

I have downloaded and installed from HACS again

Does anyone have suggestions on what to do next?

whoisthedaddy commented 7 months ago

Hiya - that does seem strange - you can add one but no another would immediately suggest there is something one with the only thing that is different, i.e. the plug - perhaps the second one is faulty - reconfigure using the app and try again? (What did you call the first plug and is the second one of a similar name - perhaps it doesn't like the name you used in the setup? Firmware versions on the plug the same? Sorry nothing specific but a few things to try....

stephencoe commented 6 months ago

I was having the same issue with this after a recent update. One thing that stood out for me was the IP it was trying to connect with wasn't the IP of the device (I would use 192.168.68.115 yet the logs show 192.168.68.107).

It felt like it was cached somewhere, my suspicion was that something relating to mac addresses prior to the update.To verify the underlying code I ran a test with this and was able to connect successfully

I can't be certain which change was finally responsible but this was fixed for me through one of these changes:

Once I did this for a single plug the others were auto discovered and the integration is now operational again

Rusketh commented 6 months ago

Found out there was a capital letter In the email when I signed up, tappo does not show you the capital letter. Created a new account with out using any caps and it works fine now.

jc12col commented 6 months ago

Hey all, Going to give my Tapo one last try before moving on to maybe TUYA.

What's the best way to remove all previous Tapo integration and data so I am starting afresh?

I have a feeling that deleting the integration would not do this.....happy to be proved wrong.

Do I need to also Create a new Tapo account and register my plugs there?

Then, with a clean sheet, the best way to install 4 x P110 plugs?

Happy to follow suggestions to get the best outcome, ie Tapo integration working!

I am a beginner, so please feel free to write your comments as if I am an idiot, (maybe I am, as I cannot get the current integration to work!)in simple terms so that other beginners like me will also be able to benefit from your knowledge.

Appreciate anyone who takes the time to respond to this!

Thanks

J

blackthorn87 commented 4 months ago

I'm getting a similar issue that's described in this ticket. All my Tapo devices were working fine until a few days ago.

My username and password as all fine, I'm getting any errors with those.

It looks like others are having the same issue: https://community.home-assistant.io/t/tapo-devices-fail-to-connect/675178/8

I'm running the following if that helps:

The devices I'm trying to connect are:

Here is the latest error I get in my logs when trying to add a device:

This error originated from a custom integration.

Logger: custom_components.tapo.config_flow
Source: custom_components/tapo/config_flow.py:143
integration: TP-Link Tapo (documentation, issues)
First occurred: 11:39:02 (1 occurrences)
Last logged: 11:39:02

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
0ranki commented 4 months ago

Similar issue as @blackthorn87, 2 out of 4 P100 devices stopped working (I didn't notice this until today, so not sure when exactly). Tried downgrading & upgrading the plugin and removing and readding the devices, but gettimg the same tapo.errors.CannotConnect error.

What's interesting is that the 2 other plugs from the same package of 4 with the same firmware version work.

blackthorn87 commented 4 months ago

Similar issue as @blackthorn87, 2 out of 4 P100 devices stopped working (I didn't notice this until today, so not sure when exactly). Tried downgrading & upgrading the plugin and removing and readding the devices, but gettimg the same tapo.errors.CannotConnect error.

What's interesting is that the 2 other plugs from the same package of 4 with the same firmware version work.

I figured out my issue, it was user error (https://github.com/petretiandrea/home-assistant-tapo-p100/issues/774).

0ranki commented 4 months ago

Similar issue as @blackthorn87, 2 out of 4 P100 devices stopped working (I didn't notice this until today, so not sure when exactly). Tried downgrading & upgrading the plugin and removing and readding the devices, but gettimg the same tapo.errors.CannotConnect error.

What's interesting is that the 2 other plugs from the same package of 4 with the same firmware version work.

I managed to get one of the non-functional P100s integrated back. Not sure which of these steps is significant:

  1. Remove plug from HA
  2. Downgrade Tapo plugin to some older version
  3. Restart HA
  4. Upgrade Tapo plugin back to 3.1.2
  5. Restart HA again
  6. Change account password
  7. Update plug firmware
  8. Dismiss the auto-discovered plug (I'd bet this is the significant one)
  9. Add the switch manually
hajmiller-at commented 1 day ago

Similar or actually same issue (and pretty well exact log content) as this ticket. Any updates, pointers or ideas on a possible resolution?

As new to the Tapo range - first test device - I have never seen a working install and if this is going to be an issue I guess I will have to go to another brand. (Already been through pretty well every google reference in 2 languages - tried all of the ones I thought made any sense :-) )

As a workaround meanwhile I set up a Smart Things account (something I do not want to use in production) and integrated the P110 there - then used the HA stock Smart Things integration.

This however has no future as the energy sensors are not fully implemented in ST as far as I can judge and is therefore nothing more useful than an on/off switch in HA :-(

Any feedback greatly appreciated. Thx.

Config: Tapo P110 / FW: 1.3.1 HA Core 2024.8.1 Tapo integration 3.1.2/3.1.3/3.1.4