Skip to content
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

(chore) Config migration flow #528

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

WebSpider
Copy link
Contributor

@WebSpider WebSpider commented Jan 5, 2025

This PR adds 2 things:

  • Config migration flow: With config migration flow we can migrate our config and values between versions. It now becomes possible to rename recalculate values, rename entities, change option defaults, etc within a version upgrade
  • Add unique_id to config entries: The config entries we created, which are used at integration setup, did not have a unique identifier. This is now added, and set to the user ID generated for your MySkoda account. Unique ID's are used within HA widely, but in this case it is particularly useful to support reauthentication (if you changed your password)

This is a partial reimplementation of #502, as that PR made too many changes at once and a preparation for #496 and #497

Copy link
Member

@dvx76 dvx76 left a comment

Choose a reason for hiding this comment

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

Cool. Thanks for figuring this out! Code looks good to me.

Comment on lines +161 to +165
except AuthorizationFailedError as exc:
raise ConfigEntryAuthFailed("Log in failed for %s: %s", DOMAIN, exc)
except Exception as exc:
_LOGGER.exception("Login with %s failed: %s", DOMAIN, exc)
return False
Copy link
Member

Choose a reason for hiding this comment

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

question: what's the difference in behavior (by HA) when this returns False vs when an exception is raised? False ignores the migration and let's the init complete and an exception causes the init to fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

False means the migration did not succeed, but lets the integration complete setup. When raising ConfigEntryAuthFailed, HA signals that there is a problem with authentication, and either starts a ConfigFlow of type reauth, which we dont have yet, so it falls back to an error in the UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants