Improve config flow UX: collapsed advanced section, server-list region picker, clearer username hint#227
Open
fredrik-lindseth wants to merge 2 commits intoJezza34000:mainfrom
Open
Conversation
Three changes that surface together because they all touch the initial account-login form: 1. Region and timezone now sit inside a collapsed "Advanced" section instead of appearing only after a failed first attempt. Defaults come from Home Assistant configuration; users only expand the section if they need to override. 2. The 200+ country dropdown is replaced with a short list of the actual PetKit regional gateways (Europe, International, Asia, Russia, China). The list is fetched live from passport.petkt.com/v1/regionservers and grouped by gateway. If the call fails the legacy country dropdown is shown as fallback. The China gateway is added manually since pypetkitapi reaches it via a separate code path that is not in the regionservers response. 3. The username field is renamed from "Username/Id" to "Username", and the helper text now switches based on the user's HA country (CN gets phone/PetKit-ID hint, everyone else gets the email hint). This removes the "or id if you are a Chinese user" line that confused most users. Plus one related fix in __init__.py: when login succeeds but PetKit returns no devices (typical when the secondary account has not yet accepted the Family Management invitation in the mobile app), raise ConfigEntryNotReady with a message that explains the next step instead of silently configuring an integration with zero entities.
for more information, see https://pre-commit.ci
|
Owner
|
Hi @fredrik-lindseth However, I have just one comment regarding the architecture:
Could you modify the library and your pull request accordingly to maintain the architecture? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



📝 Proposed Change / Description
Three small UX cleanups to the initial account-login form, plus one related setup-failure fix.
passport.petkt.com/v1/regionservers; falls back to the country dropdown if the call fails. China is added manually because pypetkitapi reaches it via a separate code path.Username/IdtoUsernameand switch the helper text onhass.config.country(CN gets phone/PetKit-ID hint, others get email hint).__init__.py: when login succeeds but no devices are returned (typical for a secondary account that has not yet accepted the Family Management invite), raiseConfigEntryNotReadywith a clear message instead of silently configuring zero entities.Storage format unchanged: section data is flattened back to top-level
CONF_REGION/CONF_TIME_ZONEinentry.data. Onlytranslations/en.jsonupdated; other languages will fall back to English on the new keys until Weblate syncs.Fixes: #---
🔖 Type of change
🐾 Affected devices
🧪 How has this been tested?
Device(s) tested on: Eversweet Max 2 (CTW3)
Verified: initial form renders with collapsed Advanced; expanding shows 5 server options with Europe auto-selected for HA-NO; failed login preserves user input; existing entries continue to load after upgrade. Family Management
ConfigEntryNotReadypath was not exercised live (no test account without Family Management).✅ Checklist
pre-commit run -ahooks and all checks passmain📸 Screenshots
Initial form (collapsed Advanced):
Advanced expanded (5 server options, Europe pre-selected for HA-NO):
Failed login preserves the username field: