Skip to content

Commit fda6aa2

Browse files
postlundfabaff
authored andcommitted
Correct documentation for Apple TV (home-assistant#3004)
* Correct documentation for Apple TV * Minor style updates
1 parent 15eba5a commit fda6aa2

File tree

7 files changed

+192
-37
lines changed

7 files changed

+192
-37
lines changed

source/_components/apple_tv.markdown

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
---
2+
layout: page
3+
title: "Apple TV"
4+
description: "Instructions how to integrate Apple TV devices into Home Assistant."
5+
date: 2017-06-26 20:47
6+
sidebar: true
7+
comments: false
8+
sharing: true
9+
footer: true
10+
logo: apple.png
11+
ha_category: Hub
12+
ha_iot_class: "Local Push"
13+
ha_release: 0.49
14+
featured: true
15+
---
16+
17+
The `apple_tv` platform allows you to control an Apple TV (3rd and 4th generation). See the [remote platform](/components/remote.apple_tv/) if you want to send remote control buttons, e.g. arrow keys.
18+
19+
<p class='note'>
20+
Currently you must have Home Sharing enabled for this to work. Support for pairing Home Assistant with your device will be supported in a later release.
21+
</p>
22+
23+
To use this component, you must first install some system libraries and a compiler. For Debian or a similar system, this should be enough:
24+
25+
```shell
26+
$ sudo apt-get install build-essential libssl-dev libffi-dev python-dev
27+
```
28+
29+
If you want to automatically discover new devices, just make sure you have `discovery:` in your `configuration.yaml` file. To manually add one or more Apple TVs to your installation, add the following to your `configuration.yaml` file:
30+
31+
```yaml
32+
# Example configuration.yaml entry
33+
apple_tv:
34+
- host: IP_1
35+
login_id: LOGIN_ID_1
36+
name: NAME_1
37+
start_off: START_OFF_1
38+
credentials: CREDENTIALS_1
39+
- host: IP_2
40+
login_id: LOGIN_ID_2
41+
name: NAME_2
42+
start_off: START_OFF_2
43+
credentials: CREDENTIALS_2
44+
```
45+
46+
Configuration variables:
47+
48+
- **host** (*Required*): The IP-address of the device.
49+
- **login_id** (*Required*): An identifier used to login to the device, see below.
50+
- **name** (*Optional*): The name of the device used in the frontend.
51+
- **start_off** (*Optional*): Set to true if device should start in fake standby.
52+
- **credentials** (*Optional*): Credentials used for AirPlay playback.
53+
54+
In order to connect to the device you need a *login id*. The easiest way to obtain this identifier is to use the `apple_tv_scan` service (described below). Additional information about `start_off` and `credentials` can also be found under the guides section.
55+
56+
## {% linkable_title Guides %}
57+
58+
### {% linkable_title Scanning for devices %}
59+
60+
To scan for devices, press the icon in the upper left corner and select the leftmost icon according to the image:
61+
62+
<img src='/images/screenshots/developer-tools.png' />
63+
64+
Select `apple_tv` as domain and `apple_tv_scan` as service then press the button:
65+
66+
<img src='/images/components/apple_tv/scan_start.jpg' />
67+
68+
Scanning will be done for three seconds and notification will be shown in the state view with all found devices:
69+
70+
<img src='/images/components/apple_tv/scan_result.jpg' />
71+
72+
Alternatively you may use the application ``atvremote``. Install it with ``pip3 install --upgrade pyatv`` in your Home Assistant environment (note: do *not* use sudo). Then run ``atvremote scan`` to scan for all devices (try again if a device is missing):
73+
74+
```bash
75+
$ atvremote scan
76+
Found Apple TVs:
77+
- Apple TV at 10.0.10.22 (login id: 00000000-1234-5678-9012-345678901234)
78+
79+
Note: You must use 'pair' with devices that have home sharing disabled
80+
```
81+
82+
Just copy and paste the login id from the device you want to add. For more details about `atvremote`, see: [this page](http://pyatv.readthedocs.io/en/master/atvremote.html).
83+
84+
### {% linkable_title My Apple TV turns on when I restart Home Assistant %}
85+
86+
The Apple TV will automatically turn on if a request is sent to it, e.g. if a button is pressed, something is streamed to it via AirPlay or if current state (currently playing) is accessed. This is how Apple has designed it and it will cause problems if you are using HDMI CEC. Every time Home Assistant is started, a new request is sent to the device to figure out what is currently playing. When using CEC, this will wake up your TV and other devices you have configured.
87+
88+
So, if your TV is randomly turning on, this is probably the reason. As stated, this is by design and there is no real fix for it. There's also no known way to turn off the Apple TV via the procotol used for communication. You basically have the following options:
89+
90+
- Do not use this platform
91+
- Disable HDMI CEC on your Apple TV
92+
- Use "fake standby"
93+
94+
The first two points are quite obvious. Fake standby is a concept implemented in this platform that disables all requests to the device and make it appear as being "off" in the web interface. This will make sure that the device is not woken up, but it will of course not show any information or allow you to control it. It is however easy to turn it on (or off) in the web interface or using an automation with `turn_on`. To make it more useful, you can write automations that turns it on or off depending on some other device, like the input source on your receiver.
95+
96+
To put a device into fake standby when starting Home Assistant, add `start_off: true` to your configuration.
97+
98+
<p class='note warning'>
99+
Turning the device on/off in the user interface will *not* turn the physical device on/off according to description above.
100+
</p>
101+
102+
103+
### {% linkable_title Setting up device authentication %}
104+
105+
If you, when playing media with `play_url`, get the following error message:
106+
107+
*“This AirPlay connection requires iOS 7.1 or later, OS X 10.10 or later, or iTunes 11.2 or later.”*
108+
109+
then device authentication is required. Press the icon in the upper left corner and select the leftmost icon according to the image below:
110+
111+
<img src='/images/screenshots/developer-tools.png' />
112+
113+
Select `apple_tv` as domain, `apple_tv_authenticate` as service and enter `{'entity_id': 'XXX'}` into "Service Data", but replace XXX with the entity id of your device (e.g. `media_player.apple_tv`). Press the button and hopefully you are presented with an input dialog asking for a pin code:
114+
115+
<img src='/images/components/apple_tv/auth_start.jpg' />
116+
117+
If no dialog appears, go back to the states view and display it from there (press `CONFIGURE` as displayed in the image):
118+
119+
<img src='/images/components/apple_tv/auth_pin.jpg' />
120+
121+
A PIN code should now be visible on your TV, just enter it into the dialog and press "Confirm". You should see if it succeeded in the state view. Copy the credentials and insert it into your configuration (make sure you copy everything, it should be 81 characters) after ``credentials:`` with no line-break:
122+
123+
```yaml
124+
# Example configuration.yaml entry
125+
apple_tv:
126+
- host: 10.0.0.20
127+
login_id: 00000000-1234-5678-9012-345678901234
128+
credentials: 1B8C387DDB59BDF6:CF5ABB6A2C070688F5926ADB7C010F6DF847252C15F9BDB6DA3E09D6591E90E5
129+
```
130+
131+
Restart Home Assistant and you should now be able to use `play_url` as before.
132+
133+
## {% linkable_title Services %}
134+
135+
### {% linkable_title Service `apple_tv_authenticate` %}
136+
137+
In order to play media on an Apple TV with device authentication enabled (e.g. ATV4 with tvOS 10.2+), Home Assistant must properly authenticated. This method starts the process and presents the credentials needed for playback as a persistent notification. Please see guide above for usage.
138+
139+
| Service data attribute | Optional | Description |
140+
| ---------------------- | -------- | ----------- |
141+
| `entity_id` | yes | String or list of strings that point at `entity_id`s of Apple TVs.
142+
143+
### {% linkable_title Service `apple_tv_scan` %}
144+
145+
Scans the local network for Apple TVs. All found devices are presented as a persistent notification.
146+

source/_components/media_player.apple_tv.markdown

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,8 @@ sharing: true
99
footer: true
1010
logo: apple.png
1111
ha_category: Media Player
12-
ha_iot_class: "Local Polling"
12+
ha_iot_class: "Local Push"
1313
ha_release: 0.38
14-
featured: true
1514
---
1615

17-
The `apple_tv` platform allows you to control an Apple TV (3rd and 4th generation).
18-
19-
<p class='note'>
20-
Currently you must have Home Sharing enabled for this to work. Support for pairing Home Assistant with your device will be supported in a later release.
21-
</p>
22-
23-
If you want to automatically discover new devices, just make sure you have `discovery:` in your `configuration.yaml` file. To manually add an Apple TV to your installation, add the following to your `configuration.yaml` file:
24-
25-
```yaml
26-
# Example configuration.yaml entry
27-
media_player:
28-
- platform: apple_tv
29-
host: IP_ADDRESS
30-
login_id: LOGIN_ID
31-
```
32-
33-
Configuration variables:
34-
35-
- **host** (*Required*): The IP-address of the device
36-
- **login_id** (*Required*): An identifier used to login to the device, see below
37-
- **name** (*Optional*): The name of the device used in the frontend
38-
39-
In order to connect to the device you need a *login id*. The easiest way to obtain this identifier is to use the application ``atvremote``. It should be available in the same environment as you installed Home-Assistant. To install this utility, run ``pip3 install --upgrade pyatv``. The run atvremote scan for all devices (try again if a device is missing):
40-
41-
```bash
42-
$ atvremote scan
43-
Found Apple TVs:
44-
- Apple TV at 10.0.10.22 (login id: 00000000-1234-5678-9012-345678901234)
45-
```
46-
47-
Just copy and paste the login id from the device you want to add. For more details about `atvremote`, see: [this page](https://github.com/postlund/pyatv/blob/master/docs/atvremote.rst).
48-
49-
## {% linkable_title Notes and Limitations %}
50-
51-
- Pairing is currently not supported
16+
To setup the `apple_tv` platform, please follow the instructions on the [Apple TV Component page](/components/apple_tv/).
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
layout: page
3+
title: "Apple TV"
4+
description: "Instructions how to integrate Apple TV remote into Home Assistant."
5+
date: 2017-06-26 20:50
6+
sidebar: true
7+
comments: false
8+
sharing: true
9+
footer: true
10+
logo: apple.png
11+
ha_category: Remote
12+
ha_iot_class: "Local Push"
13+
ha_release: 0.49
14+
---
15+
16+
17+
The `apple_tv` remote platform allows you to send remote control buttons to an Apple TV. It is automatically setup when an Apple TV is configured, please see [Apple TV Component](/components/apple_tv/) for configuration details.
18+
19+
At the moment, the following buttons are supported:
20+
21+
- up
22+
- down
23+
- left
24+
- right
25+
- menu
26+
- top_menu
27+
- select
28+
29+
A typical service call for press several buttons looks like this.
30+
31+
```yaml
32+
service: remote.send_command
33+
data:
34+
entity_id: remote.apple_tv
35+
command:
36+
- left
37+
- left
38+
- menu
39+
- select
40+
device: ''
41+
42+
```
43+
44+
Please note that `device` must be specified (because of validation) but is not used by this platform. So you may specify any value.
34.5 KB
Loading
26.1 KB
Loading
Loading
Loading

0 commit comments

Comments
 (0)