Show a connection error for an unsupported DSMR serial port URL by frenck · Pull Request #184561 · home-assistant/core · GitHub
Skip to content

Show a connection error for an unsupported DSMR serial port URL - #184561

Merged
epenet merged 1 commit into
devfrom
frenck/fix-dsmr-unsupported-url-scheme
Oct 7, 2026
Merged

epenet merged 1 commit into
devfrom
frenck/fix-dsmr-unsupported-url-scheme

Conversation

@frenck

@frenck frenck commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Breaking change

Proposed change

Serial connections for DSMR go through serialx, which also accepts URLs such as socket://host:port as the port. For a URL with a scheme it doesn't support, like http://192.168.1.20:23, it raises UnknownUriScheme, a SerialException that is not an OSError. The config flow only handled OSError, so the flow crashed and showed "Unknown error".

The connection validation now also handles serialx's SerialException, so the user gets the regular "Failed to connect" error and can correct the port. serialx is already a dependency of dsmr-parser, which uses it for the connection.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI balanced review requested due to automatic review settings October 6, 2026 21:26
@home-assistant

home-assistant Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The targeted exception handling is correct and covered by an appropriate regression test.

Review effort: Balanced
Findings: None

What changed in this PR

Handles unsupported DSMR serial URL schemes as connection failures instead of unexpected config-flow errors.

Changes:

  • Catch serialx.SerialException during validation.
  • Test both OSError and unsupported URI schemes.
File Description
homeassistant/​components/​dsmr/​config_flow.py Handles serialx connection exceptions.
tests/​components/​dsmr/​test_config_flow.py Verifies user-facing connection errors.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@frenck frenck added this to the 2026.10.0 milestone Oct 6, 2026
@epenet
epenet merged commit 16ccc93 into dev Oct 7, 2026
38 checks passed
@epenet
epenet deleted the frenck/fix-dsmr-unsupported-url-scheme branch October 7, 2026 04:33
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DSMR integration does not accept the IP address.

3 participants