-
Notifications
You must be signed in to change notification settings - Fork 68
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
Extend Functionality of Media_Player #911
base: main
Are you sure you want to change the base?
Conversation
The ESP Media_Player needs optional supports for Next/Previous Track and Turn Off/On. That way a subclass of Media_Player can use these options to have the Media card display those widgets.
Add Clear, Enqueue, Repeat, and Shuffle
Reverting back
Fix Enqueue, was incorrect from prior commit.
Important Review skippedReview was skipped as selected files did not have any reviewable changes. Files selected but had no reviewable changes (1)
You can disable this status message by setting the WalkthroughThe recent modifications to the Changes
Possibly related PRs
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
Outside diff range, codebase verification and nitpick comments (1)
aioesphomeapi/client.py (1)
1199-1200
: Add parameter descriptions to the docstring.The new parameters
enqueue
andgroup_members
should be documented in the method's docstring to provide clarity on their usage.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, # Add description in docstring group_members: str | None = None, # Add description in docstring ) -> None:
There was a problem hiding this 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
tests/test_client.py
Outdated
dict( | ||
key=1, | ||
has_media_url=True, | ||
media_url="http://example.com" | ||
has_enqueue=True, | ||
enqueue="replace" | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix syntax error in dictionary definition.
There is a missing comma at the end of line 803.
- media_url="http://example.com"
+ media_url="http://example.com",
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.
dict( | |
key=1, | |
has_media_url=True, | |
media_url="http://example.com" | |
has_enqueue=True, | |
enqueue="replace" | |
), | |
dict( | |
key=1, | |
has_media_url=True, | |
media_url="http://example.com", | |
has_enqueue=True, | |
enqueue="replace" | |
), |
Tools
Ruff
804-804: SyntaxError: Expected ',', found name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
( | ||
dict(key=1, media_url="http://example.com", enqueue="replace"), | ||
dict( | ||
key=1, | ||
has_media_url=True, | ||
media_url="http://example.com", | ||
has_enqueue=True, | ||
enqueue="replace", | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix syntax error in dictionary definition.
There is a missing comma at the end of line 803.
- media_url="http://example.com"
+ media_url="http://example.com",
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.
( | |
dict(key=1, media_url="http://example.com", enqueue="replace"), | |
dict( | |
key=1, | |
has_media_url=True, | |
media_url="http://example.com", | |
has_enqueue=True, | |
enqueue="replace", | |
), | |
( | |
dict(key=1, media_url="http://example.com", enqueue="replace"), | |
dict( | |
key=1, | |
has_media_url=True, | |
media_url="http://example.com", | |
has_enqueue=True, | |
enqueue="replace", | |
), |
tests/test_client.py
Outdated
+ key=1, | ||
+ command=MediaPlayerCommand.JOIN, | ||
+ group_members="media_player.media_player_2,", | ||
), | ||
dict( | ||
+ key=1, | ||
+ has_command=True, | ||
+ command=MediaPlayerCommand.JOIN, | ||
+ has_group_members=True, | ||
+ group_members="media_player.media_player_2,", | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix syntax error in dictionary definition.
There are several syntax errors in the dictionary definition. Ensure that each key-value pair is separated by a comma.
- key=1,
- command=MediaPlayerCommand.JOIN,
- group_members="media_player.media_player_2,",
+ key=1,
+ command=MediaPlayerCommand.JOIN,
+ group_members="media_player.media_player_2",
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.
+ key=1, | |
+ command=MediaPlayerCommand.JOIN, | |
+ group_members="media_player.media_player_2,", | |
), | |
dict( | |
+ key=1, | |
+ has_command=True, | |
+ command=MediaPlayerCommand.JOIN, | |
+ has_group_members=True, | |
+ group_members="media_player.media_player_2,", | |
), | |
key=1, | |
command=MediaPlayerCommand.JOIN, | |
group_members="media_player.media_player_2", | |
), | |
dict( | |
key=1, | |
has_command=True, | |
command=MediaPlayerCommand.JOIN, | |
has_group_members=True, | |
group_members="media_player.media_player_2,", | |
), |
Tools
Ruff
824-824: SyntaxError: Expected a parameter name
825-825: SyntaxError: Expected a parameter name
825-825: SyntaxError: Duplicate keyword argument ""
826-826: SyntaxError: Expected a parameter name
826-826: SyntaxError: Duplicate keyword argument ""
829-829: SyntaxError: Expected a parameter name
830-830: SyntaxError: Expected a parameter name
830-830: SyntaxError: Duplicate keyword argument ""
831-831: SyntaxError: Expected a parameter name
831-831: SyntaxError: Duplicate keyword argument ""
832-832: SyntaxError: Expected a parameter name
832-832: SyntaxError: Duplicate keyword argument ""
833-833: SyntaxError: Expected a parameter name
833-833: SyntaxError: Duplicate keyword argument ""
There was a problem hiding this 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
Outside diff range, codebase verification and nitpick comments (1)
aioesphomeapi/client.py (1)
Line range hint
1203-1224
: Refactor suggestion formedia_player_command
method.The addition of
enqueue
andgroup_members
parameters is handled correctly. However, the method is quite lengthy and handles many parameters, which increases its complexity. Consider refactoring this method to improve readability and maintainability. Perhaps breaking down the parameter handling into smaller helper functions could make the code cleaner and easier to manage.
( | ||
dict( | ||
key=1, | ||
command=MediaPlayerCommand.JOIN, | ||
group_members="media_player.media_player_2,", | ||
), | ||
dict( | ||
key=1, | ||
has_command=True, | ||
command=MediaPlayerCommand.JOIN, | ||
has_group_members=True, | ||
group_members="media_player.media_player_2,", | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review: Syntax Error and Logic Check for Group Members Parameter
The test case for the media player command with command
and group_members
parameters has a trailing comma in the group_members
string, which might not be necessary unless the API explicitly requires it. This could potentially lead to errors or unexpected behavior when parsing the group members on the receiving end.
Consider removing the trailing comma for clarity and to prevent potential parsing issues:
- group_members="media_player.media_player_2,",
+ group_members="media_player.media_player_2"
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.
( | |
dict( | |
key=1, | |
command=MediaPlayerCommand.JOIN, | |
group_members="media_player.media_player_2,", | |
), | |
dict( | |
key=1, | |
has_command=True, | |
command=MediaPlayerCommand.JOIN, | |
has_group_members=True, | |
group_members="media_player.media_player_2,", | |
), | |
( | |
dict( | |
key=1, | |
command=MediaPlayerCommand.JOIN, | |
group_members="media_player.media_player_2" | |
), | |
dict( | |
key=1, | |
has_command=True, | |
command=MediaPlayerCommand.JOIN, | |
has_group_members=True, | |
group_members="media_player.media_player_2" | |
), |
Updated using Gen Proto files Task in dev container
Generated after merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Outside diff range and nitpick comments (5)
tests/test_client.py (1)
825-837
: Review: Trailing Comma in Group Members ParameterThe test case for the media player command with
command
andgroup_members
parameters has a trailing comma in thegroup_members
string. This might not be necessary unless the API explicitly requires it.Consider removing the trailing comma for clarity and to prevent potential parsing issues:
- group_members="media_player.media_player_2,", + group_members="media_player.media_player_2"Please verify with the API documentation or implementation if the trailing comma is expected and handled correctly.
aioesphomeapi/api_pb2.py (2)
180-194
: The additions look good, with a minor naming nitpick.The new constants significantly expand the available media player commands, which is great.
A few of the constant names deviate slightly from the existing naming convention. Consider renaming:
MEDIA_PLAYER_COMMAND_TURN_ON
→MEDIA_PLAYER_COMMAND_ON
MEDIA_PLAYER_COMMAND_TURN_OFF
→MEDIA_PLAYER_COMMAND_OFF
This will make them more consistent with the existing
MEDIA_PLAYER_COMMAND_*
constants.
185-194
: The additions look good, with a minor naming nitpick.The new constants significantly expand the available media player commands, which is great. The additions include important functionality like playlist management, shuffle/repeat modes, and grouping.
A couple of the constant names deviate slightly from the existing naming convention. Consider renaming:
MEDIA_PLAYER_COMMAND_TURN_ON
→MEDIA_PLAYER_COMMAND_ON
MEDIA_PLAYER_COMMAND_TURN_OFF
→MEDIA_PLAYER_COMMAND_OFF
This will make them more consistent with the other
MEDIA_PLAYER_COMMAND_*
constants.aioesphomeapi/model.py (2)
874-874
: Renamesupports_turn_off_on
tosupports_turn_on_off
for consistencyConsider renaming the attribute
supports_turn_off_on
tosupports_turn_on_off
. The conventional order is "on/off," which enhances readability and aligns with common terminology.Apply this diff to rename the attribute:
-def supports_turn_off_on: bool = False +def supports_turn_on_off: bool = False
897-898
: Clarify units forduration
andposition
attributesThe
duration
andposition
attributes are integers, but the units (e.g., seconds, milliseconds) are not specified. To improve clarity, consider:
- Adding comments to specify the units for
duration
andposition
.- If sub-second precision is needed, using
float
instead ofint
.Example of adding comments:
duration: int = 0 # Duration in seconds position: int = 0 # Position in seconds
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- aioesphomeapi/api.proto (4 hunks)
- aioesphomeapi/api_pb2.py (1 hunks)
- aioesphomeapi/client.py (2 hunks)
- aioesphomeapi/model.py (4 hunks)
- tests/test_client.py (2 hunks)
Additional context used
Path-based instructions (5)
aioesphomeapi/api.proto (1)
Pattern
**
: - Do not generate or add any sequence diagramsaioesphomeapi/api_pb2.py (1)
Pattern
**
: - Do not generate or add any sequence diagramsaioesphomeapi/client.py (1)
Pattern
**
: - Do not generate or add any sequence diagramsaioesphomeapi/model.py (1)
Pattern
**
: - Do not generate or add any sequence diagramstests/test_client.py (1)
Pattern
**
: - Do not generate or add any sequence diagrams
Additional comments not posted (11)
aioesphomeapi/client.py (1)
Line range hint
1210-1231
: LGTM! Verify the callers are updated to use the new parameters.The changes to the
media_player_command
function look good. The new optional parametersenqueue
andgroup_members
are handled correctly by setting the corresponding attributes and boolean flags on theMediaPlayerCommandRequest
object.Please ensure that the callers of this function are updated to provide the new parameters if they intend to use the new media playback options.
Run the following script to verify the usage of the new parameters:
Verification successful
LGTM. Test suite accommodates new parameters. Verify external usage if any.
The changes to the
media_player_command
function are well-implemented. Our search found that:
- The test suite in
tests/test_client.py
uses**cmd
to call the function, which allows it to flexibly handle new parameters without requiring changes.- No other internal callers of the function were found in the codebase.
Please ensure any external usage of this function is updated if the new
enqueue
andgroup_members
parameters are needed.Note: The
ast-grep
search unexpectedly returned no results, which might indicate an issue with the tool in the sandbox environment.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify callers of `media_player_command` are updated to use the new parameters. # Test: Search for callers of the function. Expect: Callers are updated if using the new options. rg --type python -A 5 $'media_player_command\('Length of output: 79
Script:
#!/bin/bash # Description: Verify callers of `media_player_command` are updated to use the new parameters. # Search using rg without specifying file type echo "Searching with rg:" rg -n -A 5 'media_player_command\(' # Search using ast-grep for function calls echo "Searching with ast-grep:" ast-grep --lang python --pattern 'media_player_command($_)'Length of output: 1131
tests/test_client.py (2)
801-809
: LGTM!The new test case for the media player command with
media_url
andenqueue
parameters looks good. It correctly verifies the expected request structure and parameter values.
Line range hint
811-824
: Skipped ReviewThe remaining test cases in the
test_media_player_command
function are unchanged. Skipping review as no modifications were made.Also applies to: 838-838
aioesphomeapi/api_pb2.py (4)
172-174
: LGTM!The additions to the
MediaPlayerState
enum look good. The new constants expand the set of possible media player states and follow the existing naming convention.
180-180
: LGTM!The addition of the
MEDIA_PLAYER_COMMAND_TOGGLE
constant looks good. It expands the available media player commands and follows the naming convention.
181-182
: LGTM!The addition of the
MEDIA_PLAYER_COMMAND_VOLUME_UP
andMEDIA_PLAYER_COMMAND_VOLUME_DOWN
constants looks good. They expand the available media player commands with volume control and follow the naming convention.
183-184
: LGTM!The addition of the
MEDIA_PLAYER_COMMAND_NEXT_TRACK
andMEDIA_PLAYER_COMMAND_PREVIOUS_TRACK
constants looks good. They expand the available media player commands with track navigation and follow the naming convention.aioesphomeapi/model.py (2)
894-896
: Ensure string attributes handle Unicode and special charactersThe attributes
artist
,album
, andtitle
should properly handle Unicode characters to support international content.Run the following script to check for proper handling of Unicode strings:
#!/bin/bash # Description: Search for usage of string attributes and ensure Unicode handling # Test: Verify that string attributes use appropriate encoding/decoding rg --type py 'artist|album|title' --files-with-matchesCheck the returned files to ensure that these attributes are consistently handled with correct encoding.
825-840
: Ensure consistency and correctness in new media player commandsThe new commands added to
MediaPlayerCommand
enhance functionality but ensure that:
- All command values are sequential and correctly incremented to prevent any overlapping or missing values.
- The naming conventions align with existing commands for consistency (e.g.,
VOLUME_UP
andVOLUME_DOWN
are appropriate).- The commands are appropriately handled in the corresponding command handling logic elsewhere in the codebase.
To verify the command values and consistency, run the following script:
This script will list all the enum members and their assigned values for manual verification.
Verification successful
This script will help us locate the MediaPlayerCommand enum, extract its values, and check for any gaps in the sequence. Once we have this information, we can verify the consistency and correctness of the new media player commands.
MediaPlayerCommand enum values are sequential and consistent
The verification process confirms that the MediaPlayerCommand enum is correctly implemented:
- All command values are sequential, ranging from 0 to 19, with no gaps or overlapping values.
- Naming conventions align with existing commands, maintaining consistency (e.g., VOLUME_UP, VOLUME_DOWN).
- New commands (CLEAR_PLAYLIST, SHUFFLE, etc.) are appropriately added at the end of the enum, following the existing pattern.
No issues were found in the implementation of the MediaPlayerCommand enum. However, ensure that these new commands are properly handled in the corresponding command handling logic elsewhere in the codebase.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for sequential values in MediaPlayerCommand enum # Test: Ensure enum values are sequential and unique rg --type py --pretty '--class-name=MediaPlayerCommand' --pattern $'class MediaPlayerCommand(APIIntEnum):\n $$$' | sed -n '/^class MediaPlayerCommand/,/^$/p' | grep '='Length of output: 365
Script:
#!/bin/bash # Description: Locate and extract MediaPlayerCommand enum values # Find the MediaPlayerCommand class and extract its content rg -A 30 "class MediaPlayerCommand\(APIIntEnum\):" aioesphomeapi/model.py # Extract only the enum values for easier inspection echo "Enum values:" rg "class MediaPlayerCommand\(APIIntEnum\):" -A 30 aioesphomeapi/model.py | grep -E '^\s+[A-Z_]+ = [0-9]+$' | awk '{print $3}' # Check for gaps in the sequence echo "Checking for gaps in the sequence:" rg "class MediaPlayerCommand\(APIIntEnum\):" -A 30 aioesphomeapi/model.py | grep -E '^\s+[A-Z_]+ = [0-9]+$' | awk '{print $3}' | sort -n | awk '{if (NR>1 && $1 != prev+1) print "Gap found between", prev, "and", $1; prev=$1}'Length of output: 1200
aioesphomeapi/api.proto (2)
1140-1154
: Confirm New Commands inMediaPlayerCommand
Enum are Implemented CorrectlyThe new commands added to the
MediaPlayerCommand
enum significantly enhance the media player's functionality. Ensure that each command is correctly implemented in the system and that there are handlers for these commands where necessary.Run the following script to verify that all new commands have corresponding handlers:
#!/bin/bash # Check for handlers corresponding to new MediaPlayerCommand values new_commands=(MEDIA_PLAYER_COMMAND_TOGGLE MEDIA_PLAYER_COMMAND_VOLUME_UP MEDIA_PLAYER_COMMAND_VOLUME_DOWN MEDIA_PLAYER_COMMAND_NEXT_TRACK MEDIA_PLAYER_COMMAND_PREVIOUS_TRACK MEDIA_PLAYER_COMMAND_TURN_ON MEDIA_PLAYER_COMMAND_TURN_OFF MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST MEDIA_PLAYER_COMMAND_SHUFFLE MEDIA_PLAYER_COMMAND_UNSHUFFLE MEDIA_PLAYER_COMMAND_REPEAT_OFF MEDIA_PLAYER_COMMAND_REPEAT_ONE MEDIA_PLAYER_COMMAND_REPEAT_ALL MEDIA_PLAYER_COMMAND_JOIN MEDIA_PLAYER_COMMAND_UNJOIN) for cmd in "${new_commands[@]}"; do if ! rg "$cmd" --type-add 'cpp:*.[hc]pp' --files-with-matches; then echo "Handler for $cmd not found." fi doneThis script will help identify any commands that may not have corresponding implementations.
1129-1131
: Ensure Consistent Enum Ordering and No Duplicate Values inMediaPlayerState
The addition of
MEDIA_PLAYER_STATE_ANNOUNCING
,MEDIA_PLAYER_STATE_OFF
, andMEDIA_PLAYER_STATE_ON
to theMediaPlayerState
enum extends the media player's state representations. Verify that the enum values are sequential and that there are no duplicate values or conflicts with existing states.Run the following script to check for duplicate enum values:
If the script returns any numbers, it indicates duplicate enum values that need to be addressed.
Verification successful
MediaPlayerState Enum Verified: Correctly Implemented and Extended
The MediaPlayerState enum has been verified, and it is correctly implemented:
- Enum values are sequential (0 to 6) with no gaps.
- No duplicate values or conflicts with existing states.
- New states (ANNOUNCING, OFF, ON) are added at the end, preserving backward compatibility.
The changes to the MediaPlayerState enum are appropriate and do not introduce any issues.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check for duplicate enum values in MediaPlayerState grep -E '^\s*MEDIA_PLAYER_STATE_' aioesphomeapi/api.proto | sed 's/.*= \([0-9]\+\);/\1/' | sort | uniq -dLength of output: 2971
Script:
#!/bin/bash # Display the full MediaPlayerState enum definition sed -n '/enum MediaPlayerState/,/}/p' aioesphomeapi/api.protoLength of output: 315
ANNOUNCING = 4 | ||
OFF = 5 | ||
ON = 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconsider including OFF
and ON
states in MediaPlayerState
The addition of OFF
and ON
states to MediaPlayerState
may blur the distinction between device power states and media playback states. Typically, MediaPlayerState
represents the playback status (e.g., playing, paused). Consider handling power states separately to maintain a clear separation of concerns.
@@ -866,6 +888,14 @@ | |||
default=0.0, converter=fix_float_single_double_conversion | |||
) | |||
muted: bool = False | |||
repeat: str = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an enum for repeat
to ensure type safety
The repeat
attribute in MediaPlayerEntityState
is currently a string. To prevent typos and enforce valid repeat modes, define a MediaPlayerRepeatMode
enum (e.g., OFF
, ONE
, ALL
) and use it for the repeat
attribute.
Define the enum:
class MediaPlayerRepeatMode(APIIntEnum):
OFF = 0
ONE = 1
ALL = 2
Update the repeat
attribute:
-repeat: str = ""
+repeat: MediaPlayerRepeatMode | None = converter_field(
+ default=MediaPlayerRepeatMode.OFF, converter=MediaPlayerRepeatMode.convert
+)
bool supports_turn_off_on = 10; | ||
bool supports_grouping = 11; | ||
bool supports_next_previous_track = 12; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate Field Numbers and Dependency Management in ListEntitiesMediaPlayerResponse
The fields supports_turn_off_on
, supports_grouping
, and supports_next_previous_track
expand the capabilities of the media player entities. Ensure that:
- The field numbers (
10
,11
,12
) do not conflict with existing fields. - The implementation correctly handles scenarios when these features are unsupported by certain devices.
Verify the field numbering and update the documentation to reflect these new capabilities.
string repeat = 5; | ||
bool shuffle = 6; | ||
string artist = 7; | ||
string album = 8; | ||
string title = 9; | ||
int32 duration = 10; | ||
int32 position = 11; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refine Data Types for repeat
, duration
, and position
in MediaPlayerStateResponse
-
Repeat Field: The
repeat
field is currently astring
. It would be more robust to define an enumMediaPlayerRepeatMode
to represent repeat states, enhancing type safety and preventing invalid values. -
Duration and Position Fields: As durations and positions can't be negative, consider using
uint32
instead ofint32
.
-
Define the
MediaPlayerRepeatMode
enum:enum MediaPlayerRepeatMode { MEDIA_PLAYER_REPEAT_OFF = 0; MEDIA_PLAYER_REPEAT_ONE = 1; MEDIA_PLAYER_REPEAT_ALL = 2; }
-
Update the
repeat
field:- string repeat = 5; + MediaPlayerRepeatMode repeat = 5;
-
Change
duration
andposition
to unsigned integers:- int32 duration = 10; - int32 position = 11; + uint32 duration = 10; + uint32 position = 11;
bool has_enqueue = 10; | ||
string enqueue = 11; | ||
|
||
bool has_group_members = 12; | ||
string group_members = 13; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjust Data Types for enqueue
and group_members
Fields in MediaPlayerCommandRequest
-
Enqueue Field: If
enqueue
is intended to handle multiple media URLs, it should be arepeated string
. If it's a single URL, consider renaming it tomedia_url
for clarity. -
Group Members Field: If
group_members
represents multiple members, it should be arepeated string
.
Suggested changes:
-
Update
enqueue
field:- bool has_enqueue = 10; - string enqueue = 11; + bool has_enqueue = 10; + repeated string enqueue = 11;
-
Update
group_members
field:- bool has_group_members = 12; - string group_members = 13; + bool has_group_members = 12; + repeated string group_members = 13;
Ensure that the implementation handles these fields appropriately in the codebase.
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.
bool has_enqueue = 10; | |
string enqueue = 11; | |
bool has_group_members = 12; | |
string group_members = 13; | |
bool has_enqueue = 10; | |
repeated string enqueue = 11; | |
bool has_group_members = 12; | |
repeated string group_members = 13; |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #911 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 2671 2705 +34
=========================================
+ Hits 2671 2705 +34 ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #911 will not alter performanceComparing Summary
|
What does this implement/fix?
Lays the ground work for child components of Media Player to be built with a richer set of capability.
Description
Extends Media Player component to support the following commands in child components:
Traits are extended to include:
Requires the following pull requests:
esphome/esphome-docs#4090
esphome/esphome#7158
home-assistant/core#122799