home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.43k stars 30.67k forks source link

Lost communication with TP Link Kasa Plugs after firmware update #43088

Closed danielsmith89 closed 1 year ago

danielsmith89 commented 3 years ago

WORKAROUND

https://www.tp-link.com/us/support/faq/2707/

The problem

Lost communication with all TP Link Smart Plugs. Smart Lightbulbs still working as expected. However all works fine on TP Link Kasa App, so I know it's on the network and working correctly.

Environment

Problem-relevant configuration.yaml

tplink:
  discovery: false
  light:
    - host: 192.168.1.188
  switch:
    - host: 192.168.1.181
    - host: 192.168.1.176

Traceback/Error logs

2020-11-11 10:18:36 WARNING (SyncWorker_0) [homeassistant.components.tplink.common] Unable to communicate with device 192.168.1.181: Communication error
2020-11-11 10:18:36 WARNING (SyncWorker_0) [homeassistant.components.tplink.common] Unable to communicate with device 192.168.1.176: Communication error

Additional information

smoke007 commented 3 years ago

My three model HS100, hardware version 1.0, with firmware 1.2.6 were all not working yesterday, but this morning, all started working again. Port 9999 (abyss) was open yesterday on each and is the same still today. I made no changes over night and had tried rebooting Home Assistant several times yesterday with no change.

Supervisor 2020.11.0 OS HassOS 4.16 HA 0.117.6

deosrc commented 3 years ago

@deosrc do you have a TP-Link account (so that you can control the plug from outside your local network)? If so then you might need to set an email and password at https://gist.github.com/chriswheeldon/3b17d974db3817613c69191c0480fe55#file-hs110-py-L79

I've not tried this as I do not have an account.

@chriswheeldon I don't have a TP-Link account and the app is showing "Guest"

danerich commented 3 years ago

Just had this comment from TP-Link Support:

Thank you very much for your email requesting information about TP-Link product.

We were aware that there were some security vulnerability on the previous firmware, some third parties might take advantage of the vulnerability to manage the plug. To avoid the potential attacks and security risks causing by this, we have released a new firmware version 1.1.0 to fix it. After upgrading to the latest firmware, some customers who were not using KASA app to manage the plug might found that it is not working.

It is suggested to use the TP-Link official App KASA to manage the plug, and we can confirm that there are no functionalities on the KASA app have been removed on the latest firmware. Your understanding will be much appreciated.

So it might be time to look to replace them for my use case. Really don't want to use their app.

Robbo312 commented 3 years ago

Just had this comment from TP-Link Support:

I've now blocked my other TP-link plugs from accessing the internet to stop them getting upgraded and using REST via the cloud (see previous comments) to access emeter and control the ones that have been upgraded.

I won't be buying TP-Link again, time to support hardware manufacturers that include open protocols out of the box. On that note just read Shelly are about to release a UK plug, so that will probably be the way to go.

I also think it's arrogant for TP-Link to upgrade our stuff without warning or permission, the update caused a reboot of the device and who knows what could have been plugged in to it.

brendonrogers commented 3 years ago

@RobBie1221 agreed, its a bit disappointing from TP-Link, I've switched to Gosund UP111 UK plugs and flashed them with Tasmota to avoid issues like this. Interesting about Shelly, I'll keep an eye out.

conorlap commented 3 years ago

Just had this comment from TP-Link Support:

Yep I got the exact same response, I emailed back to complain loads but doubt they'll do anything. So annoyed at this, I literally bigged up the HS100s to lots of people saying how solid they were and how well they worked in HA! I love smart home tech but also despise it!

tombeynon commented 3 years ago

Anyone else lost HS110 connection too this morning? I was only having issues with HS100s but today my HS110s are appearing in HA but trying to change state throws an API error.

Robbo312 commented 3 years ago

Anyone else lost HS110 connection too this morning? I was only having issues with HS100s but today my HS110s are appearing in HA but trying to change state throws an API error.

I only have HS110's and the hardware v4.1's were updated the other day. I've disabled the others from accessing the Internet so they don't get updated.

bristol406 commented 3 years ago

@RobBie1221 agreed, its a bit disappointing from TP-Link, I've switched to Gosund UP111 UK plugs and flashed them with Tasmota to avoid issues like this. Interesting about Shelly, I'll keep an eye out.

I have four UK HS100s which are now 'bricked' for my application. Stuffed my heating system. Can you point me to any information on flashing the Gosund plugs ? I may just switch horses and scrap the TP-Link devices.

danielsmith89 commented 3 years ago

I've also just contact TP-Link support and even pointed the to this Github page. Suffice to say this will be the last TP-Link product I will be buying if this is their attitude.

dragon2611 commented 3 years ago

I've also just contact TP-Link support and even pointed the to this Github page. Suffice to say this will be the last TP-Link product I will be buying if this is their attitude.

I think they're a bit between a rock and a hard place tbh, as it was reported to them as a vulnerability, I'd imagine the whole TP-Link smartplugs are Insecure thing would have lost them a lot more sales than breaking various integrations does, I don't think they were ever sold as being locally controllable by 3rd party systems.

That said given it was a breaking change It would have been better if they could have pushed a message to Kasa warning that the firmware was to be upgraded and given you an option to opt-out with a standard disclaimer to cover themselves or provided an option to turn the old "insecure" way back on.

I actually find their multiple hardware revisions of the same product sometimes with different features more of a problem than this.

parautenbach commented 3 years ago

I've now blocked my other TP-link plugs from accessing the internet to stop them getting upgraded and using REST via the cloud (see previous comments) to access emeter and control the ones that have been upgraded.

Which port(s)/host(s) did you block?

dragon2611 commented 3 years ago

I've now blocked my other TP-link plugs from accessing the internet to stop them getting upgraded and using REST via the cloud (see previous comments) to access emeter and control the ones that have been upgraded.

Which port(s)/host(s) did you block?

If it were me I'd just block all outbound traffic from the ip of the plug.

Sadly mine already upgraded so too late for me.

conorlap commented 3 years ago

I've now blocked my other TP-link plugs from accessing the internet to stop them getting upgraded and using REST via the cloud (see previous comments) to access emeter and control the ones that have been upgraded.

Which port(s)/host(s) did you block?

I blocked everything except port 9999 - the port used for local talking

Robbo312 commented 3 years ago

Which port(s)/host(s) did you block?

I just blocked the plugs from accessing the Internet.

Madbeefer commented 3 years ago

Only my dimmer switches are still available in HA, but I got this response from Kasa. Thank you very much for your email requesting information about TP-Link product.

We didn't release new firmware for our smart switch, so there is no change to Kasa smart switch. So would you please double confirm if your switch can work with home assistant?

Would you please confirm if you can control your Kasa smart devices remotely when you're not at home or using mobile data?

​Looking forward to your reply. Have a nice day! Your kindly feedback is much appreciated, please feel free to contact us if you need any further help. Best Regards!

deosrc commented 3 years ago

Latest response from TP-link seems more promising:

Thank you for your feedback.

For the other hardware version, like version 1 or version 2.1 etc, we didn't have the plan to upgrade the firmware of them.

We are aware that the support of third party is a very useful feature for some customers to manage their smart devices.

I have forwarded your feedback our R&D department and our seniors are still evaluating and looking into a possible solution for this.

We will let you know if a solution is available.

We really appreciate your patience and understanding in this matter.

Not quite sure why the exact same protocol on HW v4.1 isn't an issue on HW versions 1 and 2.1 but best not to question that.

dragon2611 commented 3 years ago

Probably eol versions they don't still sell.

I got a similar response from my last email to them suggesting they make an API or official SDK available.

I suspect they're getting a few compliants about it, I'm hoping that if they come to realise that working with 3rd party tools like homeassistant means they sell more devices they'll be a bit better at supporting such integrations.

Won't hold my breath however.

danielsmith89 commented 3 years ago

The response I had this morning from them wasn't anywhere near as promising:

This is one of tp-link supervisors Candice to follow up your case. Thank you for let us know your concern. We could understand your frustration as the Home assistant has been working before, but I'm afraid Home assistant does not have the privilege to manage HS100/HS110 V4 plugs anymore. The new firmware fixed the security vulnerability that may be utilized for attacks on TP-Link plugs and certain resources currently are not open to unauthorized applications for security reason. We are sorry that Home assistants was affected by that but this a decision we have to made to protect smart plugs for our customers. Besides, tp-link has not advertised the Home Assistant integration on official websites, and we can not guarantee that feature will work properly.

Robbo312 commented 3 years ago

TP-Link are downgrading HS100/110 devices too users who request it; https://community.tp-link.com/en/home/forum/topic/236268?page=3

SimonWilkinson commented 3 years ago

Based on @chriswheeldon work here - https://gist.github.com/chriswheeldon/3b17d974db3817613c69191c0480fe55 and some earlier protocol sniffing I had been doing, I've extended python-kasa to support the new protocol. I've contributed it as their pull request 117.

With this, Home Assistant should just work with plugs that are set up in "Local" mode (where you configure them from an app without a cloud account connected) and auto discovered. Plugs that are connected to an authenticated cloud account, or those which are configured statically, will need some changes in Home Assistant to support passing a username and password into the Discover.discover call, or the SmartPlug constructor.

Of course, if they're now downgrading devices, I could have saved myself the effort!

iAmRenzo commented 3 years ago

My HS110 is still on 1.0.4 and working. I wonder, can TP-Link update firmware without the Kasa app? And does anybody know what the url is of the TP-Link service? I'd like to block it in Pi-hole/Router to avoid an update.

deosrc commented 3 years ago

I wonder, can TP-Link update firmware without the Kasa app?

Yes they can. The plugs connect directly to the TP-Link servers to update.

I'd like to block it in Pi-hole/Router to avoid an update.

Not sure about the hostname to block but I believe you can block a specific client on PiHole. Depending on your router, you may also be able to block the plug from accessing anything except local network.

iAmRenzo commented 3 years ago

Thanks. I have two domains, from somewhere. Unfortunately my router is some sort of DNS proxy, so the individual clients don't show up in AdGuard/Home. And disabling the device in my router (Orbi) seems to disable local network access as well :(

marcomsousa commented 3 years ago

HA TPLink integration use a abandoned library (pyHS100), must upgrade to the new one https://github.com/python-kasa/python-kasa

In this new python library the new Firmware will be fully supported: https://github.com/python-kasa/python-kasa/pull/117

SimonWilkinson commented 3 years ago

Christmas is coming, and I needed my plugs back in action to be able to turn the tree lights on and off.

So I've made a quick and dirty back port of my python-kasa pull request to support the new protocol into the pyHS100 library that's currently used by Home Assistant. This is designed as a drop in replacement for the existing pyHS100 library. As there's no way of passing in usernames and passwords without also modifying home assistant, this will only support plugs that are configured without a cloud account - you can do this in the Kasa app by skipping the "create a cloud account" step when setting them up.

If you're interested in trying it, you can download the modified library by doing pip3 install git+https://github.com/SimonWilkinson/pyHS100.git@new-protocol from with your Home Assistant virtual environment. You then also need to prevent Home Assistant from replacing the modified library, either by running hass with --skip-pip, or modifying the homeassistant/components/tplink/manifest.json manifest file to remove the forced pyHS100 version.

I hope this is of use to people trying to get their plugs back online!

oscarhibbert commented 3 years ago

@SimonWilkinson Thank you very much for posting this workaround! Is there a different approach needed for people with Home Assistant OS running on VirtualBox?

jakemauer commented 3 years ago

For those using Home Assistant via Docker who are interested in @SimonWilkinson's workaround the path for the files is /usr/src/homeassistant/homeassistant/components/tplink/manifest.json. You can use sudo docker exec -it [your HASS container name] /bin/bash to get into the container to make the modifications.

Thank you again @SimonWilkinson for the workaround.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

dragon2611 commented 3 years ago

Tp-link pushed an update to one of my plugs (the other one is in the draw) that re-enabled local access (According to the changelog) I'm not sure if you have to open a support case for them to do that or if they're doing it for everyone.

koobs commented 3 years ago

@dragon2611 Can you please include:

Note also: Kasa iOS app version 2.30.0 was released 31/03 with a recent review saying:

image

I haven't updated to this version yet to confirm.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

igiannakas commented 3 years ago

Plugs still don’t work with latest HA if they’ve been updated to the latest firmware from TP link.

JohnHof1275 commented 3 years ago

Having issues as well

bdraco commented 3 years ago

The TPLink integration will switch to using python-kasa next month.

https://github.com/python-kasa/python-kasa/pull/117 has gone a bit stale, but it does provide a path forward to support the new encryption protocols.

It needs a champion to finish the work who has one of the affected devices to test with.

miranml commented 3 years ago

I get this error once per day:

Logger: homeassistant.components.tplink.coordinator Source: helpers/update_coordinator.py:219 Integration: TP-Link Kasa Smart (documentation, issues) First occurred: October 27, 2021, 12:58:57 (3 occurrences) Last logged: October 27, 2021, 22:45:52

Error fetching 192.168.55.111 data: Unable to connect to the device: 192.168.55.111

davs2rt commented 2 years ago

Address Resolution Protocol (ARP) is how Ethernet converts an IP address to the MAC address that is used on the LAN. I discovered my HS103 does not respond to ARP queries, so Windows can't figure out where to try to send a packet, gives "Destination Host Unreachable" errors and just stops without sending anything out.

In Windows, adding an ARP entry is long and convoluted, must be run in an administrative command window, and yet doesn't solve the problem: e.g. netsh interface ipv4 add neighbors "Wi-Fi" 192.168.17.2 e8-48-b8-f5-12-34 (Replace the name of the interface, the IP address and MAC address with your local values) This only changes the error to "Request timed out". Wireshark-ing it, the ping is sent out now, but no response is received. I'm not sure what to make of that.

Adding a permanent ARP cache entry has been a useful work-around in Linux. There, with the ARP issue wallpapered over, Linux can successfully ping the plug. The command is simpler, too: sudo arp -v -s 192.168.17.2 e8:48:b8:f5:12:34

TP-Link support has been responsive in getting me through the "local only" setup described here, which does work if you're patient enough. When the instructions say "may take a few minutes", they really mean it. Don't interrupt it, thinking that it must be hung up.

I will lobby with them that the ARP issue is a network bug (not a "security feature") and should be fixed.

plug version info: (venv) davs2rt@heavymetal:~/code/kasa$ kasa --host kasa22 --plug sysinfo == System info == {'active_mode': 'none', 'alias': 'TP-LINK_Smart Plug_DD83', 'dev_name': 'Smart Wi-Fi Plug Mini', 'deviceId': '8006E70EFABC14B8E62408640F9AE5581E743039', 'err_code': 0, 'feature': 'TIM', 'hwId': 'B25CBC5351DD892EA69AB42199F59E41', 'hw_ver': '5.0', 'icon_hash': '', 'latitude_i': 0, 'led_off': 0, 'longitude_i': 0, 'mac': 'E8:48:B8:F5:DD:83', 'mic_type': 'IOT.SMARTPLUGSWITCH', 'model': 'HS103(US)', 'next_action': {'type': -1}, 'oemId': '211C91F3C6FA93568D818524FE170CEC', 'on_time': 1809, 'relay_state': 1, 'rssi': -32, 'status': 'new', 'sw_ver': '1.0.3 Build 201015 Rel.142523', 'updating': 0}

SimonWilkinson commented 2 years ago

I'm not longer actively working on this. I found the Kasa plugs with the new firmware to be somewhat unreliable - they would reboot at seemingly random times during the night, and when they rebooted they'd come back on with their output off. So, I've removed them from my setup in favour of Zigbee based plugs.

Happy to provide what help I can to get this moving along though.

jakemauer commented 2 years ago

@SimonWilkinson I’m interested to know what zigbee plugs or strips you’ve transitioned to using.

Robbo312 commented 2 years ago

@SimonWilkinson I’m interested to know what zigbee plugs or strips you’ve transitioned to using.

I went to a Smartthings Zigbee plugs as they have energy monitoring. I couldn’t find anything else in the UK. I use them with zigbee2mqtt via a conbee.

SimonWilkinson commented 2 years ago

For energy monitoring I’m using a mixture of the SmartThings Smart Plug and the Aurora AOne double socket (which requires installation) For just turning things on and off, the IKEA Tradfri plug works a charm.

jakemauer commented 2 years ago

I love the Tradfri sockets. Has anyone in this thread that is surely to be closed any moment now for off topic chatting found a good zigbee power strip with 3+ outlets?

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

MasterSmurf commented 2 years ago

I found the solution to integrate my HS100 in HA again. Local setup worked after resetting the Kasa HS100 and following this guide from TP-Link: https://www.tp-link.com/us/support/faq/2707/

Initially I setup a Cloud account, which caused the problems after updating HA.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

tjmoore commented 1 year ago

Just to add I've had my Kasa plugs and bulbs for a couple of years now and only just got round to installing HA. I've used the Kasa app (Android) in the past to update to latest firmware and checked again and it says they're the latest.

It detected them fine and have had no issues with them.

KL110B HW1.0- Firmware 1.8.11 KP105 HW1.0 - Firmware 1.0.7

(UK models possibly. Bought in UK at least)

Also, the note about the plugs rebooting at times. I had that early on, particular late and night and all the plugs would switch off and back on again. Since firmware updates I've not had that problem since. I'm pretty happy with them really. Power monitoring on the plugs would be nice but can't have everything. Not about to bin them over that.

A lot of this could be hardware specific though.

p.s. the workaround link is dead. Or maybe they think it's fixed? https://www.tp-link.com/us/support/faq/2707/

LordNex commented 1 year ago

Add me to the mix. I have both single and 3 way wall switches, plugs, and various bulb

LordNex commented 1 year ago

Just to add I've had my Kasa plugs and bulbs for a couple of years now and only just got round to installing HA. I've used the Kasa app (Android) in the past to update to latest firmware and checked again and it says they're the latest.

It detected them fine and have had no issues with them.

KL110B HW1.0- Firmware 1.8.11 KP105 HW1.0 - Firmware 1.0.7

(UK models possibly. Bought in UK at least)

Also, the note about the plugs rebooting at times. I had that early on, particular late and night and all the plugs would switch off and back on again. Since firmware updates I've not had that problem since. I'm pretty happy with them really. Power monitoring on the plugs would be nice but can't have everything. Not about to bin them over that.

A lot of this could be hardware specific though.

p.s. the workaround link is dead. Or maybe they think it's fixed? https://www.tp-link.com/us/support/faq/2707/

Try powerc

Just to add I've had my Kasa plugs and bulbs for a couple of years now and only just got round to installing HA. I've used the Kasa app (Android) in the past to update to latest firmware and checked again and it says they're the latest.

It detected them fine and have had no issues with them.

KL110B HW1.0- Firmware 1.8.11 KP105 HW1.0 - Firmware 1.0.7

(UK models possibly. Bought in UK at least)

Also, the note about the plugs rebooting at times. I had that early on, particular late and night and all the plugs would switch off and back on again. Since firmware updates I've not had that problem since. I'm pretty happy with them really. Power monitoring on the plugs would be nice but can't have everything. Not about to bin them over that.

A lot of this could be hardware specific though.

p.s. the workaround link is dead. Or maybe they think it's fixed? https://www.tp-link.com/us/support/faq/2707/

Try powercalc

https://github.com/bramstroker/homeassistant-powercalc

it will allow you to build “virtual sensors” based upon known factors regarding various brands of devices.

aporcupine commented 1 year ago

Archived FAQ

pfps commented 1 year ago

What's the status of Kasa devices in homeassistant? I bought some plugs and switches and I can control them directly using python-kasa by using their IP addresses. But discovery doesn't work so I have to add them one by one by their IP address. Is there another way of doing this?