Skip to content

Add Apple TV

Dick Swart edited this page Aug 11, 2018 · 4 revisions

I had issues finding my Apple TV with the scan as explained in the official documentation, So this is what I did to finally get it working.

Installation:

  1. First, make sure your raspberry pi is up to date.
$ sudo apt-get update && sudo apt-get upgrade
  1. Install the required packages.
$ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
  1. Stop your home-assistant.
sudo systemctl stop home-assistant@homeassistant.service
  1. Activate the virtual environment and then install pyatv, this is the software that allows us to communicate and interact with the apple tv.
$ sudo -u homeassistant -H -s
$ source /srv/homeassistant/bin/activate
$ pip3 install --upgrade pyatv
$ exit
  1. Edit your configuration.yaml file, add apple_tv:. If you want to discover new devices automatically, just make sure you have discovery: in your configuration.yaml file.

  2. Now head over to your apple tv and make sure Home Sharing is enabled. Go to Settings > Accounts > Home Sharing if it is off just enable it, you will be asked to sign in with your Apple Id.

  3. Now we will scan for out apple tv, this can be done via the frontend as explained by the documentation in the guid you will just need to start your home assistant (sudo systemctl start home-assistant@homeassistant.service) or you can just do it from the command line.

$ sudo -u homeassistant -H -s
$ atvremote scan

Hold your thumbs and hopefully you will get an output that looks like this:

Found Apple TVs:
- Apple TV at 10.0.10.22 (login id: 00000000-1234-5678-9abc-def012345678)

Note: You must use 'pair' with devices that have home sharing disabled

If no Apple Tv gets returned, try to scan with a long timeout.

$ atvremote -t 9 scan

If you still don't get any results returned, head over to your Apple TV and disable and re-enable Home Sharing and then restart your apple tv (Settings > System > Restart) and scan again using the commands above.

  1. Now edit your configuration.yaml file (I'm using the example output values from above, you should use your own Apple TV login id and IP address).
# Example configuration.yaml entry
apple_tv:
  - host: 10.0.10.22
    login_id: 00000000-1234-5678-9abc-def012345678
    name: MyAppleTV_Name
  1. Return to your user if you are still the home assistant user.
$ exit
  1. Start home Assistant.
$ sudo systemctl start home-assistant@homeassistant.service
  1. Go get a beer!!

Setting up device authentication:

For the authentication part of the setup, I just followed the official documentation.

Do this in front of your Apple TV as you will be required to enter a pin, running back and forward is not a good idea (I tried, it sucks! LOL)

References

Clone this wiki locally