Apple TV component does not work on TVos 13

Does it work for single user then? (I haven’t tried this) but I get my playing/paused/stopped states now and the remote works again which were my main concerns for now. And these work fine, except when HA starts and the device is off, it will show state once the device starts doing something.

Sadly I also ran into this issue. My ATV is not working in HA anymore after it auto updated to iOS 13.
I only have my own account configured on the ATV but have 5 more people in Apple Home Sharing. Nothing is found when scanning for ATV devices but it will let me authenticate, showing the PIN code on the screen. Also my Plex app is showing up as working from the ATV.

I really hope this will get some attention as the automation to dimm the lights when playing a movie, is the main reason for me getting HA accepted within the family :slight_smile:

Had I known that iOS 13 would break this function, I had disabled auto updates on the ATV!

There will be a fix soon.

If anyone is interested, I was able to get 2 AppleTV 4Ks working in HA using a combination of the apple_tv_mrp custom-component from Chamberlain2007 for the initial connection and a forked version of pyatv to get the Airplay credentials. I’m on tvOS 13.2 and now have 2 fully functioning and tested ‘media_player’ entities and 2 ‘remote’ entities. And that is with multiple users on each ATV.

I can write up what I did if anyone wants to go through the steps. It is a little tedious but works like a charm so far. You will need to assign a static IP to your ATV and if the integration breaks will need to rescan and update the PORT number in your configuration.yaml, seeing as how this port number reportedly can change under certain circumstances. However, should be a good fix for the time being until an official integration comes out.

1 Like

I am interested in how you paired it yes XD. At the moment I can only read states like play/pause (and luckily my automations work on them) But restarting the ATV will indeed change their ports. Annoying but it’s ok. Could you tell us how you did the pairing?

Yeah, a bit of a pain if you have to have to go in and change the port number if you restart AppleTV but luckily thats something I very rarely do to begin with. but anyways…

1 - Follow the steps listed to install ‘apple_tv_mrp’ all the way down to where you have to run the ‘authenticate’ service. I could not get this to work for me. HASSIO kept giving me errors so I went a different route.
2 - Go here - https://github.com/postlund/pyatv and use this page as a reference if needed.
3. Run these commands in the linux command line or on MacOS. I did mine on MacOS and didn’t have to fumble around installing additional packages and whatnot. This will install a developer version of pyatv and run in a virtual env using the setup script provided.

git clone https://github.com/postlund/pyatv.git
cd pyatv
./setup_dev_env.sh
source bin/activate

Run:
atvremote -a scan

This will list any HomePods and AppleTVs the program can find on your network. Make note of the IP of the AppleTV you are wanting to pair. It should be the same as identified in Step 1.

Run:
atvremote -a pair

This is where I had a little trouble at first. The only way I could get it to pair specifically to the device I wanted out of 5 compatible devices on my network was to make sure nothing was playing on the other 4 and then play music or movie or whatever on the device I wanted to pair. At this point a 4 digit pairing code will show up on the ATV which you then enter into the command line. After that it should pair and generate a (very long) credential that you can now add into your configuration.yaml file.

Follow those steps for each device you want to pair to get a unique credential for each device. After that its smooth sailing and you should have individual media_player and remote entities to use for each device.

Let me know if any of that doesn’t make sense or I am mistaken about something. But thats exactly what I did and it works flawlessly.

2 Likes

Works great! Thanks :wink:

I’m working on fixing this “the right” way, with slow pace. But progress will be posted here:

Hi I am trying to follow your guide on my mac, but when I run ./setup_dev_env.sh i terminal i get the following virtualenv: command not found
can you help me what I am doing wrong

I’m assuming you are trying to do run it from within the HASS frontend in the “Terminal” add-on or SSH into it? If so, and its the usual Alpine Linux distribution then virtualenv is not included with that distribution as far as I know. You will have to find the package that it’s included in and add it using apk add and then the package name. If you aren’t able to find it or its not compatible with Alpine Linux then just run it from outside the Home Assistant environment. The pyatv program doesn’t do anything on the Home Assistant side for the integration. You would just have to copy and paste the credentials the program provides after pairing with your Apple TV into your configuration.yaml file or secrets.yaml file, whichever you are using.

I am trying to run the commands from my mac machine is that not possible

I did the whole procedure above on my Mac without having to install any additional packages. Where are you getting stuck?

when I am trying to run this ./setup_dev_env.sh i get an error saying virtualenv: command not found

And you are running it from the MacOS Terminal window? Not from within Home Assistant or ssh’d into Hassio?

yes I am running from a terminal i MacOS
image

Try sudo pip install virtualenv, then try running that command again.

I get pip command not found

lol, you are going to have to install pip package as well, and possibly python before that if you don’t have that installed.

https://pypi.org/project/pip/ - this page will help you get it installed.

I think is working now :slight_smile: :slight_smile: sorry my bad :slight_smile: Windows man :slight_smile:

Ah good, and no worries. Always a bit of a learning curve on Mac and Linux with you Windows guys. :wink: