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.22k stars 30.58k forks source link

TP-Link Kasa plugs shows entities from wrong devices #97457

Closed bbordelon closed 1 year ago

bbordelon commented 1 year ago

The problem

I have two (EP-10) TP-Link plugs that are either showing the wrong number of devices in HA, and/or are showing entities from other devices in their configuration. Specifically, I have one plug called "Plug 1", and another called "Plug 3". In this list of TP-Link integration entries, Plug 1 shows that it has one device and two entities, whereas Plug 3 shows 2 devices and 2 entities: image

Following the link to see the 2 devices under Plug 3, it lists both Plug 1 and Plug 3: image

And I also notice that for Plug 1 it lists two integrations (i.e. TP-Link Kasa Smart is listed twice). Back to the entries list, if I follow the link to the 1 device under Plug 1, it lists the TP-Link Kasa Smart integration twice here as well: image

I have a nearly similar issue with two (EP-40) outdoor plugs having their devices/entities intermingled, but I suspect it might be the same root cause.

I enabled debug logging but could not find any errors related to these devices.

What version of Home Assistant Core has the issue?

core-2023.7.3

What was the last working version of Home Assistant Core?

No response

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @rytilahti, @thegardenmonkey, mind taking a look at this issue as it has been labeled with an integration (tplink) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tplink` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tplink` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


tplink documentation tplink source (message by IssueLinks)

bdraco commented 1 year ago

This can happen if a device switches ip addresses to the same one a previous device had after it's already setup and running.

There needs to be code to reject talking to the device if the MAC address doesn't match the config entry

We had the same problem in flux_led so the code could likely be borrowed from there. LIFX also currently has this problem. It's a rare issue but almost every integration has this problem

tggman commented 1 year ago

Now that you mention it... I too apparently have the same issue with my TP Link Kasa plugs. I used the word apparently because I didn't notice until it was pointed out by this issue. This problem is probably more prevalent than one might assume but just goes unnoticed. I used to assign static IP addresses to these plugs as well as my LIFX bulbs (which as @bdraco mentioned, have the same issue). If you're looking for a quick fix/ containment action, assign each plug a static IP address in your router. To fix the issue in Home Assistant, delete the the offending device (s) from HA, restart and re-add them when discovered.

bdraco commented 1 year ago

Fix will be in 2023.9.x

The fix will only prevent the problem from happening again. You'll have to remove all previously affected devices and readd them to fix the cross-linkage, but the problem should not reoccur after 2023.9.x