Skip to content

Unable to pair Apple TV Gen 2 #2789

@jeffbrl

Description

@jeffbrl

First off, thank you to the devs for sharing this software and writing top-notch documentation.

Observations

I am unable to pair my device. In its Airplay settings, I have it configured to use the Onscreen Code for pairing. The code displays on the screen but pyatv encounter tracebacks.

$ atvremote wizard
Looking for devices...
Found the following devices:
    Name            Model           Address
--  --------------  --------------  --------------
 1  atvg2           Apple TV 2      192.168.x.xxx
 2  Basement TV     XR-75X90K       192.168.x.xxx
 3  Marantz SR5012  Marantz SR5012  192.168.x.xxx
Enter index of device to set up (q to quit): 1
Starting to set up atvg2
Starting to pair Protocol.AirPlay
Traceback (most recent call last):
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/support/__init__.py", line 71, in error_handler
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/protocols/airplay/auth/legacy.py", line 40, in start_pairing
    await self.http.post("/pair-pin-start", headers=_AIRPLAY_HEADERS)
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/support/http.py", line 433, in post
    return await self.send_and_receive(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/support/http.py", line 490, in send_and_receive
    raise exceptions.AuthenticationError("not authenticated")
pyatv.exceptions.AuthenticationError: not authenticated

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

Traceback (most recent call last):
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/scripts/atvremote.py", line 998, in _run_application
    return await cli_handler(loop)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/scripts/atvremote.py", line 721, in cli_handler
    return await _exec_command(glob_cmds, args.command[0], print_result=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/scripts/atvremote.py", line 965, in _exec_command
    value = await tmp(*args)
            ^^^^^^^^^^^^^^^^
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/scripts/atvremote.py", line 287, in wizard
    await self._wizard_pair(conf, service)
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/scripts/atvremote.py", line 342, in _wizard_pair
    await pairing.begin()
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/protocols/airplay/pairing.py", line 59, in begin
    return await error_handler(
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/jeffl/pyatv/venv/lib/python3.11/site-packages/pyatv/support/__init__.py", line 77, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError: not authenticated

>>> An error occurred, full stack trace above
2025-11-19 19:43:51 ERROR [asyncio]: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f453293de10>
$

Additional info

Model: MC572LL/A
Apple TV Software: 5.3 (1605)
Activation: Failed

Packet capture attached.

cap.zip

I can successfully cast music to this device from TuneBlade in Windows 11.

FWIW, I'm not able to activate Home Sharing for reasons unknown. Not sure if that might be related.

I encounter the same error when attempting to integrate the ATV in Home Assistant, which is what led me to this repo.

The device has been jailbroken with seas0npass. If the devs can't offer support on modified devices, I get it. I can close the issue in that case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions