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

Fix/Refactor Hyperion Integration #39738

Merged
merged 43 commits into from
Sep 24, 2020
Merged

Fix/Refactor Hyperion Integration #39738

merged 43 commits into from
Sep 24, 2020

Conversation

dermotduffy
Copy link
Contributor

@dermotduffy dermotduffy commented Sep 7, 2020

Breaking change

Fixes the Hyperion Integration to work with the current Hyperion-NG release. Refactors the integration to rely on the hyperion-py client. The default_color, hdmi_priority and effect_list parameters no longer have any effect. Instead, users should use light profiles (as per https://www.home-assistant.io/integrations/light/) as default color. The effect_list is now automatically populated. The hdmi_priority parameter no longer make sense with Hyperion-NG and will be removed in a future release.

Proposed change

The current Hyperion integration does not work with the current version of Hyperion (see this bug: #36471 ). This PR rewrites the integration in order to:

  • Actually work.
  • Remove direct communication with Hyperion by using the hyperion-py client code instead.
  • Add significant test coverage.
  • Take advantage of subscriptions (via the client library) to avoid polling.

Based on the advice received in the earlier PR attempt, this rewrite intentionally leaves the YAML entirely untouched so as to respect ADR-0007 and ADR-0010.

Instead, once this in-place refactor has been submitted and functionality restored, the YAML will be subsequently removed and a configuration flow added instead. These changes are kept separate to reduce the review size.

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:

# Example configuration.yaml
  - platform: hyperion
    host: 'hyperion'
    name: Sitting Room Hyperion

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:

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.

Nice!

homeassistant/components/hyperion/light.py Outdated Show resolved Hide resolved
homeassistant/components/hyperion/light.py Outdated Show resolved Hide resolved
homeassistant/components/hyperion/light.py Outdated Show resolved Hide resolved
homeassistant/components/hyperion/light.py Outdated Show resolved Hide resolved
homeassistant/components/hyperion/light.py Outdated Show resolved Hide resolved
homeassistant/components/hyperion/light.py Outdated Show resolved Hide resolved
homeassistant/components/hyperion/light.py Outdated Show resolved Hide resolved
tests/components/hyperion/test_light.py Outdated Show resolved Hide resolved
@dermotduffy
Copy link
Contributor Author

@MartinHjelmare A huge thank you for the great review. I've attempted to integrate your recommendations -- in particular, I think the unittest is looking much better, thank you for the pointer to the concrete example of that alternative approach.

Thanks again for your time.

tests/components/hyperion/test_light.py Outdated Show resolved Hide resolved
tests/components/hyperion/test_light.py Outdated Show resolved Hide resolved
homeassistant/components/hyperion/light.py Outdated Show resolved Hide resolved
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!

@MartinHjelmare
Copy link
Member

Should we use another target branch to merge this, so we can guarantee to release all the big changes, including config flow, in the same release?

In that case I can push a copy of dev that we can use as target branch and you can rebase the branch here and swap target branch in the PR.

@dermotduffy
Copy link
Contributor Author

Thanks @MartinHjelmare for the continued review!

To make sure I understand (and to be over explicit) you are proposing:

  • You create a different target branch in this repo for the chunk of Hyperion work (e.g. hyperion-rewrite), including this PR and the rest of the work (e.g. config flow).
  • I rebase my work onto that new branch (In my local repo: git rebase hyperion-rewrite)
  • I then push that back up, and change the target branch in the PR to hyperion-rewrite.

If that's what you mean:

  • The downside is that the Hyperion integration stays broken in dev for longer.
  • The upside is that it's potentially less hassle for users. Whilst it should work seamlessly, if something were to go wrong there'd be Hyperion fixes/drama now, and potentially more later when the config flow is introduced.

In the end, I do not have a strong preference -- happy to support and work with whatever you think is the best path.

@MartinHjelmare
Copy link
Member

MartinHjelmare commented Sep 24, 2020

Yes.

I forgot that this PR is fixing a current issue. Then I think we should merge this to dev to make sure it's in the beta cut next week. Ok?

@dermotduffy
Copy link
Contributor Author

Yes, totally fine also. Thanks.

@MartinHjelmare MartinHjelmare merged commit 0a656f1 into home-assistant:dev Sep 24, 2020
@pkishino
Copy link
Contributor

pkishino commented Oct 8, 2020

thanks for updating this , my workaround hack was working but not really clean.. the only comment I have on this update is that now the effects list is really big which makes it very annoying to use on mobile devices.. It would be nice if we could override adding all effects and only keep ones we specify..previously I only had 4-5 effects I could quickly switch between

@Sousanator
Copy link

Hi, I've upgraded to Home Assistant 0.116.1 with the news that this was released, however I still can't get instances to work. I get the following with my configuration.yaml:
Invalid config for [light.hyperion]: [instance] is an invalid option for [light.hyperion]. Check: light.hyperion->instance. (See ?, line ?).

@JeffResc
Copy link
Contributor

JeffResc commented Oct 9, 2020

@Sousanator Could you please share your YAML? I have the following as the integration YAML and it seems to work for me:

light:
  - platform: hyperion
    host: x.x.x.x
    port: 19444
    name: Hyperion

@Sousanator
Copy link

@JeffResc Yes, that configuration works for instance 0 in hyperion.ng but I have multiple instances I want to control. There's a change mentioned above ( Support instance selection from multiple instances. c8424d4 ) that appears I can add 'instance: 2' to be able to select my third instance but it won't load the configuartion.yaml

light:
  - platform: hyperion
    host: x.x.x.x
    port: 19444
    name: Hyperion 3
    instance: 2

@dermotduffy
Copy link
Contributor Author

dermotduffy commented Oct 9, 2020

@Sousanator Yes, I had to remove support in the YAML for multiple Hyperion instances, as Home Assistant developers do not allow modifications to YAML anymore -- instead they ask component owners to move to using Web-UI based configuration. I have work already in flight to do this, which intends to provide full multi-instance support (without any YAML at all). See relevant Home Assistant decision for why they have applied these limitations on component developers. I hope to have the features for this ready on the dev branch within the next week or so.

@pkishino I can have a think about that. Would you mind filing a bug against me here ( https://github.com/home-assistant/core/issues/new?template=BUG_REPORT.md ). I won't be able to support this in the YAML (as the YAML is being removed in future, as above), so I will need to think about how to represent this in a UI-based config flow.

@pkishino
Copy link
Contributor

pkishino commented Oct 9, 2020

@dermotduffy Ok, I'll see when I have the time to create it.. was thinking similar to plex integration.. pull in a list of all effects and allow user to select which ones to "monitor", tickbox with "Ignore any new effects" etc

@p4sI
Copy link

p4sI commented Oct 12, 2020

Hi, was there a particular reason to remove the old integration? It was still working fine for me and now I had to spent some hours to update from Hyperion from HyperionNG, before I could do the HomeAssistant update and not breaking my system.
Do you think it would make sense to put the old one back in, to have 2 Integrations, one for Hyperion and one for HyperionNG.?

@MartinHjelmare
Copy link
Member

Please open an issue if you suspect a bug.

If you want to suggest an enhancement please open a feature request in the Feature Requests section of our community forum.

Merged PRs should not be used for enhancement discussion or bug reports. If you've found a bug it's ok to make a review with inline comments and link to an issue that reports the bug.

Thanks!

@home-assistant home-assistant locked as resolved and limited conversation to collaborators Oct 12, 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 integration needs to be updated / not working correctly
7 participants