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 Linkplay mTLS/HTTPS and improve logging #124307

Merged
merged 13 commits into from
Sep 3, 2024

Conversation

dukeofphilberg
Copy link
Contributor

@dukeofphilberg dukeofphilberg commented Aug 20, 2024

Proposed change

This PR adds new HTTPS/mTLS functionality for LinkPlay devices that do not support HTTPAPI over HTTP. This allows more devices such as the WiiM to work with HomeAssistant which was noted in #123088.

Specifically, constructing a LinkPlayBridge now happens through linkplay_factory_httpapi_bridge, which will automatically try both HTTPS and downstepping to HTTP. The function throws a LinkPlayRequestException if no LinkPlayBridge was able to be created, allowing for additional logging.

Additionally, new media sources have been added and tests now use @pytest.mark.usefixtures as per recommendation.

Requires python-linkplay==0.0.9 to provide the async creation of SSLContext and ClientSession that loads the mTLS certificate. https://github.com/Velleman/python-linkplay/releases/tag/v0.0.9

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format 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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

home-assistant[bot]

This comment was marked as outdated.

@home-assistant
Copy link

Hey there @Velleman, mind taking a look at this pull request as it has been labeled with an integration (linkplay) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of linkplay can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign linkplay Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

home-assistant[bot]

This comment was marked as outdated.

@dukeofphilberg dukeofphilberg marked this pull request as ready for review August 21, 2024 13:49
@MartinHjelmare MartinHjelmare changed the title Linkplay: Incorporate mTLS/HTTPS and improve logging Add Linkplay mTLS/HTTPS and improve logging Aug 24, 2024
@joostlek
Copy link
Member

Is that upadted now?

@dukeofphilberg dukeofphilberg mentioned this pull request Aug 26, 2024
20 tasks
Address old comments in 113940
@dukeofphilberg
Copy link
Contributor Author

Is that upadted now?

Yes the necessary changes have been made in https://github.com/Velleman/python-linkplay/releases/tag/v0.0.9 and have now been implemented in this branch

@silamon
Copy link
Contributor

silamon commented Sep 3, 2024

What's the next step for this pull request?

@joostlek joostlek added this to the 2024.9.0 milestone Sep 3, 2024
@joostlek
Copy link
Member

joostlek commented Sep 3, 2024

Mostly not forgetting about it and pressing the merge button

@joostlek joostlek merged commit b9db9ee into home-assistant:dev Sep 3, 2024
39 of 40 checks passed
bramkragten pushed a commit that referenced this pull request Sep 3, 2024
* Work

* Implement 0.0.8 changes, fixup tests

* Cleanup

* Implement new playmodes, close clientsession upon ha close

* Implement new playmodes, close clientsession upon ha close

* Add test for zeroconf bridge failure

* Bump 0.0.9
Address old comments in 113940

* Exact _async_register_default_clientsession_shutdown
@@ -4,3 +4,4 @@

DOMAIN = "linkplay"
PLATFORMS = [Platform.MEDIA_PLAYER]
CONF_SESSION = "session"
Copy link
Member

@MartinHjelmare MartinHjelmare Sep 4, 2024

Choose a reason for hiding this comment

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

We don't prefix constants with CONF_ unless it's a key used for configuration. Use eg DATA_SESSION instead.

iloveicedgreentea pushed a commit to iloveicedgreentea/core that referenced this pull request Sep 4, 2024
* Work

* Implement 0.0.8 changes, fixup tests

* Cleanup

* Implement new playmodes, close clientsession upon ha close

* Implement new playmodes, close clientsession upon ha close

* Add test for zeroconf bridge failure

* Bump 0.0.9
Address old comments in 113940

* Exact _async_register_default_clientsession_shutdown
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2024
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.

Linkplay Integration fails to setup
5 participants