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 switches went "unavailable" #45943

Closed
asnandrey opened this issue Feb 4, 2021 · 40 comments
Closed

TP-Link Kasa switches went "unavailable" #45943

asnandrey opened this issue Feb 4, 2021 · 40 comments

Comments

@asnandrey
Copy link

The problem

After upgrading to 2021.02, all my 50 switches are "unavailable" now!

I tried reloading the integration and also restarted home assistant and also core, but it did not work.

Also, I'm unable to reload the integration now. It says "reload will happen after restart".

What is version of Home Assistant Core has the issue?

2021.2.0

What was the last working version of Home Assistant Core?

2021.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

TP-Link Kasa Smart

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tplink/

Example YAML snippet

# Put your YAML below this line

Anything in the logs that might be useful for us?

# Put your logs below this line
@Spartan-II-117
Copy link
Contributor

Does anything show up on the logs relating to kasa?

@asnandrey
Copy link
Author

asnandrey commented Feb 4, 2021 via email

@asnandrey
Copy link
Author

asnandrey commented Feb 4, 2021 via email

@asnandrey
Copy link
Author

Hi @rytilahti , any updates on this one? None of my automations are working in my home as all my switches are TP-Link!

@asnandrey
Copy link
Author

asnandrey commented Feb 5, 2021

I removed the TP-Link Kasa integration, restarted home-assistant and added the integration again. But, it gives below error:
image
But, I'm able to control the switches and lights via Kasa app. It is only after home-assistant upgrade that these are not working.

@asnandrey
Copy link
Author

asnandrey commented Feb 6, 2021

Hello, any updates? TP-Link integration is not finding any devices on my network after the upgrade.

@frenck
Copy link
Member

frenck commented Feb 7, 2021

I am not sure why I was tagged? @asnandrey

@asnandrey
Copy link
Author

asnandrey commented Feb 7, 2021 via email

@frenck
Copy link
Member

frenck commented Feb 7, 2021

Please don't randomly pull people into conversations. It is considered impolite and not how this works.

There are 1.2K issues open and we have a lot of integrations. Home Assistant is an open source project, additions and fixes are relying on contributions people make.

I have no idea how this specific integration works. I don't use it. Thus pulling me in here, is rather useless (and not asked for).

Please, feel free to contribute a fix if you think it is broken.

Thanks!

@rytilahti
Copy link
Member

You may need to enable debug logging for pyHS100 and homeassistant.components.tplink to get more detailed debug logging, and capture log directly from the startup.

Now, if downgrading homeassistant makes them work again, @TheGardenMonkey may know what has changed between those versions.

@TheGardenMonkey
Copy link
Contributor

TheGardenMonkey commented Feb 7, 2021

There are no changes between those versions (no changes in months outside of a version bump on pyHS100 in Nov). I agree you should enable debug logging on those two components. You can also try running pyhs100 at the command line to confirm that it is discovering devices.

Also just want to confirm, when you say you rebooted, did you restart the device or just HA?

Just in case this is how you would enable the logging:

logger:
  default: warning
  logs:
      homeassistant.components.tplink: debug
      pyHS100: debug

@asnandrey
Copy link
Author

Thank you Angelo for sending the snippet. Please see log below.

2021-02-07 16:53:59 DEBUG (SyncWorker_8) [pyHS100.discover] Sending discovery to 255.255.255.255:9999
2021-02-07 16:53:59 DEBUG (SyncWorker_8) [pyHS100.discover] Waiting 3 seconds for responses...
2021-02-07 16:54:02 DEBUG (SyncWorker_8) [pyHS100.discover] Got socket timeout, which is okay.

@rytilahti
Copy link
Member

rytilahti commented Feb 7, 2021

Do you have multiple network interfaces / is that computer connected to multiple networks? That log snippet indicates that there were no responses from kasa devices, but as it's targeting 255.255.255.255 it may will miss devices that are not connected to the default network adapter.

@asnandrey
Copy link
Author

I run it on a NUC which is hard wired to the router with no wifi setup. It has been working good until I upgraded to the recent version.

@asnandrey
Copy link
Author

I found out a few hours ago that my Harmony integration is also not working. I believe something related to network discovery chagned. (However, all my Tasmota devices are working fine.)

@asnandrey
Copy link
Author

None of my switches are working. Can you please suggest some steps to troubleshoot? They were working good until the upgrade. I don't blame the upgrade, but something else may have happened that got triggered when the update took place. So, please help troubleshoot.

@Spartan-II-117
Copy link
Contributor

I would recommend downgrading back to the last working version.

@asnandrey
Copy link
Author

Thank you. I did downgrade ha today but my tplink integration is still not working. I then also tried today's release and still not working. I realized later that my Harmony hub is also "unavailable". I may end up recreating my machine (Intel NUC) if no solution until coming weekend! Tired spending hours trying to fix this.

@Seph29
Copy link

Seph29 commented Feb 9, 2021

Hello, same problem here: TP-Link integration no longer works
I tried to reinstall but it doesn't work.

OS Version: Home Assistant OS 5.11
Home Assistant Core: 2021.2.2
Running on proxmox VM

brave_fYC0IGsUV2

###LOG###

2021-02-09 17:59:13 DEBUG (SyncWorker_25) [pyHS100.discover] Sending discovery to 255.255.255.255:9999
2021-02-09 17:59:13 DEBUG (SyncWorker_25) [pyHS100.discover] Waiting 3 seconds for responses...
2021-02-09 17:59:16 DEBUG (SyncWorker_25) [pyHS100.discover] Got socket timeout, which is okay.

@toddejohnson
Copy link
Contributor

toddejohnson commented Feb 14, 2021

I also have this problem. I've been able to work around it with manual config as described in documentation instead of automatic discovery in my yaml. Stinks but has things working for now. Was odd as 5 devices would discover. The other 40 I've had to manually configure.

@rytilahti
Copy link
Member

Some devices (or even versions) are not responding to discoveries, potentially related to python-kasa/python-kasa#105 .

Was the discovery ever working for those other devices? What devices are they? I have personally seen that some light bulbs are not always responding to the discovery in my personal setup.

@toddejohnson
Copy link
Contributor

The below was 100% auto discover until this mornings reload after updating to 2021.2.3:

  • KL100
  • HS100
  • HS103
  • HS105
  • HS200
  • LB100
  • KP400

The manual configuration helped WAF getting things back online(If it helps others):

# Example configuration.yaml entry with manually specified addresses
tplink:
  light:
    - host: 192.168.200.1
    - host: 192.168.200.2
  switch:
    - host: 192.168.200.3
    - host: 192.168.200.4
  dimmer:
    - host: 192.168.200.5
    - host: 192.168.200.6
  strip:
    - host: 192.168.200.7
    - host: 192.168.200.8

I'd prefer to not chase IP addresses and let auto discover work it's magic but WAF is key!

@rytilahti ideas on what I should try? I have debug but only discover 5/32 devices

@rytilahti
Copy link
Member

Does downgrading make them again discoverable? Has there been firmware updates for those devices that are not anymore discovered? Also, #46142 might be related, but such problems are generally hard to debug.

You could try to execute pyhs100 discover or kasa discover (https://github.com/python-kasa/python-kasa) in console to test out the discovery without involving homeassistant.

@asnandrey
Copy link
Author

  1. Downgrading does not make them discoverable again. I tested last week.
  2. They were discoverable earlier.
  3. I have 50 TP-Link Kasa switches throughout my home and about 25 Tasmota ones. All 50 Kasa switches are "unavailable" and do not work. Tasmota and other devices are working fine.
  4. However, after the upgrade I observed that sometimes my Harmony hub is also "unavailable" but works mostly.
  5. Kasa mobile app works fine and controls all 50 devices.
  6. I've rebooted my network twice and also tried by shutting down power to my entire home for 3 minutes from the breaker to power off all devices. None of these steps helped.
  7. Tried to test per your comment above but I can't find "Kasa" executable in the download, hence unable to test.

@toddejohnson
Copy link
Contributor

Downgrading back to 2021.2.2 didn't do the trick. The problem still exists. I wonder if a critical library was updated as part of the 2021.2.3 container(>=x.x)?

I'm a bit behind and don't have ssh configured just yet to dig in. I do have a snapshot from the 3rd although that was 2021.1.5. Not sure I'm excited to revert to that to see if this goes away. I wonder would this pull back the old libraries too?

@rytilahti
Copy link
Member

1. Downgrading does not make them discoverable again. I tested last week.

2. They were discoverable earlier.

These point that either something non-related to tplink changed either in your network or in homeassistant. The last change to the underlying backend library was in 2020-11-25.

Have you upgraded the firmware of those devices lately?

4. However, after the upgrade I observed that sometimes my Harmony hub is also "unavailable" but works mostly.

This could indicate, that it's something related to homeassistant core changes. There has been some changes to the discovery (related to dhcp discovery, which may be related).

5. Kasa mobile app works fine and controls all 50 devices.

The mobile app may be controlling the devices over the internet?

7. Tried to test per your comment above but I can't find "Kasa" executable in the download, hence unable to test.

pyhs100 is the one from the library used by current homeassistant integration. kasa (note, lowercased) is the tool for the successor of pyhs100 library, which is not yet used by homeassistant (but can be installed for testing with pip install python-kasa --pre).

@rytilahti
Copy link
Member

Downgrading back to 2021.2.2 didn't do the trick. The problem still exists. I wonder if a critical library was updated as part of the 2021.2.3 container(>=x.x)?

The library used for communicating with the devices was last updated in 2020-11-25 to fix a compatibility issue with HS220 devices. If something has changed, it is either in the integration itself (ping @TheGardenMonkey), or in homeassistant core functionalities, which may be the case as @asnandrey pointed out problems with harmony, too.

@asnandrey
Copy link
Author

I will try to create a fresh HA environment to test this out. My setup is still broken and none of my TP-Link switches are working via HA. (They work fine from Kasa app.)

Anybody else having similar issues?

@asnandrey
Copy link
Author

So, I setup fresh network at home and reset every device about 3-4 weeks ago. All my TP-Link switches came back to HA. Note: these switches were always available in the Kasa app. So, it seems something went wrong when HA was upgraded.

Here is the interesting part...I upgraded HA today to 2021.4 and same thing happened again. My TP Link Switches (not all, but about 50% of them) are unavailable again. They still work via the Kasa app.

So, this confirms that something definitely happens when HA is upgraded. Not sure what....I have rebooted my HA (on Intel NUC) and restarted HA few times...Also, reloaded the integration a few times, tried restarting unavailable switches etc...but nothing worked.

The switches were not rebooted, nor the network was reset, but only HA was upgraded that caused this!

Is it possible to use the same method of detecting and controlling switches that is used by the Kasa app?

@asnandrey
Copy link
Author

I factory-reset my home network this morning and all my TP-Link devices are back again. Can you help me on how to debug this issue? My devices only go missing when I upgrade homeassistant! It seems homeassistant does something to the network due to which it can't see TP Link devices.

@asnandrey
Copy link
Author

I also noticed that my Tasmota devices keep working via HA, but they become "unreachable" via a browser to update their firmware.

I then reset my Unifi network again and all goes back to normal. I can control TP link switches via HA and can reach Tasmota devices via browser.

Then I apply 2021.4.4 today and all hell breaks loose again. Now my TP link switches are not reachable via HA and also my Tasmota devices are not reachable via my computer browser!

"Reloading" the integration does not bring my TP-Link switches back.

@ghost
Copy link

ghost commented Apr 29, 2021

I had the same problem after upgrading my host OS, turned out to be a firewall issue blocking discovery.

@asnandrey
Copy link
Author

I had the same problem after upgrading my host OS, turned out to be a firewall issue blocking discovery.

Can you provide details on how you found and fixed it? I can try the same at my end too.

Also, my firewall settings were same before and after upgrade. I saw that this happened every time I upgraded HA (and not just the OS) since 2021.02. (Resetting my entire network fixes it; and I've already done it 3-4 times already!)

I will watch it again on coming Wed if this recurs after the upgrade.

@teewhey
Copy link

teewhey commented Jun 15, 2021

I had the same issue for LB130. I tried removing the integration and added it back. The problematic device is not even detected now although i still can see and control it from Kasa app. Any idea?

@Snuupy
Copy link

Snuupy commented Jun 18, 2021

Did an upgrade from 2021.6.2 to 2021.6.5 and ran into the same issue. Downgrading back to 2021.6.2 did not fix this issue, my switches are still unavailable.

@asnandrey
Copy link
Author

I don't have this issue anymore. I believe there is some network setting that gets messed up with the upgrade. I had to factory reset my wireless network 4 times and I believe I unknowingly altered some setting during the 4th reset that likely "fixed" the issue. I believe the home assistant upgrade process sends some network packets that cause a kind of deadlock in the network.

Following integrations were affected by this issue in my case:

  1. TP-Link Switches (worked fine via Kasa app but unavailable in HA)
  2. Harmony Hub (worked fine via Harmony app, but unavailable via HA)
    --next one is reverse case
  3. Tasmota switches (worked fine via HA but I was unable to navigate to the individual Tasmota URLs from any pc/browser on my network), nor would they list in Tasmota Device Manager!

I'm glad that I'm not having this inconvenience anymore! Hoping yours gets resolved too.

@github-actions
Copy link

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.

@asnandrey
Copy link
Author

All switches went "unavailable" after today's release 2021.10.0!

https://community.home-assistant.io/t/2021-10-0-z-wave-s2-support-tuya-secure-esphome-and-400-new-icons/344457/63

@rytilahti
Copy link
Member

@asnandrey sorry to hear that :-( could you please create a new issue report and add as many details as possible? The integration was ported to use a completely reworked code base which doesn't share many details to make it fruitful to reopen this issue with all its history.

@asnandrey
Copy link
Author

Sure...will open a new issue soon.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 5, 2021
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

9 participants