-
-
Notifications
You must be signed in to change notification settings - Fork 36.3k
Set account number as required for Anglian Water config entry #157939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zweckj
merged 1 commit into
home-assistant:dev
from
pantherale0:fix/set-account-number-mandatory
Dec 4, 2025
+9
−18
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we get the account number from the API and set it as default value? Or would that be counter productive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require an extra step in the config flow as we can only get that information following a successful auth (following KISS - https://en.wikipedia.org/wiki/KISS_principle).
Perhaps for a follow up PR I could look at that what was originally proposed in the initial PR to add a select field with valid accounts for a release next year (it feels odd to say that)? More work needs to be done on the library to support that first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right - the extra step makes sense. What I don't understand yet is why inputting the number solves the problem, does the API currently select the first "working" account automatically? Or what exactly is going wrong here? The other thing is: How do we get users for which this is currently broken back to a working state, is there a way to guide them without deleting the entry first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inputting the number solves the problem as currently the account number is collected from the claims in the authentication token, not the actual API itself. It seems Anglian Water don't keep their Azure B2C users up to date with whats on their internal SAP database and therefore when you move house (or the account owner changes), you are issued with a new account number, yet retain access to your old and inactive account number which is what is still stored in the B2C user profile.
Apologies if this doesn't make sense, I don't really know how best to explain this as it does get quite complicated the more you dig.
Users will need to delete the entry, there isn't any possible way to migrate them to a working state because we won't be able to know what their account numbers are and what is "correct".
Related discussion: #156225 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its worth noting I only have access to my own account which is effectively the golden path, there are no public API docs apart from what I've figured out from de-obfuscating frontend javascript & watching network requests in the browser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking if we can detect a broken entry and offer the user with a repair where they have to enter the missing account info - tbf I'm not even sure it would be worth the effort. I agree though that a select would be a bit nicer, but that's too much effort?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yeah, I see what you mean now. I think it still might not quite work how we think because the account is always populated anyway in the config entry data.
A select would be a "nice to have", but I think that is currently too much effort for the immediate problem, especially as despite adding functionality to retrieve associated accounts (pantherale0/pyanglianwater#37) to the library, it still needs to validate each account which requires refactoring the library to support multiple accounts in one initialization (if that makes sense), I've already started this, but the code isn't published yet because it currently breaks too many things.