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 hyperion config options flow #43673

Merged
merged 6 commits into from
Nov 30, 2020
Merged

Conversation

dermotduffy
Copy link
Contributor

@dermotduffy dermotduffy commented Nov 26, 2020

Breaking change

Adds Hyperion config flow, with automated migration between YAML configuration to config entries. Every attempt is made to preserve entity_ids, but they may change during this migration.

Proposed change

  • Add a Hyperion configuration flow, with tests. This is part 2 of the major rework of the Hyperion component (see Part 1).
  • This will allow the YAML configuration to be completely removed in a subsequent PR (after the deprecation window).
  • Rework tests to use config entry based testing by default.
  • This automatically pulls in new features that the underlying library supports but that were not available before due to limitations of the YAML configuration support (e.g. access to multiple Hyperion instances on the same server, Hyperion authentication, dynamic instances -- entities created/removed in Home Assistant as they are created/removed on the Hyperion server).
  • Add an option (priority) that can be tweaked from the UI.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

None.

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

* Add initial skeletal config flow.

* Deprecate all remaining YAML options.

* Add basic config_entry plumbing.

* Add priority and name plumbing.

* Add token support.

* Add auth handling.

* Test correct abort message is used.

* Variable tidy.

* Break out instance into a separate stage/form.

* Add zeroconf step.

* Add flow diagram.

* Use IP address rather than hostname for zeroconf.

* Add zeroconf support and final confirmation.

* Update http port comment and remove TODO for now.

* Back out instances support, the entry is for the Hyperion server.

* Dynamic instance creation/deletion.

* Convert tests to use config entries by default

* Test unload.

* Argument cleanup.

* Test YAML key

* Add automatic migration from YAML to config entry

* Various pylint fixes

* Remove completed TODO

* Add unique_id comment.

* Add to the domain to the id for extensibility.

* Update unique_id comment.

* Add skeletal options flow.

* Add strings for options flow.

* Plumb options through to entity.

* Add strings entry for already_in_progress.

* Set unique_id as early as possible for Zeroconf.

* Ensure entry_id actually exists in data.

* Fix bug in dynamic token creation.

* Use context manager for connections.

* Lint fixes

* Migrate options from YAML.

* Add SSDP support.

* Fix duplicate SSDP discoveries.,

* Remove zeroconf support (as SSDP is used anyway).

* Fix migration bug of old unique_id values.

* Add test for new style unique_id without config

* Remove domain from unique_id.

* Add log entry for migration

* Change title to host:port rather than id.

* Rely on the latest hyperion-py

* Fix merge error AsyncMock -> CoroutineMock.

* Test some additional error conditions.

* Phase 1 fixes for codereview

* Rearrange flow steps as per code review.

* Update flow diagram

* Minor diagram update

* Re-arrange loading logic  as per codereview.

* Remove TODO.

* Remove options flow and save for a future PR.

* Remove TODO as it fails pylint.

* Address @balloob code review feedback

* Codereview fixes for @MartinHjelmare (Part 1)

* Codereview fixes for @MartinHjelmare (Part 2)

* Codereview fixes for @MartinHjelmare (Part 3)

* pylint fix.

* Codereview fixes for @MartinHjelmare (Part 4)

* Codereview fixes for @MartinHjelmare (Part 4)

* pylint fixes.

* Codereview fixes for @MartinHjelmare (Part 5)

* Codereview fixes for @MartinHjelmare (Part 6)
* Add options flow and tests.

* Codereview fixes for @MartinHjelmare (Part 1)

* Use relative import
* Add rigorous type hinting to Hyperion

* Typing/lint fixes and bump hyperion-py version

* Add type definition for effect_list.

* Fix mypy when run w/o the underlying hyperion-py
* Add name to entity unique ids for future extensibility

* Bump the Hyperion version we warn at

* Use a type name instead of the light domain
@dermotduffy
Copy link
Contributor Author

@MartinHjelmare Time to get out of this special branch! As you previously requested, here is a draft PR to merge add-hyperion-config-options-flow back into dev. Note that #43674 should be merged first, to ensure tests continue to pass post-merge.

I have locally tested the resultant merge into dev (both unittests and functionality sanity check).

This PR description is unchanged from when I started down this rabbit hole. The only alteration is a new PR to update the documentation: home-assistant/home-assistant.io#15763

Thank you!

* Allow more time until config option invalidation

* Restore the invalidation of CONF_HDMI_PRIORITY

* Remove invalidation_version as flags used in tests
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Great!

@dermotduffy dermotduffy marked this pull request as ready for review November 26, 2020 23:49
@dermotduffy
Copy link
Contributor Author

Hi @MartinHjelmare , anything left to do before merging this in and closing out this special branch? Thank you!

@MartinHjelmare MartinHjelmare merged commit 7ad2a6b into dev Nov 30, 2020
@MartinHjelmare MartinHjelmare deleted the add-hyperion-config-options-flow branch November 30, 2020 17:38
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hyperion is not discovered, when HA Core starts first
3 participants