Apple TV not working properly

Yeah, I added support for ignore in discovery because of situations like these :slight_smile: It was included in 0.39 so it’s brand new.

It should work fine on both 3rd and 4th gen devices. I only have a 3rd gen myself, but other people have verified on 4th gen for me. What the skip command does depends on what you are playing. For video for instance, it will skip 10 seconds I think. You can compare behavior with the Remote app if you want. Should be the same.

Same for TTS, should work out-of-the-box in the UI :slight_smile: It does for me at least.

Polling is done every ten seconds, so it’s probably with that interval. But it should not flicker. Must be that a state change is found for some reason. Anyway, I believe this will be fixed once and for all when I add support for push updates, which will be ready in the next release. That will also give instant updates, which is quite nice.

Cool, I can hold out until the next release, doesn’t effect functionality so it’s all good.

Sweet, thanks!

Just created a PR for push update, available here: https://github.com/home-assistant/home-assistant/pull/6323
Give it a spin if you have the chance!

New here and found this thread trying to fix my problem so bumping it - hope that’s OK.

So, there’s a few posts about Apple TV “randomly” turning on, however my problem is more similar to this thread which describes the jumping in the UI. My issue is not another device like to original post update and I do not have a problem where it’s only displaying “No title”. Everything seems to be working, except I can’t keep my TV off.

I can live with the jumping in the UI, however, since I’m using CEC (and would like to keep doing that) every time I shut down my Apple TV (and thus the TV), the Apple TV and TV will start again within 1 - 5 minutes.

Even if I were to remove the CEC (which I tried), the Apple TV will still start up and that means that the Apple TV would be on (not in stand-by) 24/7 which I would like to avoid. Since I’m running Home Assistant on an always-on Raspbery Pi the polling will be made 24/7.

I’ve read about the “start_off” parameter, disabling of Apple TV discovery (my Apple TVs is added manually) etcetera but nothing really resolves my issue. So after reading this post I understood that the “start_off” is the same thing as turning the Apple TV off in the UI (no polling will be made), right? Since the jumping won’t occur in this state, nor does the TV start - this kind of resolves my issue. However I have automations setup in Home Assistant which tweaks my lights depending on states of the Apple TV so I don’t want it switched off while actually on. This is my configuration:

discovery:
  ignore:
    - apple_tv

apple_tv:
  - host: 10.10.1.17
    login_id: 00000000-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    name: "Apple TV Living room"
    start_off: true

Since the TV I’m using is a Sony Bravia I was able to connect my TV to Home Assistant. Now what I’ve done is that I’ve added the following automations:

- action:
  - alias: Turn on Apple TV
    data:
      entity_id: remote.apple_tv_living_room
    service: remote.turn_on
  trigger:
  - entity_id: media_player.sony_bravia_tv
    from: 'off'
    platform: state
    to: 'on'
- action:
  - alias: Turn off Apple TV
    data:
      entity_id: remote.apple_tv_living_room
    service: remote.turn_off
  trigger:
  - entity_id: media_player.sony_bravia_tv
    from: 'on'
    platform: state
    to: 'off'

Speaking of that, is there a way to not add the remotes for every Apple TV? I can’t really see the usage of the remote since all I can do with it is to toggle the Apple TV on or off which can also be done via media_player.apple_tv.

This makes sure that whenever the TV is not on, the Apple TV in HA will be off and vice versa.

  • Is this really the intended way to setup an Apple TV 4?
  • Is there a way to avoid the Apple TV from always starting when HA is on?
  • If I turn off CEC - should the Apple TV be on 24/7 anyway?

This issue is only present on Apple TV 4 and not with Apple TV 3.

Setup
Raspberry Pi 1 (Model B)
Linux hassbian 4.9.35+ (although I had to install pyatv/atvremote manually anyway)
HA 0.51.1
Python 3.4.2
Combined with homebridge-homeassistant

Edit
Ok, it seems like the bouncing UI might be related to this, only larger jumps. Since that’s a known bug I guess my only problem is that I cannot keep my Apple TV/TV turend off.

1 Like

Hope it’s OK to bump this, I haven’t made any progress. @postlund Can you confirm or deny that the behaviour I’m experiencing is the intended way?

Yes, you have basically answered your own question. If you use CEC then you will have to turn it off (preferably using start_off:) in HA when not using it, otherwise it will start automatically at some point (especially since HA will set up a connection to it and wait for changes). As I have said before and written in the documentation, this is the design chosen by Apple and nothing I can do anything about. Using an automation to turn it on, like you have described above is the best solution I have come up with, so that’s what I would recommend.

It’s kinda like you can’t have the cake and eat it to. In order to know what is currently playing, the device must be on. So yes, even if you disable CEC, the device will be on otherwise there will be no way of knowing what the device is up to. This is also how all other platforms and components work in HA, so it’s nothing unique here.

Regarding remotes, you will have to hide them manually. Remotes are setup automatically when a device is added. You can use them to send other key presses too (like arrow keys, menu, …) but you must use the service for that since the UI currently only implements turn on/off.

1 Like

Hi everyone,
I’ve added this configuration to my HA, but as a result my appletv seems to end up being not detected by HA. I can’t even find it as an entity. I’m wondering if apart from configuring HA this way, I’m supposed to do something else.
My understanding is that, in order to avoid AppleTV from switching on my TV over CEC, one must add the start_off toggler. If then one defines a static AppleTV, should that not generate an entity? assuming this is the case, why is it not being displayed in the Overview section of HA? If the answer is no, then I understand that the automations enable you to actually see an AppleTV in the Overview section?
thanks a lot in advance,

anybody can help me with this? Thanks! :slight_smile:

You should get a media_player entity. Have you taken a look into the log? Without any further details it’s hard to tell what’s wrong.

The configuration you quoted from me is the configuration I still use, however I don’t think the ‘start_off’ option is of any help in this case since it will handle the ATV as turned off and thus not poll anything. If you want to use any kind of trigger related to your ATV it must be switched on in HA.

If you remove your manually added section for the Apple TV and enable the discovery service again, do you see your ATV?

yes, if I let HA autodiscover it, it definitely finds my AppleTV (and switches on my TV set :frowning:)

1 Like

Hello,

this is what my configuration looks like

media_player:
  - platform: apple_tv
    name: AppleTV Dinning Room
    host: appletv4_dinningroom.kitusnetwork.no-ip.biz
    login_id: MY-LOGIN-ID
    start_off: true

I don’t see any message related to this in the logs view. I’m running hassio and it is a pretty well sealed platform… not sure where to check for logs other than in the section of the web environment.

Hello, I re-added this information to my configuration file and it now displays my AppleTV!! :wink:
Many thanks to everyone in this thread. Your help is much appreciated :slight_smile:

Not sure I follow. Now that I managed to set it up, may I ask what the differences are between HA autodiscovering an AppleTV and manually configuring it like you did?

Many thanks :slight_smile:

You should not add the media_player platform yourself, only the apple_tv: platform as it sets up the media player for you.

I already see the AppleTV on the main screen by adding this configuration found here. Is there anything missing?
thanks

Looks fine to me. Since you have start_off it will always be in off mode until you turn it on. So if you want to see any updates, try turning it on in the UI. You should see a message like “Establishing a connection…” for a long time if it doesn’t work. In that case you’ll have to look in the log.

Hello there,

I just figured that my apple TV was not reached by home assistant, so I started the scan service again and got

Found Apple TVs:
 - Apple TV Fitness at 192.168.1.228 (home sharing disabled)
 - Apple TV Cinema at 192.168.1.227 (home sharing disabled)

I finished to get it working by your suggested workaround:

Disable Home sharing
Restart AppleTV
Enable Home sharing

Now the scan finds my atvs and gives me the login_id.

With this id through the terminal I can control my atv - but it is no longer shown in my hass instance. No media_player is listed. I tried changing the config several times, but no help.
My log gives me:

2018-05-17 13:04:45 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/home/smartassi/homeassistant_v2/lib/python3.6/site-packages/homeassistant/components/apple_tv.py”, line 210, in _setup_atv
session = async_get_clientsession(hass)
File “/home/smartassi/homeassistant_v2/lib/python3.6/site-packages/homeassistant/helpers/aiohttp_client.py”, line 38, in async_get_clientsession
hass.data[key] = async_create_clientsession(hass, verify_ssl)
File “/home/smartassi/homeassistant_v2/lib/python3.6/site-packages/homeassistant/helpers/aiohttp_client.py”, line 55, in async_create_clientsession
connector = _async_get_connector(hass, verify_ssl)
File “/home/smartassi/homeassistant_v2/lib/python3.6/site-packages/homeassistant/helpers/aiohttp_client.py”, line 164, in _async_get_connector
connector = aiohttp.TCPConnector(loop=hass.loop, ssl=ssl_context)
TypeError: init() got an unexpected keyword argument ‘ssl’

I am not sure what to do now… :frowning:
Do you have an idea?