postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
839 stars 91 forks source link

ScreenSaver Activation Fails #2139

Open Ghawken opened 10 months ago

Ghawken commented 10 months ago

Describe the bug

Hi Thanks for ongoing work. Testing out activate ScreenSaver on AppleTV 4k Gen 2 OS 16.6 & Fails with below appearing the relevant exception logging

Error log

Traceback (most recent call last):
  File "plugin.py", line 507, in _exec_command
    value = await tmp(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/core/facade.py", line 190, in screensaver
    return await self.relay("screensaver")()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/__init__.py", line 349, in screensaver
    await self._press_button(HidCommand.Screensaver)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/__init__.py", line 357, in _press_button
    await self.api.hid_command(False, command)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/api.py", line 279, in hid_command
    await self._send_command(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/api.py", line 174, in _send_command
    raise exceptions.ProtocolError(f"Command {identifier} failed") from ex
pyatv.exceptions.ProtocolError: Command _hidC failed

   appleTV Plugin Debug            
Exc_info: (<class 'pyatv.exceptions.ProtocolError'>, ProtocolError('Command _hidC failed'), <traceback object at 0x116381dc0>) 
Exc_Text: Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/api.py", line 163, in _send_command
    resp = await self._protocol.exchange_opack(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/protocol.py", line 157, in exchange_opack
    return await self._exchange_generic_opack(frame_type, data, identifier, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/protocol.py", line 170, in _exchange_generic_opack
    unpacked_object = await self._queues[identifier].wait(timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/support/collections.py", line 130, in wait
    await asyncio.wait_for(self._event.wait(), timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "plugin.py", line 507, in _exec_command
    value = await tmp(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/core/facade.py", line 190, in screensaver
    return await self.relay("screensaver")()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/__init__.py", line 349, in screensaver
    await self._press_button(HidCommand.Screensaver)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/__init__.py", line 357, in _press_button
    await self.api.hid_command(False, command)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/api.py", line 279, in hid_command
    await self._send_command(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pyatv/protocols/companion/api.py", line 174, in _send_command
    raise exceptions.ProtocolError(f"Command {identifier} failed") from ex
pyatv.exceptions.ProtocolError: Command _hidC failed 
Stack_info: None

How to reproduce the bug?

Run Active Screen Saver Command

What is expected behavior?

Screen Saver Activates

Operating System

macOS

Python

3.10

pyatv

0.13.4

Device

AppleTV 4k Gen 2 OS 16.6

Additional context

Thanks!

postlund commented 10 months ago

Does this always fail for you? I have seen similar issues in case my TV is not on, I.e. no HDMI output. But it seems to normally work otherwise.

Ghawken commented 10 months ago

Yeah - it does seem to. Have tried with 2 different appleTV devices, and this particularly one quite a bit.

Initally thought maybe was because was already on screensaver, but checked and wasn’t that. Just checked now, is on, select App worked, and then screensaver activate - same error. Other companion remote commands work.

Not an OS16 thing?