Allow searching for bridges on more than one network - #82
Merged
Conversation
The discovery request went to the limited broadcast address, which the operating system sends out over a single interface, the one that the routing table selects. A bridge that lives behind another interface never sees the request. This is why discovery fails on machines with virtual adapters next to the real network card, but it is not Windows specific, the same happens on Linux with multiple interfaces. Accept the broadcast address of every network that should be searched instead. Home Assistant knows them through network.async_get_ipv4_broadcast_addresses(), and the cli learned a --broadcast option. Without them, we broadcast like we always did. Bridges that answer more than one of our requests are only reported once, and responses that arrive after the discovery finished are ignored, they used to raise an InvalidStateError on the completed future.
This was referenced Aug 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The discovery request went to the limited broadcast address (
<broadcast>=255.255.255.255). That is not sent out over every interface: the operating system does a routing lookup and picks exactly one, so a bridge behind another interface never sees the request.This is what breaks discovery in #61, where VirtualBox, WSL and a few disconnected WiFi adapters compete with the real network card. It is not Windows specific though, and
ProactorEventLoophas nothing to do with it: a Linux machine with multiple interfaces fails in exactly the same way, which is also why--hosthas always worked for these users.discover_bridges()now accepts the broadcast address of every network that should be searched:Sending to a subnet directed broadcast address makes the routing work in our favour:
192.168.1.255is routed over the interface that owns that subnet, so no interface binding or address enumeration is needed here. Home Assistant already knows these addresses throughnetwork.async_get_ipv4_broadcast_addresses(), which follows the adapters the user enabled, so the integration can pass them without pulling in a dependency likenetifaces(as #62 proposed) orifaddr. The cli learned a--broadcastoption that can be repeated.Nothing changes when no addresses are passed, we broadcast like we always did.
Two smaller things in the same file:
set_result()on the completed future (InvalidStateError) and mutate the list that was already handed to the caller.Tested against a real bridge:
--broadcast 192.168.1.255 --broadcast 10.0.0.255finds it once, plaindiscoverand--hostare unaffected, and a search on the wrong subnet only now logsNo bridges responded to the discovery request. The Windows side of #61 still needs @sfo2001 to confirm.Refs #61
🤖 Generated with Claude Code