Add a connect_single method to Discover to avoid the need for UDP#528
Add a connect_single method to Discover to avoid the need for UDP#528rytilahti merged 5 commits intopython-kasa:masterfrom
Conversation
rytilahti
left a comment
There was a problem hiding this comment.
Sounds like a good idea to me, however I'm wondering if this will make more difficult to integrate #509 and the potential support for tapo devices, as for those we don't have the information about the protocol available w/o performing a discovery call.
Codecov ReportAll modified lines are covered by tests ✅
📢 Thoughts on this report? Let us know!. |
I think we can work around that by adding params to This assumes that the discovered info for a device doesn't need to be discovered every time. Something like that would likely be a better design anyways since it would avoid the first query for the current protocol. I was looking for a solution that didn't involve a major change to HA to start with which could be iterated on in the future. |
|
Sounds like a good solution to me. I was wondering if we should convert the cli tool to use Ping @sdb9696 as this is relevant for the klap PR & for its future homeassistant support. |
|
added docstrings in 892f4c4 |
|
@bdraco @rytilahti https://github.com/python-kasa/python-kasa/blob/0.5.3/kasa/discover.py |
|
@sdb9696 We haven't switched HA to use The problem with the power strips needs to be fixed with it first before we can use it in home-assistant/core#103150 |
|
@bdraco Yes I know but we haven't switched python-kasa to use UDP yet either (well it seems it's been bumped to 0.5.4 today but the issue being reported was well before that). If you look at the https://github.com/python-kasa/python-kasa/blob/0.5.3/kasa/discover.py you can see it used the old discover_single method which was the same as the new connect single you're adding here. |
I follow now. So we are likely to have more problems now that its bumped 😢 |
|
Hopefully not because the UDP method only sends to the target ip, it doesn't broadcast to 255.255.255.255, so it shouldn't really slow things down. However, that said I noticed when looking at your PR that some users are using hostnames to add to HA and the UDP discover_single does not handle this properly. I created PR #539 to fix this and I'd suggest if we're happy with it we put it in a 0.5.5 and bump to that. |
This should equate to a significant reliability improvement for networks with poor wifi (edge of range)/udp.

needs #494
related issue home-assistant/core#99449
Can be tested with HA by doing