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
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.
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.