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 media_player platform to Android TV Remote #91677

Merged
merged 21 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove direction parameter from _send_key_commands
  • Loading branch information
Drafteed committed Apr 28, 2023
commit 45f82278e8af3f193b5044bf466479ec28a00660
4 changes: 2 additions & 2 deletions homeassistant/components/androidtv_remote/entity.py
Drafteed marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def _send_launch_app_command(self, app_link: str) -> None:
) from exc

async def _send_key_commands(
Drafteed marked this conversation as resolved.
Show resolved Hide resolved
self, key_codes: list[str], direction: str = "SHORT", delay: float = 0.1
self, key_codes: list[str], delay: float = 0.1
) -> None:
"""Send key press sequence to Android TV."""
try:
for index, key_code in enumerate(key_codes):
self._api.send_key_command(key_code, direction)
self._api.send_key_command(key_code)
if index != (len(key_codes) - 1):
Drafteed marked this conversation as resolved.
Show resolved Hide resolved
await asyncio.sleep(delay)
except ConnectionClosed as exc:
Expand Down
8 changes: 4 additions & 4 deletions tests/components/androidtv_remote/test_media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async def test_media_player_volume_set(
blocking=True,
)

mock_api.send_key_command.assert_called_with("VOLUME_UP", "SHORT")
mock_api.send_key_command.assert_called_with("VOLUME_UP")
assert mock_api.send_key_command.call_count == 3
mock_api.send_key_command.reset_mock()

Expand All @@ -174,7 +174,7 @@ async def test_media_player_volume_set(
blocking=True,
)

mock_api.send_key_command.assert_called_with("VOLUME_DOWN", "SHORT")
mock_api.send_key_command.assert_called_with("VOLUME_DOWN")
assert mock_api.send_key_command.call_count == 2


Expand Down Expand Up @@ -260,8 +260,8 @@ async def test_media_player_play_media(
blocking=True,
)
assert mock_api.send_key_command.mock_calls == [
call("4", "SHORT"),
call("5", "SHORT"),
call("4"),
call("5"),
]

assert await hass.services.async_call(
Drafteed marked this conversation as resolved.
Show resolved Hide resolved
Expand Down