Skip to content

Support media player grouping in apple_tv integration#94704

Closed
michalmo wants to merge 2 commits into
home-assistant:devfrom
michalmo:appletv-media-player-grouping
Closed

Support media player grouping in apple_tv integration#94704
michalmo wants to merge 2 commits into
home-assistant:devfrom
michalmo:appletv-media-player-grouping

Conversation

@michalmo
Copy link
Copy Markdown
Contributor

Proposed change

This PR adds support for grouping (media_player.join, media_player.unjoin and group_members) to the apple_tv integration, which was enabled in the latest pyatv (#94683).

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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 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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link
Copy Markdown
Contributor

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

Code owner commands

Code owners of apple_tv 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 apple_tv Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@michalmo
Copy link
Copy Markdown
Contributor Author

@postlund, will you have some time to review this? It adds HA grouping support using the set output devices feature I recently added to pyatv.

@postlund
Copy link
Copy Markdown
Contributor

@michalmo Right, sorry, I'll try to get to it asap.

Copy link
Copy Markdown
Contributor

@postlund postlund left a comment

Choose a reason for hiding this comment

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

Overall gist looks good, but it's a big change and I think a core dev should have a look too.

SUPPORT_BASE = (
MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.GROUPING
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this should be added here as it would suggest all devices supports grouping, which isn't the really the case (old Apple TVs for instance).

You need to add the features related to grouping to SUPPORT_APPLE_TV. You can just map all of them to GROUPING and the issue above will be solved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll explain my reasoning:

Apple devices can be controllers, that actually play the media and send it to other devices. Other AirPlay devices can be players.

Home Assistant has a few features gated behind this support flag, one of which is the group_members attribute.
A device that can be grouped needs to have this flag set so that it can expose that attribute.

In async_join_players there is an extra check for FeatureName.AddOutputDevices to see if the device can be the group controller, that feature is set If there is an MRP connection (so not for AirPlay only devices).

Now I don't have any device that doesn't work with grouping so I can't run any more checks.
@postlund do you know if feature support is device specific, or OS version specific? Also can these old Apple TVs be added to a group over AirPlay even if they can't be leaders? Are there any AirPlay devices that cannot be added t a group? If I knew that I could try to add more specific features flagging.

@frenck frenck marked this pull request as draft October 8, 2023 15:09
@frenck
Copy link
Copy Markdown
Member

frenck commented Oct 8, 2023

Converted this PR to a draft, as there is an unresolved discussion.

@postlund @michalmo Is there a way we can move this PR forward? If so, what needs to be happen? Or should we close this addition for now?

../Frenck

@michalmo
Copy link
Copy Markdown
Contributor Author

@postlund @michalmo Is there a way we can move this PR forward? If so, what needs to be happen? Or should we close this addition for now?

I'm available again to complete this, after a period of inactivity during the summer. I'm still motivated to get this in, since I'm already relying on this locally in automations.

I need to resolve which devices need to be excluded from this, and add the required feature flagging. I'll create a ticket in the pyatv repo and move the discussion there.

Other than that @postlund suggested that a core dev should have a look too, which could be done now (since only better feature flagging needs to be added), or after I update this PR.

@github-actions
Copy link
Copy Markdown

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions Bot added the stale label Dec 10, 2023
@github-actions github-actions Bot closed this Dec 17, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 18, 2023
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.

3 participants