Skip to content

Ecobee username/password authentication#161716

Merged
joostlek merged 4 commits into
home-assistant:devfrom
MizterB:ecobee-webauth
Feb 25, 2026
Merged

Ecobee username/password authentication#161716
joostlek merged 4 commits into
home-assistant:devfrom
MizterB:ecobee-webauth

Conversation

@MizterB
Copy link
Copy Markdown
Contributor

@MizterB MizterB commented Jan 27, 2026

Proposed change

Allow the Ecobee integration to authenticate with account credentials (username / password), as an alternative to the current method which requires an API key. The API key has limited utility to new users, as Ecobee has not accepted developer registrations since March 2024.

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

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:

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Ecobee integration’s configuration flow to support authenticating with Ecobee account credentials (username/password) as an alternative to the legacy API key–based developer flow, and wires that through to runtime usage and tests.

Changes:

  • Updates the Ecobee config flow to accept either an API key or a username/password pair and to short‑circuit directly to entry creation when username/password authentication succeeds.
  • Extends the Ecobee integration runtime (EcobeeData and async_setup_entry) to support initializing and refreshing tokens when configured with username/password instead of an API key.
  • Adds config flow tests that verify the new success, failure, and invalid‑combination paths for username/password authentication.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
homeassistant/components/ecobee/config_flow.py Extends the user step schema and logic to accept either API key or username/password, and introduces new login_failed / invalid_auth error paths for credential-based auth.
homeassistant/components/ecobee/__init__.py Generalizes EcobeeData and async_setup_entry to handle either API-key or username/password credentials, and updates token refresh logic to persist the appropriate credential set back into the config entry.
tests/components/ecobee/test_config_flow.py Adds tests covering successful and failed username/password authentication and the invalid combination case when both API key and credentials are supplied.

Comment on lines +61 to +63
errors["base"] = "login_failed"
else:
errors["base"] = "invalid_auth"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The new error keys "login_failed" and "invalid_auth" are used here for config flow errors, but there are no corresponding entries under config.error in homeassistant/components/ecobee/strings.json, so the UI will surface raw keys instead of user-friendly messages. Please add localized error message entries for these keys (similar to "pin_request_failed" and "token_request_failed") so users get clear feedback when credential authentication fails or the provided field combination is invalid.

Suggested change
errors["base"] = "login_failed"
else:
errors["base"] = "invalid_auth"
errors["base"] = "token_request_failed"
else:
errors["base"] = "pin_request_failed"

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +19
_USER_SCHEMA = vol.Schema(
{
vol.Optional(CONF_API_KEY): str,
vol.Optional(CONF_USERNAME): str,
vol.Optional(CONF_PASSWORD): str,
}
)
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

_USER_SCHEMA now allows either an API key or a username/password pair, but the config.step.user description and field definitions in strings.json still only mention entering an API key. To keep the UI consistent with the actual behavior, please update the user-step description (and, if needed, data field text) to explain that users can authenticate either with an API key or with their Ecobee account credentials.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@joostlek joostlek merged commit 58e8a8d into home-assistant:dev Feb 25, 2026
31 of 33 checks passed
@joostlek
Copy link
Copy Markdown
Member

@MizterB Can you open a PR to the docs to explain the new requirements?

@github-actions github-actions Bot locked and limited conversation to collaborators Feb 26, 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.

3 participants