Yes they are. And they were paired successfully for months (built-in integration) before upgrading to tvOS15.
Can you check if there’s anything in the log?
Since I have to close the pairing dialog box without submitting a pin code, there’s not much in the log. If I make up a pin code I get this authentication error, as expected. Do you see anything out of the ordinary there?
Logger: custom_components.apple_tv.config_flow
Source: custom_components/apple_tv/config_flow.py:322
Integration: Apple TV
First occurred: 7:08:53 PM (1 occurrences)
Last logged: 7:08:53 PM
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/hap.py", line 77, in finish_pairing
resp = 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.ProtocolError(
pyatv.exceptions.ProtocolError: HTTP/1.1 method POST failed with code 470: Connection Authorization Required
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 322, 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 470: Connection Authorization Required
Hmm, then I don’t now really. If you could run atvremote scan
and provide the result it would somehow help. Perhaps also pairing and include the debug log for that (atvremote -s <ip> --debug --protocol airplay pair
).
For anybody in the same dead end, it was my bad: AirPlay Password was activated and thus no PIN screen showed up when pairing. I had double-checked AirPlay was ON and Allow access was set to Everyone, but there’s a Require Password down there that somehow was set to ON. Great work from @postlund and many thanks for the help.
Yeah, that’s easy to miss and not something that is clearly marked as unsupported either. The config flow will in general tell you when something is configured in an unsupported way, but password is currently not handled. So I will add a dialog informing about password not being supported when a protocol requiring it is found.
At the moment pyatv can report if a password is required or not and it is also supported for RAOP, but not AirPlay (those are the only protocols using passwords). I will add support for password protected devices in the future as well, but not as part of this uplift.
@postlund I’ve using Release 2 for some weeks and works really well. I use it for switching on the APT (send menu to wake up) and switch it off (home + home_hold + select).
I see you have just issued Release 4. Thanks first of all for your constant improvements!
I see in the remote code the def “turn_on” and “turn_off”. WIll I be able with this release to send a single command for powering on and off the device?
Also, is there any option to query the state of the device?
Thanks a lot.
There is no real power management built in yet, there’s a PR open about it though. I’m gonna try to prioritize some new features (like that) once I have the general uplift merged. Until then you will navigate menus like you do now.
The only state you can get is the one reported by the media_player
entity. I have a concept of detecting “deep sleeping” devices in pyatv but that’s not integrated in Home Asisistant, nor will it be since it very unstable and buggy.
Just installed the beta from HACS and I’m very grateful for the fix. I am seeing my 2 Sonos systems listed as Apple TV devices in addition to the 2 Apple TV boxes I have. Is this something I should should expect to see? Would all Airplay devices show up like this?
Yes, basic support for most AirPlay devices is supported by the integration (basically just audio streaming and “stop”).
Understood. Thanks.
I don’t have urgency then to update to the latest release.
I added the beta integration and it’s working fine. However, while it now sees all airplay endpoints on my network, it can’t add all of them. Specifically my Sonos Amps and Beams. When I click configure and submit, it asks for a passcode, which I do not have a way of getting for the Sonos devices. My Airport Express (2nd gen) and my Denon X2200W both configured without a passcode as expected.
On a side note, I did not remove the previous (built-in) AppleTV integration and rebooted my HA docker. When it came back, it could see all of the previously paired AppleTVs, but I had no status or control of them. They were not unavailable, just no change in states. I had removed the integrations, rebooted the docker again, and when it came back up it had discovered all of the AppleTV and AirPlay endpoints so I could configure the integration.
Ah yes, AirPlay might work a bit strange. I have not figured out all the quirks yet, as I don’t know what authentication is required. Normally some type of authentication is required, but it varies and especially with third party devices. There’s a similar issues opened for the IKEA Symfonisk speaker, which is Sonos software (https://github.com/postlund/pyatv/issues/1259). To work more efficiently, I would need to get hold on one of those or remote access to one. It’s so hard to just guess. But thank you for reporting that back!
That behavior is expected. Previously i stored one “unique identifier” which I used during scanning to find the same device again. This identifier was normally extracted from MRP, but since MRP has been removed there’s no service left to find. So Home Assistant will basically continue looking forever but never find the device. I have changed this to save unique identifiers from all’s protocols now, so this will not be a problem in the future. But it current makes it impossible to create a proper migration function, it would only work for Apple TV 3 devices.
I don’t have the ability to do remote access to these devices, but if you need logs of any kind, let me know if I can help.
One thing that I would like to try is the same kind of authentication used by AirPort Express (MFi). I have a test branch in pyatv prepared for that. I would require you to clone pyatv and install it, do you have time to help with that?
Sure. I run HA in docker, so I’m assuming I just need to clone the test branch and replace the files in my custom components directory with the test branch files? Or is this doable through HACS and I just need to select a different release?
It’s tricky to integrate it back to Home Assistant, so it’s easier to just run it from a command line. I have built a docker image from my test branch, so you should be able to just run it like this:
docker run -it --rm --network=host ghcr.io/postlund/pyatv:raop_test atvremote - s <ip of device> stream_file=somefile.mp3
You need a sample file to stream. If you don’t have one available, you can take one from here: Sample audio files | File Examples Download
This is mainly to test that audio streaming work (for another issue really), but it’s the same authentication so it will be true for AirPlay as well.
So I was finally able to figure out how to add HACS, the custom repository, and then the beta Apple TV integration. I went to my integrations tab and saw my TV and homepods. I ignored the homepods and tried to add the apple tv.
I got multiple PINs, but the connection ultimately errored out. I think it was because I did not have airplay set to everyone. I have corrected that, but cannot get the apple tv to show up again so that I can try to add it. I checked my core.config file and there is nothing in there for the apple tv.
Any help to get the Apple TV to show up again would be greatly appreciated. I am sorry for the newb type question. I am fairly tech savvy, but am new to HA.
EDIT: NEVERMIND. I WAS ABLE TO FIGURE IT OUT AND HAVE IT CONNECTED NOW. THANK YOU.
If a flow fails for a device for some reason you usually have to restart home assistant to make it appear again, don’t know why. You can also try adding it manually.