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.24k stars 30.59k forks source link

TP Link switches unavailable #35137

Closed mattyteds closed 4 years ago

mattyteds commented 4 years ago

The problem

Updated to 0.109.3 and all (2) my TP - Link switches became unavailable. Removed the integration and tried to re-add, "Aborted. No TP-Link devices found on the network". Restarted and tried to re-add, integration added but none of my switches appear even after multiple restarts. Switches appear in TP Link app (Kasa) and are functional. Switches have latest firmware and I have power cycled them. I'm going to reset one soon to test.

UPDATE: I removed the integration again and now no matter what I cannot re-add because it cannot find any switches on the network.

I tried to manually setup one via the switches.yaml:

- platform: tplink
  switch:
    - host: 192.168.1.83

But I get the error: "The tplink platform for the switch integration does not support platform setup. Please remove it from your config."

Environment

Problem-relevant configuration.yaml

Traceback/Error logs

Additional information

lilbuh commented 4 years ago

i have 3 HS100 tp link smart plug no problem here

mattyteds commented 4 years ago

Mine are HS105 I removed and readded integration and now no matter what it won't add indicating no switches are found on the network.

probot-home-assistant[bot] commented 4 years ago

Hey there @rytilahti, mind taking a look at this issue as its been labeled with a integration (tplink) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

mattyteds commented 4 years ago

After resetting and reconfiguring the switches I was able to re-add the integration and they both are available in Home Assistant. Not sure why the app could see them but Home Assistant could not.

mattyteds commented 4 years ago

Randomly when I reboot the system home assistant is running on I have to reset and re-add my switches to the Kasa app before home assistant will see them again. I re-added one and left the other. After about 2 hours of troubleshooting the one I left alone eventually appeared again. The app sees them the whole time and can control them.

Update: Upon restarting home assistant the one I left alone became unavailable again.

caseyjhol commented 4 years ago

Related: https://community.home-assistant.io/t/tp-link-switches-going-unavailable/62286

stowers95120 commented 4 years ago

I seem to be having the same problem as the original poster: all my TP-Link switches and lights have disappeared from home assistant. I have tried many things: deleting and re-adding the TP-Link integration, deleting all of the switches from TP-Link's Kasa app, completely re-imaging home assistant, etc, but still the TP-Link integration says that it can't discover any devices on my network and then aborts.

Anybody got any ideas what I can try?

jimmyeao commented 4 years ago

I have the same issue, some devices discovered, some are not. I can't even pin it to a specific model, A mix of HS100/110 plugs

jimmyeao commented 4 years ago

image Unifi integration sees them, but the TPLINK one doesn't pick them all up

mandad commented 4 years ago

I'm also seeing this issue. Mostly HS105 plugs, one outdoor KP400. After a few add/removes of the integration, I got all the indoor plugs detected but now (after some time) all but one are showing unavailable and there are communications errors in the log. "Could not read state for 192.168.1.194: Communication error"

trentjw commented 4 years ago

this intergration for all intense and purposes has been abandoned the guy working on it gotten as far as a unreleased PR and nothing more so unless somebody that knows how to code picks it up, it is what it is

caseyjhol commented 4 years ago

https://github.com/home-assistant/core/pull/30719 looks like the PR to follow.

docfactory37 commented 4 years ago

i have a HS100 and just set up Home Assistant 0.111.4 in Docker and im not able to use the TP-link Kasa integration ans it dose not find the devise and tryed add manualy and still not working.

rytilahti commented 4 years ago

When using inside docker, you need to make sure that your network configuration is passing the broadcast requests properly. I'm afraid I don't know exactly how to make that happen, but it is definitely doable.

But when it is not working even when configured manually, it seems that for a reason or another it cannot communicate with the device. Firewall issues?

docfactory37 commented 4 years ago

When using inside docker, you need to make sure that your network configuration is passing the broadcast requests properly. I'm afraid I don't know exactly how to make that happen, but it is definitely doable.

But when it is not working even when configured manually, it seems that for a reason or another it cannot communicate with the device. Firewall issues?

i have been able to set it up manual be the config.yam and auto discovery dose not work

brettjenkins commented 4 years ago

My tplink devices are so unreliable. I'd love for a fix for this

trentjw commented 4 years ago

My tplink devices are so unreliable. I'd love for a fix for this

so would everybody else that has these devices unfortunately the guy that worked on this integration no longer has the time so unless someone that knows how to code steps up this is what we get, I would recommend looking into alternate methods, lucky my house is all Z wave which works as it should, I am only using a few of the TPLink in my RV so I don't have much invested in this so I when I find a better solution I am jumping from this mess

rytilahti commented 4 years ago

I'm still working on it (just added support for bulb transitions last week after procuring a color bulb thanks to a donation), but I have also other things to do nor do I have all possible device combinations at home... Anyway, any help on development and testing is greatly appreciated, so feel free to contribute.

The linked PR in its current state should be working even when there are exceptions related to GeneratorExit. From the features, the emeter information on HS300 is still missing (https://github.com/python-kasa/python-kasa/issues/64).

trentjw commented 4 years ago

I'm still working on it (just added support for bulb transitions last week after procuring a color bulb thanks to a donation), but I have also other things to do nor do I have all possible device combinations at home... Anyway, any help on development and testing is greatly appreciated, so feel free to contribute.

The linked PR in its current state should be working even when there are exceptions related to GeneratorExit. From the features, the emeter information on HS300 is still missing (python-kasa/python-kasa#64).

I am on the latest HA version and still get the unnamed device error on HS300 that has been ongoing since Nov 2019 typically 2 of the plugs show up as unnamed device and it is random of which plug, the emeter works fine, as I stated I know you are busy and don't really have time for this intergration anymore life happens, and if I had any clue on how to build a intergration I would but would not even know where to start so it is what it is

rytilahti commented 4 years ago

Yes, the PR has not been merged and is still WIP, so it's hardly unexpected that the issues are still there. The most problematic part is the HS300 with emeter support requiring separate queries. Making this working properly is not as simple as I thought originally, especially without a test device at hand.

One approach would be to simply remove the emeter support from HS300 which would eradicate the one last bigger issue immediately, the other one is having some more patience. @Sidlinger (https://github.com/home-assistant/core/issues/28912#issuecomment-651475019) has offered to contribute to the latter approach by making a device available for me to use for development.

trentjw commented 4 years ago

Something that doesn't make sense is the kasa app works like it should it polls the switches to get Information from them what are you doing different to make it refuse connection?

trentjw commented 4 years ago

Not sure if this helps but the integration for Wi-Fi stuff that works with ewelink app made by alexx uses a json file to cache all the devices that and refers that file instead of hitting the devices so hard for requests maybe look at that integration see if that a possible path to help with this intergation

AkshatShah1 commented 4 years ago

I keep running into this same issue and I just switched to connecting them to the SmartThings app and using that to connect to Home Assistant. It's not local but at least it works!

simontb commented 4 years ago

Something that doesn't make sense is the kasa app works like it should it polls the switches to get Information from them what are you doing different to make it refuse connection?

The same behavior for me. Interestingly in the past it was the other way around: HA always worked like a charm and Kasa was unreliable. I also use them only locally.

trentjw commented 4 years ago

I keep running into this same issue and I just switched to connecting them to the SmartThings app and using that to connect to Home Assistant. It's not local but at least it works!

Do you have the smart things hub as well or are you just using the app on a regular router

notalecdusheck commented 4 years ago

Having this exact issue... not using smart things. Devices were working fine for months and randomly became "unavailable". Removing the integration and readding it caused a "No TP-Link devices found on the network." message.

All switches have DHCP reservations (static IPs) and have not had any network drops.

AkshatShah1 commented 4 years ago

Mine was working fine for a few weeks after I setup my first Home Assistant instance and then it started to be really spotty to the point where the state bar was just a pattern of red and gray. When I looked at my router, I noticed the plug changed IP addresses so I assigned static IPs to the plug and it worked for a few days before the same thing started happening.

pwl-consult commented 4 years ago

I'm also having more problems now than I ever have. It seems to find them randomly if I restart home assistant so I've taken to restarting over and over until I get most of them back and then living without whichever ones don't come back. Google assistant with a direct Kasa integration can still control them thankfully, but any of my node-red integrations fail - hope this is fixed soon! image

AkshatShah1 commented 4 years ago

This is exactly what I had going on. If you want a quick fix, I suggest linking Kasa with Smartthings and adding Smartthings to Home Assistant.

qcasey commented 4 years ago

Had the same issue, reserving static IPs in my router and defining those IPs in the home assistant yaml config fixed this for me.

Using the UI Kasa integration does not work

AlecDusheck commented 4 years ago

I can confirm that the Home Assistant -> SmartThings -> Kasa setup works without issue. I will be using this until the Kasa integration is fixed

Sidlinger commented 4 years ago

Dear rytilahti, I have not forgotten. A few network setbacks and some COVID-19 distractions but I plan to have public-key ssh access set up for you soon. Your dedicated network with the HS300 is still set up. Thank you for your patience. -Bruce

rytilahti commented 4 years ago

Hi @Sidlinger, no worries! We are all volunteers here, life happens. I hope you received my discord messages, feel free to ping me whenever you are ready :-)

Bilhix commented 4 years ago

Similar issue here, swapped router kept same SSID and WPA2, plug working in Kesa app / Alexa etc. Current integration now unable to find any plugs. Any news on when the PR will be committed to HA ?

mkarnebeek commented 4 years ago

Any news on when the PR will be committed to HA?

I'm interested in this also. The current implementation requires me to reboot HA multiple times before all of my HS110's are picked up. This is starting to become unworkable.

rytilahti commented 4 years ago

@vangorra would you like to take over the maintainership of the tplink integration (and merge whichever PRs you deem necessary)?

The current ongoing transition period obviously very nonoptimal and is making everyone around unhappy; on one hand I don't want to throw away the work done in python-kasa that will be useful for many users, but on the other hand forcibly pushing that PR to be a part of a release before everything is definitely done will make at least the HS300 users using the emeter data very unhappy.

As there is no real deadline when the issue with HS300 gets properly solved, I have been contemplating on the idea of turning that PR into a custom component (named tplink_ng or something). This would allow integrating your proposed changes into the core integration to help people with all these issues, while also enabling easier installation of the "upcoming" version for those those who prefer to do so.

I'm afraid I should have already proposed this change of maintainership long ago, but better now then never? What do you think?

mattyteds commented 4 years ago

As the original creator of this issue I just wanna say I haven't had any issues with my switches for months. Sorry to see other people are having issues.

trentjw commented 4 years ago

Well as a previous user it never worked right, it taught me to stay with zwave luckily only my rv has three devices that uses this intergation

hyacin75 commented 4 years ago

Static addressing and configuration worked perfect for me, thanks to those who suggested that. They mapped right back up to their previously discovered entities, and thus all their automations and everything too.

rytilahti commented 4 years ago

I have seen that some devices are more responsive for discovery, but I have no idea what could be the reason. My HS110 gets always discovered correctly, but sometimes KL130 and KP303 are not responding to the discovery requests.

mikesalz commented 4 years ago

I chimed in on another thread before finding this one. I am also encountering the unnamed_device issue on a new HS300, even with discovery off and static IPs. I've only had it a day, and am considering returning it. @rytilahti @vangorra Do you think that this is something that might be resolved soon, or should I just get rid of this thing? :) Thanks in advance for your help!!

bi99sy commented 4 years ago

I have issue with TP-Link HS100 after upgrading to 0.114.4, prior to 0.114.4 I would get the occasional HS100 unavailable which would be resolved with a restart, upgraded OS from 4.11 to 4.13 and then upgrade from 0.113.3 to 0.114.4 and all 3 HS100 are unavailable (work in the KASA app), removed the integration and added to the switch.yaml which worked perfectly for years even before the integration, but the switch.yaml configuration no longer works either. Switch entities are not added or discovered in the entities. Rolled back to 0.113.3 everything works perfectly again, so there must be an issue with 0.114 somewhere.

Toffi32 commented 4 years ago

Had problems with HS110 for a while and digged a little bit deeper now. HS110 is working fine e.g. via Alexa, but was unavailable in HA. Tried to delete the entity, integrations etc. and start over fresh, but integration didn´t find the device. Only gives "No TP-Link devices found on the network."

Home Assistant 0.115.2

pmd5700 commented 4 years ago

Any update on this? Just today all my switches/bulbs have become unavailable. They were rock solid for months before this. Was on 0.115.5 and they weren't working. Upgrade to 0.115.6 - still not working.

turbouk2312 commented 4 years ago

I have an odd issue, after a restart all of my switches are picked up except one, always the same one, the most recent hs110 I added. It appears in Kada fine so it's not an IP/connection issue. If I reload the tp link integration within HA it gets picked up ok and appears as it should. Seems strange.

pmd5700 commented 4 years ago

I get the following error on startup each time:

Logger: homeassistant.config_entries
Source: components/tplink/common.py:122
First occurred: 11:26:19 AM (1 occurrences)
Last logged: 11:26:19 AM

Error setting up entry TP-Link Smart Home for tplink
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pyHS100/smartdevice.py", line 115, in _query_helper
    response = self.protocol.query(
  File "/usr/local/lib/python3.8/site-packages/pyHS100/protocol.py", line 60, in query
    length = struct.unpack(">I", chunk[0:4])[0]
struct.error: unpack requires a buffer of 4 bytes

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 228, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/usr/src/homeassistant/homeassistant/components/tplink/__init__.py", line 82, in async_setup_entry
    static_devices = get_static_devices(config_data)
  File "/usr/src/homeassistant/homeassistant/components/tplink/common.py", line 122, in get_static_devices
    for plug in SmartStrip(host).plugs.values():
  File "/usr/local/lib/python3.8/site-packages/pyHS100/smartstrip.py", line 43, in __init__
    children = self.sys_info["children"]
  File "/usr/local/lib/python3.8/site-packages/pyHS100/smartdevice.py", line 186, in sys_info
    return defaultdict(lambda: None, self.get_sysinfo())
  File "/usr/local/lib/python3.8/site-packages/pyHS100/smartdevice.py", line 196, in get_sysinfo
    return self._query_helper("system", "get_sysinfo")
  File "/usr/local/lib/python3.8/site-packages/pyHS100/smartdevice.py", line 120, in _query_helper
    raise SmartDeviceException('Communication error') from ex
pyHS100.smartdevice.SmartDeviceException: Communication error
MarkHofmann11 commented 4 years ago

You can run @TheGardenMonkey changes as a custom component for the time being to fix all the unavailable issues. I have been assisting with the testing and have been using a modified tplink component for almost a year with no issues.
https://github.com/home-assistant/core/pull/39762

I had also added this pull request to fix the issues which was never approved. https://github.com/home-assistant/core/pull/35460

dilzeem commented 4 years ago

@MarkHofmann11 thanks for pointing this out. I didn't realize progress was made here.

I using that pull request in my docker container.

Seems like I still can't get tp-link to work. Any advice would be appreciated.

MarkHofmann11 commented 4 years ago

The attached are the modified tplink component files I'm using right now with no issues. I run HA on Windows, so the directory structure is a bit different so not exactly sure how you would install these on your platform. You can also unzip these are make a tplink directory under custom_components and run it that way.

TPlink.zip

dilzeem commented 4 years ago

Thanks for that. I will try this over the weekend, and see how I go.