Closed kochinc closed 5 years ago
Looks fine to me, I have only one question: do you think it's better to have an address instead of an interface name for this?
Not sure whether this was directed at me, or @kochinc, my general preference is to deal with interfaces, rather than IP addresses - network ranges change, interfaces generally stay the same. If go for interfaces, however, how do we address the 'broadcast' since broadcast should send to all interfaces? Perhaps a interface='all'
keyword argument?
Either way it's fine for me. At first I wanted to add an interface parameter. After inspected the code, I realized it's very simple to just include a broadcast target address parameter. That solved my issue with TP-Link device discovery on Home Assistant.
Would it be possible to get a release with this merged so that we can get Home Assistant working with Kasa on different subnets before python-kasa is integrated?
Sometimes it's useful to be able to specify the broadcast address for discovery. On a host with multiple network interfaces, when a discovery message is sent to 255.255.255.255:9999, the routing table decides which interface it is routed to. By specifying broadcast address, e.g. 192.168.xxx.255, the discovery message can be directed to a particular subnet only.
The modification to discover.py is very limited and shouldn't affect existing programs using the library. The cli.py is changed to include a --target option for specifying broadcast address.