Improve error message when load_xml_db fails to connect to controller#118
Open
mortms wants to merge 1 commit into
Open
Improve error message when load_xml_db fails to connect to controller#118mortms wants to merge 1 commit into
mortms wants to merge 1 commit into
Conversation
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.
PR: Improve error messaging when XML database fetch fails
PR Description
Problem
When
load_xml_db()fails to fetch the XML database from the Lutron controller(e.g., due to an incorrect IP address, network misconfiguration, or an
unresponsive controller), the user sees a raw Python
urllib.error.URLErrortraceback with
TimeoutError: [Errno 110] Operation timed out.This error gives no indication of what IP address was being contacted or
what the user should check to resolve the issue. In Home Assistant, this
surfaces as:
Users facing this error have to dig through source code to understand that the
integration is trying to reach the controller's HTTP server to download the XML
database, and that the configured IP address may simply be wrong.
Solution
This PR wraps the
urlopencall inload_xml_db()with a try/except thatcatches
urllib.error.URLErrorand raises aConnectionErrorwith a clear,actionable message that includes:
Additionally, an explicit
timeout=30is added to theurlopencall to avoidrelying on the system default socket timeout, which can vary across platforms
and lead to inconsistent behavior.
Example error output (after this change)
Change summary
urlopeninload_xml_db()with try/except forurllib.error.URLErrorConnectionErrorwith a descriptive message including the URL and hosttimeout=30tourlopencallTesting
Tested with Home Assistant 2026.2.3 on HA OS with a Lutron RadioRA 2 system.
Verified that: