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

Add seperate setup flow to coordinator #447

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

Conversation

WebSpider
Copy link
Contributor

This alters the coordinator setup as follows:

  • When doing a data update (poll), we make a distinction between a regular update and one being made while the MySkoda integration is being setup
  • During setup, we require the get_user() and get_vehicle() call not to return any unignorable errors
  • During setup, we tell HA to schedule the MQTT connection for when we are done setting up
  • During regular polling, we check if MQTT connection is still present, and try to reconnect if needed

This should allow the integration to succesfully set-up, even if MQTT is unavailable, instead of blocking HA startup for 1h.

- Seperate flow for setup phase
- Schedule MQTT connection only after integration has initialized
- Wrap MQTT startup in try/except for proper unlocking
@WebSpider WebSpider added the bugfix This PR contains a bugfix label Dec 13, 2024
@WebSpider WebSpider marked this pull request as draft December 13, 2024 10:30
@WebSpider
Copy link
Contributor Author

Converted to draft since this probably needs a different approach

@dvx76
Copy link
Member

dvx76 commented Dec 23, 2024

Why does this need a different approach?

I'm trying to understand how the coordinator is involved during the setup (ConfigFlow?) i.e. how does _async_update_data end up being called during the setup?

@WebSpider
Copy link
Contributor Author

Why does this need a different approach?

The approach that is currently in this draft is mostly incomplete and has corner cases for multiple vehicles, integration reloading

I'm trying to understand how the coordinator is involved during the setup (ConfigFlow?) i.e. how does _async_update_data end up being called during the setup?

ConfigFlow is the configuration of the integration. Once the integration is configure, it can be setup. Those are two different things.

In setup, async_setup is called in __init__.py, which instantiates and inits the coordinator(s).

Have a look at the coordinators parent class, they are partially overriden by us only

@WebSpider
Copy link
Contributor Author

My idea is to only request data during first setup of coordinator that is needed for the actual initialisation, and then do a normal data pull.

This should hopefully make integration setup a lot more robust

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

Successfully merging this pull request may close these issues.

2 participants