postlund / pyatv

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

How do I pair a homepod mini? #1170

Closed xpnewmedia closed 3 years ago

xpnewmedia commented 3 years ago

This is what I've tried.

atvremote -s x.x.x.x --debug --protocol companion pair 

Output:

2021-06-23 15:26:04 DEBUG [pyatv.support.knock]: Knocking at ports [3689, 7000, 49152, 32498] on 10.x.x.x
2021-06-23 15:26:04 DEBUG [pyatv.support.scan]: Auto-discovered Bedroom at 10.x.x.x:49152 (Protocol.Companion)
2021-06-23 15:26:04 DEBUG [pyatv.support.scan]: Auto-discovered Bedroom at 10.x.x.x:7000 (Protocol.AirPlay)
2021-06-23 15:26:04 DEBUG [pyatv.support.scan]: Auto-discovered Bedroom at 10.x.x.x:7000 (Protocol.RAOP)
2021-06-23 15:26:04 DEBUG [pyatv.companion.pairing]: Start pairing Companion
2021-06-23 15:26:04 DEBUG [pyatv.companion.connection]: Connected to companion device 10.x.x.x:49152
2021-06-23 15:26:04 DEBUG [pyatv.companion.protocol]: Companion credentials: None
2021-06-23 15:26:04 DEBUG [pyatv.companion.protocol]: Send OPACK: {'_pd': b'\x00\x01\x00\x06\x01\x01', '_pwTy': 1}
2021-06-23 15:26:04 DEBUG [pyatv.companion.connection]: >> Send data (Data=e2435f706476000100060101455f7077547909, FrameType=03)
2021-06-23 15:26:09 ERROR [root]: Pairing failed
Traceback (most recent call last):
  File "xxx\x\x\x\x\asyncio\locks.py", line 413, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\x\x\x\x\xasyncio\tasks.py", line 492, in wait_for
    fut.result()
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "c:\x\x\x\lib\site-packages\pyatv\support\__init__.py", line 33, in error_handler
    return await func(*args, **kwargs)
  File "c:\xxxxxxxxxxxxxxxxxxxxxxe-packages\pyatv\companion\auth.py", line 53, in start_pairing
    resp = await self.protocol.exchange_opack(
  File "c:\xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\pyatv\companion\protocol.py", line 72, in exchange_opack
    _, payload = await self.connection.exchange(
  File "c:\xxxxxxxxxxxxxxxxxxxxxxx\on39\lib\site-packages\pyatv\companion\connection.py", line 102, in exchange
    await asyncio.wait_for(semaphore.acquire(), timeout)
  File "c:     python\python39\lib\asyncio\tasks.py", line 494, 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 "c:\xxxxxxxxxxxxxxxxxxxxxxxxxxxckages\pyatv\scripts\atvremote.py", line 174, in pair
    await self._perform_pairing(pairing)
  File "c:\xxxxxxxxxxxxxxxxxxxxxxxpackages\pyatv\scripts\atvremote.py", line 184, in _perform_pairing
    await pairing.begin()
  File "c:xxxxxxxxxxxxxxxxxxxxkages\pyatv\companion\pairing.py", line 52, in begin
    await error_handler(
  File "c:\xxxxxxxxxxxxxxxxxxxxxxxxxx\pyatv\support\__init__.py", line 35, in error_handler
    raise exceptions.ConnectionFailedError(str(ex)) from ex
pyatv.exceptions.ConnectionFailedError
2021-06-23 15:26:09 DEBUG [pyatv.companion.connection]: Closing connection
2021-06-23 15:26:09 DEBUG [pyatv.companion.connection]: Connection lost to remote device: None
postlund commented 3 years ago

You don't need to pair with the HomePod, it's not supported for any protocol right now. Streaming works without it and there's no features in the Companion protocol that pyatv supports for HomePod. Companion is interesting, but we haven't figured out a way to pair with it. It's possible to extract credentials from the keychain on a Mac. But as I said, there's no features in pyatv that utilizes Companion for the HomePod so you don't gain anything from it.

I'll see if I can clarify which protocols that can be paired in the documentation. There's definitely a gap.