question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to configure Apple TV - does not accept PIN

See original GitHub issue

Describe the bug

While trying to add ATV to integration cannot pass the step of entering the PIN, but it is not accepted. Configuration wizard displays message:

Pairing
Pairing is required for the RAOP protocol. Please enter the PIN code displayed on 
screen. Leading zeros shall be omitted, i.e. enter 123 if the displayed code is 0123.
Invalid authentication

After evry retry new PIN is displayed by ATV, but none is accepted by integration. Every retry logs error in homeassistant.log - listed below

Error log

021-12-18 14:39:59 ERROR (MainThread) [custom_components.apple_tv.config_flow] Authentication problem
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pyatv/support/__init__.py", line 33, in error_handler
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/airplay/auth/legacy.py", line 62, in finish_pairing
    await self._send_plist(
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/airplay/auth/legacy.py", line 79, in _send_plist
    return await self.http.post(
  File "/usr/local/lib/python3.9/site-packages/pyatv/support/http.py", line 359, in post
    return await self.send_and_receive(
  File "/usr/local/lib/python3.9/site-packages/pyatv/support/http.py", line 412, in send_and_receive
    raise exceptions.HttpError(
pyatv.exceptions.HttpError: HTTP/1.1 method POST failed with code 500: Internal Server Error

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

Traceback (most recent call last):
  File "/config/custom_components/apple_tv/config_flow.py", line 424, in async_step_pair_with_pin
    await self.pairing.finish()
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/airplay/pairing.py", line 74, in finish
    await error_handler(
  File "/usr/local/lib/python3.9/site-packages/pyatv/support/__init__.py", line 41, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError: HTTP/1.1 method POST failed with code 500: Internal Server Error

How to reproduce the bug?

I receive this error every try to add ATV to HA.

What is expected behavior?

Completion of configuration wizard.

Operating System

Mac OS 12.0.1

Python

3.9

pyatv

2.2.0

Device

Apple TV 4k, TV OS 15.2

Additional context

Not sure about python version, using supervised HA in VM under ESXi. All the lates update, so assuming the latest version of python too.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
postlundcommented, Dec 22, 2021

@Colorado4Wheeler I think we found the problem. For some reason there’s an old entry lurking around in .storage/core.config_entries for your device. I don’t quite understand why this isn’t visible in the frontend, but if you remove that it will work again.

0reactions
Colorado4Wheelercommented, Dec 22, 2021

I’ll take another look but when I manually purged everything from core.config_entries before (when you posted that it was needed generally for the update) I was pretty thorough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

If your Apple TV can't connect to Wi-Fi
On the Apple TV menu, go to Settings > System and select Restart. Unplug your router and your cable or DSL modem from...
Read more >
Apple TV not accepting password. - Apple Community
My older Apple TV will not accept my iTunes password for my library of movies due to double verification. I need to use...
Read more >
Apple TV won't accept password and 6 digi…
Apple TV won't accept password and 6 digit pin even though they are correct. Whenever try to log in to the iTunes account...
Read more >
Set up your Apple TV
To get started with your Apple TV device, follow these steps.
Read more >
I can't find a pin - Apple Support Communities
I try to stream from an app to the tv via apple tv. But the app keeps asking for a pin, to should...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found