Skip to content

media_player add off on capability #1092

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

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

rwrozelle
Copy link

@rwrozelle rwrozelle commented Feb 28, 2025

Extends the media_player to additional features. supports_turn_off_on

Copy link
Contributor

coderabbitai bot commented Feb 28, 2025

## Walkthrough

The changes update both the protocol buffer definitions and the Python model for media player functionality. Three new states and several new commands are added to the `MediaPlayerState` and `MediaPlayerCommand` enums, respectively. The protocol message `ListEntitiesMediaPlayerResponse` and its corresponding Python dataclass `MediaPlayerInfo` are extended with a new boolean field indicating support for turning the media player on or off. These updates expand the representable states, commands, and capabilities for media player entities in the API.

## Changes

| File                    | Change Summary                                                                                                                  |
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| aioesphomeapi/api.proto | Added new states to `MediaPlayerState` enum, new commands to `MediaPlayerCommand` enum, and a `supports_turn_off_on` field to `ListEntitiesMediaPlayerResponse` message. |
| aioesphomeapi/model.py  | Added corresponding new states and commands to Python enums, and a `supports_turn_off_on` attribute to the `MediaPlayerInfo` dataclass.                                 |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant API
    participant MediaPlayer

    Client->>API: ListEntitiesMediaPlayer
    API->>MediaPlayer: Query capabilities
    MediaPlayer-->>API: States, commands, supports_turn_off_on
    API-->>Client: ListEntitiesMediaPlayerResponse (includes supports_turn_off_on, new states/commands)

Suggested labels

new-feature


<!-- walkthrough_end -->

<!-- announcements_start -->

> [!NOTE]
> <details>
> <summary>⚡️ AI Code Reviews for VS Code, Cursor, Windsurf</summary>
> 
> CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
> Learn more [here](http://coderabbit.ai/ide).
> 
> </details>

---

> [!NOTE]
> <details>
> <summary>⚡️ Faster reviews with caching</summary>
> 
> CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure `Review - Disable Cache` at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the `Data Retention` setting under your Organization Settings.
> Enjoy the performance boost—your workflow just got faster.
> 
> </details>

<!-- announcements_end -->

---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 361541519fbe7130b2145a0ab55f192dc11ea3b8 and edd1ec2d8981e72df10deb57f9f4860340a18504.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `aioesphomeapi/api.proto` (2 hunks)
* `aioesphomeapi/model.py` (3 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (2)</summary>

* aioesphomeapi/model.py
* aioesphomeapi/api.proto

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACI2Wng0AH1uLzRZSnRaenwAMxz+LAY0bhV4L3VZaMgAdzRkBwFmdRp6OTDYD2xEDIpqinwALxIfD0x6VHglDHEc+Ci6yAxHAQyARgAGAE4AJg1IAElQoqwV9AYGaW76anaPHPwffGr4DCJIAFUbABkuWFxcbiIDgAemBRHUsGwAg0TGYwOk3FgLBIwO0+ARSLYxXgwO43i8wI2Ow0bg6kCUiAYFHg3HE+CwuVunh8fkCwUQoQ51Gk7Ru6kgJAAHjQMLRkLgyXEEslUuk+LDuPT2GF8Jl4nSMGhfDkSNR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pm52CBFmwIyBrB7BcSCSampiASki8cMitiKOii9ATi0wXAVAri6OHiuiGUBiagviOgYi5iq+IUiQkw0YcMCMdAiQV4oQ/i5RAgAcKgFw2wAcM0KgWqtA6wWqJA2wGE2wOQVcmwJAVcWQ80tAM0Kw6wqw80VcaAJAM0VcJiZiEi/sAc80M0i0UcixWqVcOQ8xDA6wM0WqmwM0AcKxAgVc6wtA2wWqaAqwOQAgmwVci0WqqwmwvoZRmxi0M0IxCxaAUcmw80Agi0tAmwFxogjxogAgDAFx2wJAWqWq5wAcOsKgaAdcfxEA/sVcAgjx6wVcqwi0qwDArxexDAAcDAtAOQOxnRkJsxAcQxSxOotAixFJ6xBg5RqxM0pJAgWqi080rxRcpxLJi0i0JAAci0kxfR1chJYxi0KgOQM0mwOQQcuJkiGpOp2wMxnR80WqIpWq2wmw6wRQJACx2wi0KwrCCxOQnRiJGwAg3J5RmwiJaAqxepWqxJ0xVcRQkx/R6pZJFw80GJYZAc7pi0WwzprpmxuxqwVc80iZ3xrxKJye6whJCxSx6wKgVcRx3xepDABsuozJcZeJdAtAqwsJtAkZAc1ZJpdJGwSgtxWqOQ6pYZ0ZC0uZgcdxOJCRPJmx1Y6gVRYoiQtROK9RUi6xQAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=esphome/aioesphomeapi&utm_content=1092):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link

codspeed-hq bot commented Feb 28, 2025

CodSpeed Performance Report

Merging #1092 will not alter performance

Comparing rwrozelle:media_player_all_features (feb7c7f) with main (592ca6f)

Summary

✅ 11 untouched benchmarks

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (592ca6f) to head (feb7c7f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1092   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines         2935      2948   +13     
=========================================
+ Hits          2935      2948   +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d803269 and b8abce2.

📒 Files selected for processing (3)
  • aioesphomeapi/api.proto (4 hunks)
  • aioesphomeapi/client.py (2 hunks)
  • aioesphomeapi/model.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**`: - Do not generate or add any sequence diagrams

**: - Do not generate or add any sequence diagrams

  • aioesphomeapi/client.py
  • aioesphomeapi/api.proto
  • aioesphomeapi/model.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: py 3.12 on windows-latest (skip_cython)
🔇 Additional comments (8)
aioesphomeapi/client.py (1)

1232-1260: New media player command parameters look good.

The additions of enqueue and group_members parameters to the media_player_command method are well-implemented, with proper optional typing and conditional flag setting. The implementation follows the same pattern as the existing parameters.

aioesphomeapi/api.proto (4)

1127-1159: Media player state and command enums expanded appropriately.

The new states and commands enhance the media player functionality as described in the PR objectives, adding support for announcements, power control, track navigation and playback controls.


1190-1193: Support flags for new media player capabilities.

The new boolean capability flags correctly implement the planned functionality additions: turning media players on/off, grouping players together, and navigating between tracks.


1203-1210: Enhanced media player state attributes.

The additional fields for song metadata and playback state provide much more detailed information about currently playing media, which will greatly improve the user experience.


1231-1236: Command request fields for new functionality.

The enqueue and group_members fields enable the new features and follow the same pattern as existing command parameters with appropriate has_* flags.

aioesphomeapi/model.py (3)

813-816: Media player state enum values correctly added.

The new state enum values match the protocol definitions and enable the new functionality.


872-875: Media player info capability flags properly added.

These flags correctly correspond to the new fields in the ListEntitiesMediaPlayerResponse message.


891-899: Media player state information significantly enhanced.

The new attributes in MediaPlayerEntityState provide rich metadata about media playback, matching the protocol definition.

Comment on lines 825 to 840
TOGGLE = 5
VOLUME_UP = 6
VOLUME_DOWN = 7
ENQUEUE = (8,)
REPEAT_ONE = (9,)
REPEAT_OFF = (10,)
CLEAR_PLAYLIST = (11,)
NEXT_TRACK = (12,)
PREVIOUS_TRACK = (13,)
TURN_ON = (14,)
TURN_OFF = (15,)
SHUFFLE = (16,)
UNSHUFFLE = (17,)
REPEAT_ALL = (18,)
JOIN = (19,)
UNJOIN = (20,)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix tuple syntax in MediaPlayerCommand enum values.

There's a syntax error in how the new commands are defined - they're incorrectly using tuple syntax with trailing commas instead of simple integer values.

Apply this diff to fix the syntax:

    TOGGLE = 5
    VOLUME_UP = 6
    VOLUME_DOWN = 7
-   ENQUEUE = (8,)
-   REPEAT_ONE = (9,)
-   REPEAT_OFF = (10,)
-   CLEAR_PLAYLIST = (11,)
-   NEXT_TRACK = (12,)
-   PREVIOUS_TRACK = (13,)
-   TURN_ON = (14,)
-   TURN_OFF = (15,)
-   SHUFFLE = (16,)
-   UNSHUFFLE = (17,)
-   REPEAT_ALL = (18,)
-   JOIN = (19,)
-   UNJOIN = (20,)
+   ENQUEUE = 8
+   REPEAT_ONE = 9
+   REPEAT_OFF = 10
+   CLEAR_PLAYLIST = 11
+   NEXT_TRACK = 12
+   PREVIOUS_TRACK = 13
+   TURN_ON = 14
+   TURN_OFF = 15
+   SHUFFLE = 16
+   UNSHUFFLE = 17
+   REPEAT_ALL = 18
+   JOIN = 19
+   UNJOIN = 20

The current implementation with tuple values would cause runtime errors when converting between Python enums and protocol enum values.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
TOGGLE = 5
VOLUME_UP = 6
VOLUME_DOWN = 7
ENQUEUE = (8,)
REPEAT_ONE = (9,)
REPEAT_OFF = (10,)
CLEAR_PLAYLIST = (11,)
NEXT_TRACK = (12,)
PREVIOUS_TRACK = (13,)
TURN_ON = (14,)
TURN_OFF = (15,)
SHUFFLE = (16,)
UNSHUFFLE = (17,)
REPEAT_ALL = (18,)
JOIN = (19,)
UNJOIN = (20,)
TOGGLE = 5
VOLUME_UP = 6
VOLUME_DOWN = 7
ENQUEUE = 8
REPEAT_ONE = 9
REPEAT_OFF = 10
CLEAR_PLAYLIST = 11
NEXT_TRACK = 12
PREVIOUS_TRACK = 13
TURN_ON = 14
TURN_OFF = 15
SHUFFLE = 16
UNSHUFFLE = 17
REPEAT_ALL = 18
JOIN = 19
UNJOIN = 20

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
aioesphomeapi/model.py (2)

873-875: Consider renaming for clarity.

supports_turn_off_on might be more consistent if named supports_turn_on_off or supports_power_toggle to match reading order and be more descriptive. This is a minor naming nitpick but can improve clarity.


891-899: Consider using strong types for repeat/shuffle/timing fields.

Storing repeat as a string and duration/position as integers can work, but using dedicated enums (for repeat/shuffle) or floats (for more precise timing) can improve type safety and clarity. Otherwise, please ensure robust validation for string-based repeat values.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8abce2 and 18436fa.

📒 Files selected for processing (1)
  • aioesphomeapi/model.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**`: - Do not generate or add any sequence diagrams

**: - Do not generate or add any sequence diagrams

  • aioesphomeapi/model.py
🔇 Additional comments (2)
aioesphomeapi/model.py (2)

814-816: Check for feature usage of newly introduced states.

These new states (OFF, ON, and ANNOUNCING) appear valid. Please ensure they are handled throughout the codebase wherever a media player state might be set or interpreted, so that existing code that expects only IDLE, PLAYING, or PAUSED does not encounter unexpected behavior.


825-840: All new commands are well-structured and consistent.

Thank you for fixing the previous tuple-related syntax. These commands integrate well with the existing MediaPlayerCommand pattern.

@bdraco bdraco added the waiting-for-esphome Indicates the PR is waiting for the esphome main repo code approval label Feb 28, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
aioesphomeapi/client.py (1)

1231-1262: Consider adding documentation for the new parameters

The method lacks docstring documentation explaining what the new parameters do. Adding documentation would improve developer experience and code maintenance.

 def media_player_command(
     self,
     key: int,
     *,
     command: MediaPlayerCommand | None = None,
     volume: float | None = None,
     media_url: str | None = None,
     announcement: bool | None = None,
     enqueue: str | None = None,
     group_members: str | None = None,
 ) -> None:
+    """Send a command to a media player.
+
+    Args:
+        key: The key identifying the media player.
+        command: The command to send to the media player.
+        volume: The volume to set on the media player.
+        media_url: The URL of media to play.
+        announcement: Whether this is an announcement.
+        enqueue: The enqueue option for the media player.
+        group_members: The group members for the media player when operating in group mode.
+    """
     req = MediaPlayerCommandRequest(key=key)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 15b2705 and 35316b7.

📒 Files selected for processing (1)
  • aioesphomeapi/client.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**`: - Do not generate or add any sequence diagrams

**: - Do not generate or add any sequence diagrams

  • aioesphomeapi/client.py
🔇 Additional comments (2)
aioesphomeapi/client.py (2)

1239-1240: Method signature enhancement for extended media player functionality

The addition of enqueue and group_members parameters aligns well with the PR objectives, enabling support for the media player enqueueing functionality and grouping capabilities.


1255-1260: Implementation follows consistent parameter handling pattern

The implementation for the new parameters follows the established pattern in the codebase, properly checking for None values before setting the request attributes and their corresponding flags.

@bdraco bdraco closed this Apr 14, 2025
@bdraco bdraco reopened this Apr 14, 2025
@bdraco
Copy link
Member

bdraco commented Apr 14, 2025

close/reopen to restart CI to fix codspeed settings

@rwrozelle rwrozelle changed the title media_player_all_features media_player add off on capability Apr 15, 2025
@bdraco
Copy link
Member

bdraco commented Apr 29, 2025

Is there a PR on the main ESPhome repo to accompany this PR? If so please link it in the opening text as we need that one to be approved before this can merge

@rwrozelle
Copy link
Author

I have the code, but have not sent in a PR for it, I will work on that.

@paco3346
Copy link

paco3346 commented May 4, 2025

I'm about to submit a PR that's inclusive of all these changes (and adds a few more).

@rwrozelle
Copy link
Author

@paco3346 Just let me know and I'll review them instead of submitting the additional PRs in esphome, core, and esphome-docs.

@paco3346
Copy link

paco3346 commented May 8, 2025

I had this fully working on 2023.11 but let it run on my home HA server for the last ~18 months and fell behind on versions. I'm getting it working for 2025.4 locally and then I'll submit PRs. I go on paternity leave this coming week so I'll have more time to work on it come Monday.

@rwrozelle
Copy link
Author

@paco3346 Are you still planning on releasing PRs, when do you think this will happen?

@paco3346
Copy link

@paco3346 Are you still planning on releasing PRs, when do you think this will happen?

Yes, I am. I got everything working again against the latest changes but I'm fleshing out all of the features so that we don't keep adding actions 1 by 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-esphome Indicates the PR is waiting for the esphome main repo code approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants