Raise a proper error when the bridge can't be reached - #83
Merged
Conversation
Only asyncio.TimeoutError was translated when opening the connection, so everything else that asyncio.open_connection raises, a refused connection, a host that is gone from the network, a hostname that doesn't resolve, escaped as a bare OSError. Callers can't reasonably catch that, and in the reconnect loop it ended up in the catch-all handler, which logged a full traceback every five seconds for as long as the bridge stayed away. Translate it to AioComfoConnectNotReachable and retry it like a timeout.
This was referenced Aug 2, 2026
Merged
Local connection lost when WAN is down, error flooding
michaelarnauts/home-assistant-comfoconnect#87
Closed
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.
Opening the connection only translated
asyncio.TimeoutError:Everything else that
asyncio.open_connection()can raise came out as a bareOSError: a refused connection, a bridge that is gone from the network, a hostname that no longer resolves. That is not something a caller can reasonably catch, and it is what the reporter of home-assistant-comfoconnect#100 ran into:It also ended up in the catch-all handler of the reconnect loop, which logs the full traceback, every five seconds for as long as the bridge stays away.
OSErroris now translated to a newAioComfoConnectNotReachable, and the reconnect loop retries it the same way it retries a timeout, with a one line warning instead of a traceback.Some notes:
TimeoutErrorhandler has to stay above theOSErrorone, sinceTimeoutErroris a subclass ofOSError. There is a comment saying so.ComfoConnectNotReachablealready exists but means something else, the gateway telling us it cannot route a request to a node, so this needs its own exception. It is in theAiofamily with the other connection level errors.For the Home Assistant integration this needs a small follow up: it catches
AioComfoConnectTimeoutto trigger the rediscovery that handles a bridge that changed address, andAioComfoConnectNotReachableshould trigger the same path.🤖 Generated with Claude Code