postlund / pyatv

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

atvscript push_updates - output_devices is not supported #2396

Open stevemac00 opened 2 weeks ago

stevemac00 commented 2 weeks ago

Describe the bug

atvscript -s 10.0.1.29 push_updates throws error immediately. Goal was to use this update to know if a movie started from atv.launch(deeplink)

Error log

Traceback (most recent call last):\n  
File "python3.11/site-packages/pyatv/scripts/atvscript.py", line 393, in appstart\n args.output(await _handle_command(args, abort_sem, storage, loop)),\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File ".appdevel/venv/lib/python3.11/site-packages/pyatv/scripts/atvscript.py", line 275, in _handle_command\n    return await _run_command(atv, args, abort_sem, loop)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File ".appdevel/venv/lib/python3.11/site-packages/pyatv/scripts/atvscript.py", line 308, in _run_command\n    audio_listener.outputdevices_update([], atv.audio.output_devices)\n                                            ^^^^^^^^^^^^^^^^^^^^^^^^\n  File ".appdevel/venv/lib/python3.11/site-packages/pyatv/support/shield.py", line 72, in _guard_method\n    return func(self, *args, **kwargs)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File "appdevel/venv/lib/python3.11/site-packages/pyatv/core/facade.py", line 484, in output_devices\n    return self.relay("output_devices")\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File ".appdevel/venv/lib/python3.11/site-packages/pyatv/core/relayer.py", line 90, in relay\n    instance = self._find_instance(\n               ^^^^^^^^^^^^^^^^^^^^\n  File ".appdevel/venv/lib/python3.11/site-packages/pyatv/core/relayer.py", line 114, in _find_instance\n    raise exceptions.NotSupportedError(f"{target} is not supported")\npyatv.exceptions.NotSupportedError: output_devices is not supported\n"}

How to reproduce the bug?

command line above

What is expected behavior?

something else

Operating System

macOS

Python

Other

pyatv

0.14.5

Device

Model/SW: Apple TV 4, tvOS 17.4

Additional context

Unsure what else is relevant. Been working with pyatv now for couple months in a dedicate python app to perform analysis on output (OCR, etc) and worked around any minor issue.

postlund commented 2 weeks ago

You are probably lacking credentials for any protocols supporting push updates. Try atvremote wizard, pick your device, follow the instructions and let me know if it works.

stevemac00 commented 2 weeks ago

conf.set_credentials(pyatv.protocols.Protocol.Companion, creds) returns True in my app and other atv methods work. Is there a different protocol that needs creds?

class KeyboardListener(pyatv.interface.KeyboardListener): def focusstate_update(self, old, new): g.logger.critical(f'LISTEN Focus state changed from {old} to {new}')

tv.keyboard.listener = KeyboardListener()

I get nothing in my app so thought I'd try doing things with atvremote (again has creds and works) and see callbacks with atvscript push_updates but I get nothing there either. Most things I have working except for the unavailable.

On May 1, 2024, at 14:01, Pierre Ståhl @.***> wrote:

You are probably lacking credentials for any protocols supporting push updates. Try atvremote wizard, pick your device, follow the instructions and let me know if it works.

— Reply to this email directly, view it on GitHub https://github.com/postlund/pyatv/issues/2396#issuecomment-2088850512, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECHBYBGFRF3C6AEGLXHOLTZAEUVZAVCNFSM6AAAAABHARZJ4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBYHA2TANJRGI. You are receiving this because you authored the thread.

stevemac00 commented 2 weeks ago

You are probably lacking credentials for any protocols supporting push updates. Try atvremote wizard, pick your device, follow the instructions and let me know if it works.

There's no question I have credentials because I can launch_app and any remove_control, etc. (wizard was first thing I did a month or so ago to snag the creds). My intention was to try atvscript push_updates while using atvremote to test.

I still can't get it to report in my app either (see above reply).

And here's my current code (gleaned from scripts).

creds = config[ipKey]['creds']
for protocol in Protocol:
    name = protocol.name.lower()
    logger.debug(f"protocol={protocol}, name={name}")
    if protocol in (Protocol.Companion, Protocol.RAOP):
        credsResult[name] = conf.set_credentials(protocol, creds[name])
atv = await pyatv.connect(conf, g.evtloop)
atv.listener = DeviceListener()
atv.power.listener = PowerListener()
if atv.features.in_state(FeatureState.Available, FeatureName.PushUpdates):
    atv.push_updater.listener = PushListener()