Skip to content

Use protocol default port and keep form input in Axis config flow - #195402

Open
genestealer wants to merge 4 commits into
home-assistant:devfrom
genestealer:axis-config-flow-port
Open

genestealer wants to merge 4 commits into
home-assistant:devfrom
genestealer:axis-config-flow-port

Conversation

@genestealer

@genestealer genestealer commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Proposed change

Fixes two problems with the Axis setup, reauthentication and reconfiguration form:

  1. Port did not follow the protocol. The port was pre-filled with 443, so selecting HTTP and submitting kept port 443. The port is now optional: when left empty, it uses the selected protocol's default (80 for HTTP, 443 for HTTPS). An entered port is always kept. When reconfiguring, a protocol default port is left empty so it follows a protocol change, while a custom port is pre-filled.
  2. Entered values were lost after an error. After "Failed to connect" or "Invalid authentication", the form now shows the submitted protocol, host, username, password and port again, so the user can correct them instead of re-entering everything.

Existing config entries are not changed; the stored port is always a number.

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 (refactoring, typing, performance, etc.)
  • Developer tooling (CI, GitHub workflows, linters and checkers, scripts, AI instructions, code owners)

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to contributors documentation pull request:
  • Link to frontend pull request:

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 adaptive review requested due to automatic review settings November 29, 2026 22:24
@home-assistant

home-assistant Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

👋 Hi! Thanks for contributing to Home Assistant.

This is your PR dashboard which flags anything you need to address before your PR can be reviewed. Once everything is green, you can press the 'Ready for review' button at the bottom of the page to notify reviewers to take a look.

More information about this dashboard

This dashboard automatically updates on every change to this PR and reevaluates the rules as you go. Until everything has been addressed, the bot will keep the PR in draft.

Skip a check that doesn't apply

If you think a check doesn't apply to your PR (or the rule is bugged), comment @home-assistant ignore "<check name>" "<reason>". The check name as shown in the table above. This will mark the check as ignored and let you put your PR in 'Ready for review'; @home-assistant unignore "<check name>" restores the rule.

Bot commands

Reply with @home-assistant <command>. Several commands can be stacked, one per line:

  • update — Re-runs the bot's checks on the issue or pull request.
  • ignore — Waives a dashboard check: ignore "<check name>" "<reason>". (author) — e.g. @home-assistant ignore "Merge conflicts" "Broken rule, no merge conflicts present"
  • unignore — Restores a waived dashboard check: unignore "<check name>". (author) — e.g. @home-assistant unignore "Merge conflicts"
  • unassign — Removes the given integration domain's label and its code owners from the assignees. (author or code owners) — e.g. @home-assistant unassign "opensky"
  • close — Closes the issue or pull request. (code owners)
  • reopen — Reopens the issue or pull request. (code owners)
  • rename — Renames the issue or pull request: rename "<new title>". (code owners) — e.g. @home-assistant rename "A more descriptive title"
  • add-label — Adds a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the issue or pull request. (code owners) — e.g. @home-assistant add-label "needs-more-information"
  • remove-label — Removes a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) from the issue or pull request. (code owners) — e.g. @home-assistant remove-label "needs-more-information"
  • mark-draft — Marks the pull request as draft. (code owners)
  • update-branch — Updates the pull request branch with the base branch. (code owners)

Checks

✨ Everything's in order!

5 checks passed (6 skipped)
Status Check Details
✅ Forbidden files No forbidden files.
✅ Merge conflicts Merge status is being recalculated by GitHub.
✅ Merge target This PR targets dev.
✅ Type of change Type of change: bugfix
✅ CLA Everyone involved has signed the CLA.
➖ New integration validation Not a new-integration PR.
➖ Single new platform No new platforms added.
➖ Documentation Not a new integration or platform — no documentation PR required.
➖ Belongs together No pull requests listed.
➖ Code owner approval Touches no platinum integration — no code-owner approval required.
➖ Blocking: awaiting-frontend awaiting-frontend label not set — nothing to block.

@home-assistant

Copy link
Copy Markdown
Contributor

Hey there @Kane610, mind taking a look at this pull request as it has been labeled with an integration (axis) you are listed as a code owner for? Thanks!

Code owner commands

Reply with @home-assistant <command>:

  • update — Re-runs the bot's checks on the issue or pull request.
  • ignore — Waives a dashboard check: ignore "<check name>" "<reason>". (author) — e.g. @home-assistant ignore "Merge conflicts" "Broken rule, no merge conflicts present"
  • unignore — Restores a waived dashboard check: unignore "<check name>". (author) — e.g. @home-assistant unignore "Merge conflicts"
  • unassign — Removes the given integration domain's label and its code owners from the assignees. (author or code owners) — e.g. @home-assistant unassign "opensky"
  • close — Closes the issue or pull request. (code owners)
  • reopen — Reopens the issue or pull request. (code owners)
  • rename — Renames the issue or pull request: rename "<new title>". (code owners) — e.g. @home-assistant rename "A more descriptive title"
  • add-label — Adds a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the issue or pull request. (code owners) — e.g. @home-assistant add-label "needs-more-information"
  • remove-label — Removes a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) from the issue or pull request. (code owners) — e.g. @home-assistant remove-label "needs-more-information"
  • mark-draft — Marks the pull request as draft. (code owners)
  • update-branch — Updates the pull request branch with the base branch. (code owners)

@genestealer
genestealer marked this pull request as ready for review November 29, 2026 22:25
@genestealer
genestealer requested a review from Kane610 as a code owner November 29, 2026 22:25

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.

🟡 Changes recommended

An omitted port retains the previous custom-port suggestion after a connection or authentication error, causing subsequent submissions to use it instead of the protocol default.

1 open issue
What changed in this PR

This PR improves Home Assistant’s Axis configuration flow by selecting default ports based on the protocol and preserving form input after connection or authentication errors.

Changes:

  • Make the port optional, using 80 for HTTP or 443 for HTTPS while preserving explicit ports.
  • Restore submitted values after errors and prefill custom ports during reconfiguration.
  • Add port guidance and tests for default ports and form retries.
File Description
tests/​components/​axis/​test_config_flow.py Tests protocol defaults, custom ports, and input preservation after errors.
homeassistant/​components/​axis/​strings.json Explains the behavior when the port is left empty.
homeassistant/​components/​axis/​config_flow.py Resolves default ports and retains submitted form values.

Review effort: Balanced (adaptive)

Copilot AI adaptive review requested due to automatic review settings November 29, 2026 22:40

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.

🟢 Approval recommended

No active review issues are reported for the protocol-aware port defaults and form-input preservation changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced (adaptive)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants