I have a little automation that turns on a Kasa smart switch when motion is detected. It works great but after a reboot it goes offline for long periods, like days sometimes. I have to give it to the homeassistant team for the fact that it eventually fixes itself but is there something I need to do to make it connect after a reboot?
The Kasa integration is somewhat old and, from time to time, experiences issues such as the one you’re seeing. There are several topics discussing this and other issues. Search on Kasa Integration, TPLink or TPLink offline. There’s work afoot (by others) to improve the integration. Until that work is done, I found the best approach is to add a few lines to your configuration.yaml. Here’s a sample;
# TP Link Kasa Devices
# The section has been added as the current integration (Oct 14/20)
# does not find dimmer switches
tplink:
discovery: false
switch:
- host: 192.168.2.190 #Kasa Switch - Kitchen Counter - East
- host: 192.168.2.191 #Kasa Switch - Kitchen Counter - South
- host: 192.168.2.192 #Kasa Switch - Studio Pot Lights
- host: 192.168.2.210 #Kasa 3-Way - Kitchen Island
- host: 192.168.2.215 #Kasa 3-Way - Kitchen Pots
- host: 192.168.2.220 #Kasa Plug - Floor Lamp
- host: 192.168.2.225 #Kasa Plug - Couch Lamp
- host: 192.168.2.230 #Kasa Plug - Side Table
- host: 192.168.2.235 #Kasa Plug - Desk Lamp Breakfast Room
- host: 192.168.2.240 #Kasa Plug - Dresser
- host: 192.168.2.245 #Kasa Plug - Reading Lamp
dimmer:
- host: 192.168.2.195 #Kasa Dimmer - Dinning Room Light
- host: 192.168.2.200 #Kasa Dimmer - Breakfast Room Light
- host: 192.168.2.205 #Kasa Dimmer - Living Room Pots
Remove the “- host” entries that don’t relate to your configuration and replace them with the IP address of your switch. Restart HA. Give it a few minutes then check for the switch that keeps dropping off-line. It should be present. If not, the next thing to check is the wi-fi signal strength. If it’s not very strong at the location of the switch you may have to up the power of the wi-fi or add an AP.
Regards
Thanks Robert. It worked once I got the right ip address. is there any way to give it a static ip?
It may be possible to establish static IP reservations on the router used in your network. That’s how I setup the devices used here. The mac address of the device may be needed. That’s available in the Kasa app. Each router manufacturer uses different configuration screens so you’ll need to search Google for instruction for your specific model using “IP reservation router”.
I’ve used TP-Link smart plugs for a while. I strongly recommend reserving static IP addresses in your router. HA doesn’t seem to like when the addresses change!
I’ve also had good luck using the dynamic discovery and NOT including the individual IP addresses in configuration.yaml. I still got occasional “unavailable” devices, but in most cases they’d come back on their own with auto-discovery enabled. My configuration.yaml has only one line for TP-Link (tplink:) with no other parameters below it.
There was a recent update which some users are reporting has fixed or significantly reduced the “unavailable” problem. You’re coming in at a good time:
Good too know. Thanks
Thanks again,Robert. I will give it a try.