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

TP-Link/Kasa integration frequent problem with connection or updating #93312

Closed
dolfs opened this issue May 21, 2023 · 16 comments
Closed

TP-Link/Kasa integration frequent problem with connection or updating #93312

dolfs opened this issue May 21, 2023 · 16 comments
Assignees

Comments

@dolfs
Copy link

dolfs commented May 21, 2023

The problem

I see two kinds of errors with Kasa integration frequently in my logs:

  • Updating state for sensor.plug_6_current_consumption (<class 'homeassistant.components.tplink.sensor.SmartPlugSensor'>) took 0.705 seconds
  • Error fetching 192.168.10.164 data: Unable to connect to the device: 192.168.10.164 (390 occurrences)

Both errors happen on more than one Kasa smart socket/plug, happen frequently. The example above both represent the same plug (it is a plug on a HS300, but I also see it with KP1125 devices etc.). Whenever I see this and check with a network utility the devices are listed as on-line, respond to ping, and show as "everything fine" in the KASA app.

Overall functionality seems largely unaffected, but the logs are being swamped with these messages.

What version of Home Assistant Core has the issue?

2023.5.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

TP-Link/KASA

Link to integration documentation on our website

No response

Diagnostics information

config_entry-tplink-cb4a0b8013ed0f6cb9971a2397e05853.json.txt

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

home-assistant bot commented Jul 6, 2023

Hey there @rytilahti, @TheGardenMonkey, 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.

(message by CodeOwnersMention)


tplink documentation
tplink source
(message by IssueLinks)

@rytilahti
Copy link
Member

  • Unable to connect to the device: 192.168.10.164

This just indicates that the connection is broken for a reason or another, but does not give any other hints why that may be happening.

Are you seeing any other error message after that in the logs? You could try to enable debug logging to get more information, if nothing else is not shown.

@jasonalsing
Copy link

I'm having similar issue, I have 2 HS103 plugs (2-pack same box) and one in my office shows "unavailable" every few minutes for about 10 seconds. Now my WiFi isn't "Great" in the office but according to the AP this plug is at -70dbm so should be fine (my house isn't that big) and non-Kasa devices seem to work solid in far worse conditions.

However to note, the second plug as a test I plugged into in my "game room" which is 20 ft from the AP (-46dbm) and it seems to stay connected 100% at least for the last 24 hrs or so,

Logger: homeassistant.components.tplink.coordinator
Source: helpers/update_coordinator.py:229
Integration: TP-Link Kasa Smart (documentation, issues)
First occurred: July 8, 2023 at 4:30:21 PM (1360 occurrences)
Last logged: 9:20:02 PM

Error fetching 192.168.66.236 data: Unable to query the device 192.168.66.236:
Error fetching 192.168.66.236 data: Unable to connect to the device: 192.168.66.236:
Error fetching 192.168.66.236 data: Unable to connect to the device: 192.168.66.236: [Errno 113] Connect call failed ('192.168.66.236', 9999)

@rytilahti
Copy link
Member

Please test if the upcoming 2023.7.4 release improves the situation and report back, thanks!

@bdraco
Copy link
Member

bdraco commented Jul 24, 2023

Updating state for sensor.plug_6_current_consumption (<class 'homeassistant.components.tplink.sensor.SmartPlugSensor'>) took 0.705 seconds

That duration indicates you might have something blocking your event loop.

Can you try putting asyncio in debug mode?
https://docs.python.org/3/library/asyncio-dev.html#debug-mode

You can also do this by enabling debugpy: in configuration.yaml

Than look for any asyncio messages in the raw log (download in the UI)

@bdraco
Copy link
Member

bdraco commented Aug 4, 2023

@bdraco
Copy link
Member

bdraco commented Aug 4, 2023

It probably makes sense to have a connect timeout of 30s and half of that for a read/write round trip to deal with poor Wi-Fi connections

@bdraco
Copy link
Member

bdraco commented Aug 4, 2023

@jasonalsing
Copy link

Please test if the upcoming 2023.7.4 release improves the situation and report back, thanks!

does not seem to be helping in my case (2023.8.1)

@Vendivar
Copy link

I am also having this same problem

@ctml91
Copy link

ctml91 commented Dec 27, 2023

Same problem. I'm not noticing any issues, just clutters the logs.

Logger: homeassistant.components.tplink.coordinator
Source: helpers/update_coordinator.py:322
Integration: TP-Link Kasa Smart ([documentation](https://www.home-assistant.io/integrations/tplink), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+tplink%22))
First occurred: 5:57:22 PM (3 occurrences)
Last logged: 6:15:51 PM

Error fetching 192.168.2.25 data: Unable to query the device 192.168.2.25:9999:
Error fetching 192.168.2.23 data: Unable to query the device 192.168.2.23:9999

@wjb178
Copy link

wjb178 commented Dec 29, 2023

I was also getting hundreds of the "Unable to connect to the device" log messages for a while. Many of the devices were also going unavailable for 1 second in the logbook. Occasionally the unavailable lights would cause an error in an automation.

It seems letting Tplink update the firmware on all the devices has corrected the problem for me. It's been 24 hours and I have no log messages and none of the devices have gone unavailable since.

I had always blocked the devices from internet access afraid of Tplink firmware updates blocking local access. I decided to take a chance and let all the devices update to the new firmware.

For reference
I have 27 Tplink devices.
Mix of HS200 switches, HS220 dimmers, KL125 bulbs and KP125 outlets.
They connect to 2 tplink EAP245 wifi access points. Omada controller log shows no disconnects for any of the devices. All wifi signals are greater than 75 percent.

@jhemak
Copy link

jhemak commented Feb 2, 2024

Same as others:

2024-02-01 22:29:45.293 ERROR (MainThread) [homeassistant.components.tplink.coordinator] Error fetching 192.168.3.136 data: Unable to connect to the device: 192.168.3.136:9999: [Errno 113] Connect call failed ('192.168.3.136', 9999)
2024-02-02 01:59:00.301 ERROR (MainThread) [homeassistant.components.tplink.coordinator] Error fetching 192.168.3.136 data: Unable to connect to the device: 192.168.3.136:9999: [Errno 111] Connect call failed ('192.168.3.136', 9999)
2024-02-02 02:01:42.147 ERROR (MainThread) [homeassistant.components.tplink.coordinator] Error fetching 192.168.3.125 data: Unable to connect to the device: 192.168.3.125:9999: [Errno 111] Connect call failed ('192.168.3.125', 9999)
2024-02-02 02:11:58.541 ERROR (MainThread) [homeassistant.components.tplink.coordinator] Error fetching 192.168.3.136 data: Unable to connect to the device: 192.168.3.136:9999: [Errno 113] Connect call failed ('192.168.3.136', 9999)

@DevSecNinja
Copy link
Contributor

DevSecNinja commented Feb 3, 2024

Same as others with my HS110's (EU). Has been going on for quite a while so I'm not sure with what Home Assistant release the issue first started. The TP-Links are blocked from internet access on my firewall considering their actions of the past, so the firmware is probably old (Firmware: 1.5.6 Build 191125 Rel.083657).

In the logs I'm seeing two variants though:

ERROR (MainThread) [homeassistant.components.tplink.coordinator] Error fetching <ip> data: Unable to query the device <ip>:9999: 
ERROR (MainThread) [homeassistant.components.tplink.coordinator] Error fetching <ip> data: Unable to connect to the device: <ip>:9999: 

@sdb9696
Copy link
Contributor

sdb9696 commented Feb 8, 2024

These issues should be fixed in the latest HA release 2024.02.

@sdb9696
Copy link
Contributor

sdb9696 commented Feb 8, 2024

@home-assistant close

@home-assistant home-assistant bot closed this as completed Feb 8, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 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