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
Support vizio pairing through config flow #31520
Support vizio pairing through config flow #31520
Conversation
A couple questions / comments:
|
|
I don't know what the difference is between storing it in the config_entries storage file vs. storing it in storage. But ultimately, my question is as follows. Suppose a user configures their Vizio TV as vizio:
host: 192.168.0.123:7345 And suppose they go through the pairing process in HA but they don't add the access token to their configuration. Then every time they restart HA, they'll need to go through the pairing process again, right? |
No, they won't have to do that. By moving to config flow, entities are no longer directly loaded from configuration.yaml. Instead, they are loaded from a ConfigEntry. When you launch HA for the first time with the config you posted, the config gets imported into the vizio config flow and a ConfigEntry gets created, which is then persisted to storage and will survive through restarts. When a user goes through the pairing process, the access token gets stored in the config data for the ConfigEntry. This means it is available on restart to reload the entity even if it hasn't been added to configuration.yaml, and will remain there until you delete the ConfigEntry entirely from the Integrations menu or wipe your storage. After a config gets imported into a ConfigEntry, the ConfigEntry is independent from configuration.yaml. What happens on restarts is that HA attempts to import the configuration again, but sees that a vizio ConfigEntry for the specified host already exists and aborts the import process. This means that you can remove that piece from your configuration.yaml entirely, restart, and the entity will still be there, and the only way to completely remove it is to both delete it from configuration.yaml and from the Integrations menu in the frontend. I think I'm overexplaining at this point but just to complete the thought, the only way configuration.yaml affects your vizio entities after the initial startup is if you specify a different name or volume_step in your config, as those changes are detected and get applied to the ConfigEntry before import is aborted. |
Thanks for the detailed explanation! |
Codecov Report
@@ Coverage Diff @@
## dev #31520 +/- ##
======================================
Coverage ? 94.76%
======================================
Files ? 768
Lines ? 55686
Branches ? 0
======================================
Hits ? 52769
Misses ? 2917
Partials ? 0
Continue to review full report at Codecov.
|
17c9d02
to
e791e15
Compare
@MartinHjelmare I've learned a lot from your reviews of my past PRs, would you mind reviewing this one as well when you have a moment? |
e791e15
to
9820e27
Compare
9820e27
to
47f2e77
Compare
47f2e77
to
8c1e2e1
Compare
Proposed change
The
vizio
integration currently requires users to pair to their device usingpyvizio
on the command line. This PR allows the pairing process to be completed through config flow for all source types (this also means the additional custom validation for configuration.yaml entries can be removed because pairing for config imports is also supported). For config imports, a message is now logged anytime the import does not get aborted because aborts typically occur due to a previous import whereas setup failures are silent without the logging.Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale: