-
-
Notifications
You must be signed in to change notification settings - Fork 221
Trying to get 'kasa discovery' to work across subnets -- both from the CLI and in Home Assistant TP-Link Integration #1431
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
Comments
Note for both
But again '--host |
|
Just to make sure I am following as I am a newbie here, I assume you mean broadcast as 192.168.x.255 and 255.255.255.255 are broadcast addresses, not multicast. Regarding #3, my HA device is a RPi for now so only one nic :( Also, one related question... |
Yes apologies I meant broadcast. The HA tplink integration handles ip changes via 20002/9999 discovery and dhcp discovery. Both of these won't work across subnets by default, so unless you're able to setup some sort of relay 😬 assigning static ips or perhaps using dns names is the way to go. |
It's a shame that there is no good solution for discovery across subnets as it is increasingly common and recommended to run your IoT devices on a separate subnet given that so many devices are made in China, require cloud access, and have dubious security and/or privacy guarantees. At the same HA is "trusted" and should run on your primary network so it has access to necessary resources. In particular, I wish there were simpler ways to selectively relay broadcast messages across subnets -- but at least with my dd-wrt router, it seems like standard iptables rules don't work for broadcast. |
OK, I finally go it to work by compiling and installing udp-broadcast-relay on my dd-wrt router.
And added the following iptables rules on the router:
Note: where:
Note that udp-broadcast-relay is a small, easy to compile program. I just had to run 'make' to get it to compile under dd-wrt (where I have gcc installed via entware) |
@rytilahti if you want, you might want to add or reference this solution to the "bug report" that I filed but is now closed under homeassistant/core so I can't add to it. TP-LINK: Can't auto-discover devices on a separate IOT subnet #132654 I also added the solution to the parallel community discussion Auto-Discovery for TP-Link/Kasa devices on separate IOT network |
@puterboy glad that you got it working for your setup. I added a brief comment to link the issues 👍 |
I have my home server as well as my HA device on my primary 192.168.1.x network.
My kasa devices are on my IOT 192.168.100.x subnet.
I would would like to discover the Kasa devices on the IOT subnet (br1, vlan3) from my primary 192.168.1.x subnet (br0) -- whether via HA or via the CLI
kasa discover
In the HA TP-Link integration, I can manually discover individual devices across subnets if I give the host IP -- but not if I leave the host blank and seek to "auto-discover".
Similarly, direct host addressing using CLI
kasa --target 192.168.100.144 discover
works (where 192.168.100.144 is a Kasa device on my IOT network). Though strangelykasa --host 192.168.100.144 discover
returns after a second but without any discovery data suggesting that it connects but somehow returns no data.In contrast, "auto discovery" using
kasa discover' or even 'kasa --target 192.168.100.255
times out after ten seconds, returning:I assume that the problem is that "auto" discovery is using broadcast (255.255.255.255) on ports 9999 and 20002 -- but of course broadcast messages are not forwarded across subnets, i.e, from 192.168.1.x (br0) to 192.168.100.x (br1) whereas specifying a specific host IP just sends the discovery packet directly to the host IP address on ports 9999 and 2002.
Indeed tcpdump confirms the broadcast originating on br0:
but
tcpdump -i br1 \( udp port 9999 or \udp port 20002 \)
doesn't show any traffic.So to summarize, my questions are:
kasa --target 192.168.100.144 discover
succeed while,kasa --host 192.168.100.144 discover
fails?kasa --target 192.168.100.255 discover
working where the target is on a different subnet?This is particularly important to me in HA since I would rather not have to type in each IP individually - plus presumably the IP address can change.
Note I am using version python-kasa-0.8.1
The text was updated successfully, but these errors were encountered: