Add Powerline hint to username field description#167473
Conversation
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
Hey there @AaronDavidSchneider, @chemelli74, @mib1185, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
This PR makes the username field optional in the Fritz integration to support FRITZ!Powerline devices, which only support password-based authentication. The underlying fritzconnection library already supports password-only authentication when user=None is passed, automatically retrieving the last logged-in username.
Changes:
- Made username optional in all config flow steps (user, confirm, reauth) by changing from
vol.Requiredtovol.Optional(default="")and using defensive.get()access - Updated FritzConnection initialization to convert empty username to
Noneto trigger automatic username resolution - Added comprehensive test coverage for Powerline devices including user flow, SSDP discovery, reauth, and auth error scenarios
- Updated documentation strings to mention Powerline device support
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| homeassistant/components/fritz/config_flow.py | Made username optional in all form steps and added proper defensive access with .get() method |
| homeassistant/components/fritz/coordinator.py | Pass user=self.username or None to convert empty string to None for automatic username resolution |
| homeassistant/components/fritz/init.py | Use defensive .get() access when reading username from stored config entries |
| homeassistant/components/fritz/strings.json | Updated username field description to document Powerline support |
| tests/components/fritz/test_config_flow.py | Added test cases for Powerline device flows (user, SSDP, reauth, auth error) |
| tests/components/fritz/const.py | Added MOCK_USER_INPUT_POWERLINE constant for test cases |
|
Hi @iluebbe , your code was clearly written by AI. And there are some inconsistencies. Please test all values and report back. |
|
Hi @chemelli74, thanks for looking at this! I tested all cases against a real FRITZ!Powerline 1240E (fritzconnection 1.15.1): With correct password:
Without password / wrong password:
The Powerline ignores the username entirely — it only validates the password. Why Looking at fritzconnection's source, if user is None:
user = os.getenv(FRITZ_ENV_USERNAME, FRITZ_USERNAME) # -> 'dslf-config'While Both work for Powerline (since it ignores the username), but Our code path: Why this PR is needed: The current |
|
Honestly, I would rather update the documentation (https://www.home-assistant.io/integrations/fritz/#username) than modify the code. |
|
@chemelli74 fair point — I agree that making the field optional could confuse router users. How about a compromise:
This is a strings-only change, no schema modification. The The reason I'd like at least the hint in the config flow: Powerline devices appear via SSDP auto-discovery, so users see the config form without necessarily reading the docs first. A short hint in the field description would prevent confusion. I'm happy to update the PR accordingly if you agree with this approach. |
Please go ahead
Maybe we can just have a default here like "admin". What you think @mib1185 ? |
chemelli74
left a comment
There was a problem hiding this comment.
We are evaluating another approach
|
I agree with @chemelli74 we shouldn't make the user name field optional, as it isn't for the majority of the devices. Further I would not set a default user |
Add a note to the username data_description mentioning that FRITZ!Powerline devices don't have a username and any value can be entered.
167f244 to
3b5ff45
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| "data_description_port": "Leave empty to use the default port.", | ||
| "data_description_ssl": "Use SSL to connect to the FRITZ!Box.", | ||
| "data_description_username": "Username for the FRITZ!Box.", | ||
| "data_description_username": "Username for the FRITZ!Box. FRITZ!Powerline devices do not require a username; enter any value.", |
There was a problem hiding this comment.
| "data_description_username": "Username for the FRITZ!Box. FRITZ!Powerline devices do not require a username; enter any value.", | |
| "data_description_username": "Username for the FRITZ!Box. FRITZ!Powerline devices accept any value.", |
There was a problem hiding this comment.
That sounds OK to me. If technically correct we could also write "Username for the FRITZ!Box. FRITZ!Powerline devices ignore this information and accept any value."
|
@NoRi2909 can you check if wording makes sense for you please ? |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@iluebbe looking for documentation PR as well ;-) |
What it does
Adds a note to the username field description in the Fritz integration config flow, mentioning that FRITZ!Powerline devices don't have a username and any value can be entered.
Why
FRITZ!Powerline devices (e.g. 1240E) only support password-based authentication — they have no username concept and accept any value in the username field. When these devices appear via SSDP auto-discovery, users see the config form with a required username field and don't know what to enter.
As discussed with @chemelli74 and @mib1185, a documentation update + a short hint in the
data_descriptionis the right approach.Changes
data_description_usernameto mention Powerline devicesType of change
Checklist
Related to #79343