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 sample_bytes to media player supported format and a test #955

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aioesphomeapi/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ message MediaPlayerSupportedFormat {
uint32 sample_rate = 2;
uint32 num_channels = 3;
MediaPlayerFormatPurpose purpose = 4;
uint32 sample_bytes = 5;
}
message ListEntitiesMediaPlayerResponse {
option (id) = 63;
Expand Down
388 changes: 194 additions & 194 deletions aioesphomeapi/api_pb2.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions aioesphomeapi/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ class MediaPlayerSupportedFormat(APIModelBase):
default=MediaPlayerFormatPurpose.DEFAULT,
converter=MediaPlayerFormatPurpose.convert,
)
sample_bytes: int = 0

@classmethod
def convert_list(cls, value: list[Any]) -> list[MediaPlayerSupportedFormat]:
Expand Down
30 changes: 30 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
ListEntitiesValveResponse,
LockStateResponse,
MediaPlayerStateResponse,
MediaPlayerSupportedFormat,
NumberStateResponse,
SelectStateResponse,
SensorStateResponse,
Expand Down Expand Up @@ -651,3 +652,32 @@ async def test_bluetooth_gatt_services_from_dict() -> None:
assert BluetoothGATTDescriptorModel.from_dict(
{"uuid": [1, 3], "handle": 3},
) == BluetoothGATTDescriptorModel(uuid=[1, 3], handle=3)


def test_media_player_supported_format_convert_list() -> None:
"""Test list conversion for MediaPlayerSupportedFormat."""
assert MediaPlayerInfo.from_dict(
{
"supports_pause": False,
"supported_formats": [
{
"format": "flac",
"sample_rate": 48000,
"num_channels": 2,
"purpose": 1,
"sample_bytes": 2,
}
],
}
) == MediaPlayerInfo(
supports_pause=False,
supported_formats=[
MediaPlayerSupportedFormat(
format="flac",
sample_rate=48000,
num_channels=2,
purpose=1,
sample_bytes=2,
)
],
)
Loading