Ecobee username/password authentication#161716
Conversation
There was a problem hiding this comment.
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 (
EcobeeDataandasync_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. |
| errors["base"] = "login_failed" | ||
| else: | ||
| errors["base"] = "invalid_auth" |
There was a problem hiding this comment.
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.
| errors["base"] = "login_failed" | |
| else: | |
| errors["base"] = "invalid_auth" | |
| errors["base"] = "token_request_failed" | |
| else: | |
| errors["base"] = "pin_request_failed" |
| _USER_SCHEMA = vol.Schema( | ||
| { | ||
| vol.Optional(CONF_API_KEY): str, | ||
| vol.Optional(CONF_USERNAME): str, | ||
| vol.Optional(CONF_PASSWORD): str, | ||
| } | ||
| ) |
There was a problem hiding this comment.
_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.
|
@MizterB Can you open a PR to the docs to explain the new requirements? |
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
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: