postlund/pyatv

"atvremote -s <IP> previous" won't go back to the previous page within an app

Opened this issue · 3 comments

Describe the bug

I wonder if "previous" button works as the "<" button on the actual apple tv remote, if so i think it has a bug while within an app - it won't go back to previous page.

Error log

<place log here>

How to reproduce the bug?

To reproduce: hover over any app, send "atvremote -s previous" wont return back to the first app on home page

What is expected behavior?

Expect first app icon being focused with "previous" command sent

Operating System

macOS

Python

3.12

pyatv

atvremote 0.14.5

Device

Model/SW: Apple TV 4K (gen 3), tvOS 17.5.1 build 21L580

Additional context

N/A

previous is a media command (like "previous song"), so I wouldn't expect that to work. Maybe left if it is navigation to the left you mean?

Or maybe menu is what you want.

Marx314 commented

What:
pytv 0.16.0 (docker) on a arm,
appletv 4k tvOS: 18.1 22j580
When I send the previous command I assume it's the same button as the physical remote with the < logo, so should go to the previous menu if I'm already within a sub menu.... I get the included stacktrace

atvremote -s 10.0.0.172 previous --debug

logs
previous-appletv-18.1_22j580_tvOS.log

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/pyatv/protocols/mrp/protocol.py", line 275, in _receive
    await semaphore.acquire()
  File "/usr/local/lib/python3.13/asyncio/locks.py", line 407, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/pyatv/scripts/atvremote.py", line 997, in _run_application
    return await cli_handler(loop)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyatv/scripts/atvremote.py", line 726, in cli_handler
    return await _handle_commands(args, config, storage, loop)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyatv/scripts/atvremote.py", line 876, in _handle_commands
    ret = await _handle_device_command(args, cmd, atv, storage, loop)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyatv/scripts/atvremote.py", line 919, in _handle_device_command
    return await _exec_command(atv.remote_control, cmd, True, *cmd_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyatv/scripts/atvremote.py", line 964, in _exec_command
    value = await tmp(*args)
            ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyatv/core/facade.py", line 97, in previous
    return await self.relay("previous")()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyatv/protocols/mrp/__init__.py", line 402, in previous
    await self._send_command(CommandInfo_pb2.PreviousTrack)
  File "/usr/local/lib/python3.13/site-packages/pyatv/protocols/mrp/__init__.py", line 342, in _send_command
    resp = await self.protocol.send_and_receive(messages.command(command, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyatv/protocols/mrp/protocol.py", line 262, in send_and_receive
    return await self._receive(identifier, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyatv/protocols/mrp/protocol.py", line 274, in _receive
    async with async_timeout.timeout(timeout):
               ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
    ~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError```