Kasa/TP-link devices constantly losing connection for less than a second

I just installed a bunch of Kasa smart lights. They’re working great, and openHAB is controlling them just fine… however, when I check my log, it’s filled with errors saying that a TP-link device has lost connection (timed out), followed in less than a second by a reconnection status. And of course, any associate item goes to “UNDEF” during the connection loss, and then back to its proper state.

If I didn’t look at my logs, I wouldn’t even know there was an issue, but my logs are seriously overrrun by these errors. I went all in on Kasa lights for my outdoor lighting area and some indoor lamps, so I currently have 13 kasa bulbs and it seems like most of them throw this error every couple of minutes.

Here’s an example disconnect/reconnect pair of lines from the log:

2021-12-21 16:19:32.716 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'tplinksmarthome:kl125:C6840B' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Read timed out

2021-12-21 16:19:33.132 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'tplinksmarthome:kl125:C6840B' changed from OFFLINE (COMMUNICATION_ERROR): Read timed out to ONLINE

Has anyone else had this issue? Is there a way to suppress these particular types of log events? Or to figure out why the lights keep timing out?

I was thinking it might be an issue with poor wifi signal strength, but I have a mesh router with really good coverage, and the RSI in all locations should be more than adequate.

Maybe the binding has an ever-so-slightly shorter time-out on communications than the polling cycle of the bulbs?

Yep, I get that happening with my Kasas every once in awhile, but I don’t worry about it as there’s no real-world impact. It usually sorts itself out after awhile, and sometimes I reboot my router (which puts an end to it).

I don’t have bulbs, just switches and plugs. What’s interesting is that I also have a mesh router, and I can’t remember if this happened before that was the case. Maybe a Kasa decides to hop back and forth between the APs every once in awhile (even though that shouldn’t happen).

I don’t think that would be the case, or else it would happen with all of them constantly and never-endingly. @hilbrand, have you heard of this before?

The timeout is 3 seconds. What refresh cycle time did you set on the bulbs? Or did you use the default of 30 seconds? Because I wouldn’t expect that it comes online directly after the timeout.

Interested to hear a fix for this one also. I discovered a few months back that the newest patch to my router causes all my TP-Link light switches/smart plugs to start flapping as you describe. After some research I tried a number of settings changes with no effect before rolling back the patch.

No fault of openhab but definitely an annoyance.
Cheers

I left the refresh cycle on the default 30 seconds.

I also have about 60 devices on the router, so maybe my router just can’t keep up… but most of the devices are just IoT things that shouldn’t have much traffic, and the router should theoretically handle upwards of 200 devices. It’s an Orbi RBR750 with two satellites. Not super high-end, but certainly better than most home wifi routers.

The plot thickens: my router is an Orbi RBR40. If @pleedell also has an Orbi, then we have a correlation.

It happened early this morning with one of my switches that’s only about 15ft from the router. Over the course of an hour, it disconnected and reconnected seven times (usually after two seconds), and then just went back to normal. Is this similar to what you’re seeing?

2021-12-22 00:00:38.919 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from OFF to UNDEF
2021-12-22 00:00:40.155 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from UNDEF to OFF

2021-12-22 00:26:35.794 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from OFF to UNDEF
2021-12-22 00:26:37.740 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from UNDEF to OFF

2021-12-22 00:37:04.674 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from OFF to UNDEF
2021-12-22 00:37:06.167 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from UNDEF to OFF

2021-12-22 00:37:36.274 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from OFF to UNDEF
2021-12-22 00:37:38.699 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from UNDEF to OFF

2021-12-22 00:53:38.754 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from OFF to UNDEF
2021-12-22 00:53:40.658 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from UNDEF to OFF

2021-12-22 00:56:42.834 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from OFF to UNDEF
2021-12-22 00:56:44.222 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from UNDEF to OFF

2021-12-22 01:02:21.071 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from OFF to UNDEF
2021-12-22 01:02:22.467 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Switch_Office' changed from UNDEF to OFF

Huh. Someone on the TP-Link forum solved their problem by switching to an Orbi router.

Whatever the case, it’s almost certainly an issue between the router and Kasas.

Yeah, that’s similar.

I’m beginning to wonder if it has something to do with the mixed 2.4 and 5 GHz SSID, and the band auto-steering that Orbi uses. The kasa lights are 2.4 GHz only, so perhaps the Orbi is trying to push them to the 5GHz radio, and when that fails, it switches back to 2.4 and they reconnect? It could even be as simple as channel-switching, if the router is set to automatically select a channel

I’m out of the house at the moment, but when I get back I will do some experimenting with router settings and see what happens.

I don’t think the Orbi would try to push them to 5G, since they don’t have that capability. But I could see the switches jumping between access points.

Note that for me, it’s only ever one Kasa at a time. It’s not always the same Kasas, but I feel like some of my switches/plugs have never done it at all.

I’m curious about this paragraph from the first link I posted:

After looking at the router logs I saw that all of my HS105 plugs and my HS200 switch were constantly disconnecting and reconnecting to the router every few seconds. All of that activity seemed to be causing the outages I was having because once I isolated the problem and unplugged the plugs and blocked the switch, the outages have stopped. I blocked the switch using Wireless > Wireless MAC Filter on the 2.4GHz band which rendered it unusable in the Kasa app and also stopped it from trying to reconnect to the router every 5 seconds or so. I should note that the wifi signal to the switch was excellent -28db so that isn’t the issue.

It’s a bigger issue if it’s causing Internet outages, but I haven’t noticed that being a problem.

I had a look at the binding, and made some changes to not set the device directly off-line after a communication error, but retry 2 times before setting the device off-line. The idea is this should suppress setting the device going offline. I’ve put the updated binding in the marketplace here, so you can install it from main ui via the marketplace and try if it helps or if it needs some tweaking.

3 Likes

Thanks, Hilbrand! I haven’t jumped to 3.2 yet, but I’ll keep that in mind.

@Chad_Hadsell, if you want to try experimenting with router settings then I’d be happy to keep looking at it with you.

Thanks, Hilbrand! I’ve managed to tame the issue somewhat by giving each of my kasa devices a static IP, but it still happens.

Russ, have you tried assigning static IPs?

I’ll give this updated version of the binding a try and report back!

EDIT: After an hour of running the updated binding (and having the static IPs for the kasa devices), the disconnect error has been significantly reduced. I’m down to one or two every few minutes, instead of 10-12 every minute. The log is actually readable again! Thanks for the quick work on the updated binding, Hilibrand!

EDIT2: A few more hours later, and things have settled down even more. There were only 8 disconnect errors over the last hour. Seven were time-outs, and one was a “no route to host (Host Unreachable)” error. Also, only four of my kasa devices caused these errors, and one device accounted for half of the errors. I’ll be setting up the RSSI channel for that device to monitor the signal strength moving forward. I may just need to change the placement of my mesh satellites to make sure everything gets a good, strong signal.

I only use static IPs for switches/plugs. I had to do that for the system I was using before openHAB, so I just kept the habit. Perhaps that’s why I wasn’t seeing it as frequently as you.

Keep in mind that the disconnects are still happening even if they show up less frequently in your log due to Hilbrand’s mods. Might be worth keeping an eye on that TP-Link forum.

No orbi here, I use an Asus AX88U on firmware 3.0.0.4.386_44266-g7f6b0df from July 2/2021. With about 70 devices connected I have no issues with the kasa switches or anything else, it is running perfectly. However I’ve attempted to upgrade to every other firmware release since then and each causes the flapping issue with kasa switches and smartplugs. I’ve gone through the vulnerability patches for the subsequent firmware release with the thinking that somewhere in that list is the root cause.

No luck yet however.