Apple TV - apple_tv:failed to login

I didn’t include it in my config. LOL

home-assistant.log:17-02-14 09:56:28 INFO (Thread-15) [homeassistant.components.discovery] Found new service: apple_tv {'name': 'Apple TV', 'hsgid': '00000000-07ce-0a48-9410-cd36ff1d4845', 'host': '192.168.2.102'}
home-assistant.log:17-02-14 09:56:28 INFO (MainThread) [homeassistant.core] Bus:Handling <Event platform_discovered[L]: service=load_platform.media_player, platform=apple_tv, discovered=name=Apple TV, hsgid=00000000-07ce-0a48-9410-cd36ff1d4845, host=192.168.2.102>
home-assistant.log:17-02-14 09:56:28 INFO (MainThread) [homeassistant.loader] Loaded media_player.apple_tv from homeassistant.components.media_player.apple_tv
home-assistant.log:17-02-14 09:57:30 ERROR (Thread-1) [homeassistant.bootstrap] Not initializing media_player.apple_tv because could not install dependency pyatv==0.1.4

Why don’t you disable discovery?

I could do that, but that’s kind of like cutting your ears off because you don’t like the music playing isn’t it? How about a discovery_ignore file that allows us to put in items either by domain or by name that we don’t want to discover (or more accurately, that when discovered, get ignored).

I could be wrong but, I believe the discovery component is designed to help you find compatible devices on your network, and add them to HA. Not ignore them. You could always submit a feature request, I guess.

From what I can see, auto discovery works and actually find your device. The problem is that Home Assistant is unable to install pyatv (the library used to interact with the device):

… Not initializing media_player.apple_tv because could not install dependency pyatv==0.1.4

If this worked, you would probably see your device (you do not have to specify the platform, Home Assistant does that on-the-fly for auto discovered platforms). Maybe it’s the same for your chromecast? It’s nevertheless a problem with your python setup or network connection.

Maybe you should try this:

Agreed, the discovery component does a great job of discovering devices to help me get them into my configuration. But it would be nice if after doing that, it would check and see if a particular component or type of component is one I have taken an active role at saying please ignore this. In this case, although I am sure it is very small, I have to install the pyatv component and any support files for it in order to get a clean install. The time will come as HA continues to grow and expand that we will have to start making individual choices between devices we want controlled by HA, and the amount of computer power we can afford to support them all. Having the ability to consciously say “I know you are there, but I don’t want to use my system resources to talk to you” would be a nice feature.

The AppleTv control and the Cast Control are very nice components. The people that put them together did a great job. This is not a comment on their work or the need for what they did. It is simply because of the direction I want to go with my personal HA install, which does not include media players past determining if a TV is on or not.

That is absolutely up to you :slight_smile: Since I’m the author of the Apple TV platform, I just want to fix bugs if anyone encounters any. My philosophy is more: get as much stuff in there as possible, that’s when you can start do cool stuff. Resources is currently not a big problem, dependencies will only be installed for the platform you activate (or that are automatically discovered). But back to your issue… I see that you have two choices:

  1. Disable discovery
  2. Write a feature request for someone to implement an “ignore” setting for discovery

Option 2 is something I would like to see, but I don’t really use discovery myself since I want to know all my devices (and don’t have to wait for discovery).

Postlund, my comment was not aimed at you. You did a great job. :blush: Sorry if I offended, it was not my intention.

I’m not at all offended, just trying to help :slight_smile: But you should aim for option 2 above!

If I could follow up on the original issue, my log is still being flooded with these warnings:

17-02-19 07:07:48 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] failed to login: 400 (bad login id?)

I’m on 38.3 and have one gen. 4 Apple TV configured, discovery is disabled. The warnings disappear after restarting HA and the integration works beautifully. However, at some point, the warnings startup again and I’m not sure what’s triggering them. Manually putting Apple TV to sleep doesn’t seem to do it.

Any thoughts or troubleshooting suggestions?

More failed logins:

grep "failed to login: 400 (bad login id?)" home-assistant.log |wc -l
3061

My apple tv has a static IP address, and I’ve verified that the login ID hasn’t changed.

atvremote scan
Found Apple TVs:
 - Living Room TV at 192.168.2.123 (login id: 00000000-0763-7101-c2b7-b6f779354a5a)
grep "00000000-0763-7101-c2b7-b6f779354a5a" media_player/media_player.yaml
    login_id: 00000000-0763-7101-c2b7-b6f779354a5a

Suggestions?

Glad, it’s not just me. I’m also using a static IP and verified the login hasn’t changed.

Could 2-factor authentication be involved? I do have 2FA enabled on my iCloud account.

i have also 2FA on, but i think it is a other problem, saw there was a temp fix for it

Oh, I missed that there were updates to this thread. Sorry about that. It does not have to do with 2FA, i’m pretty sure about that. Could you enable logging for homeassistant.components.media_player.apple_tv in your config and try to get some additional logging? It will flood a bit, but more output would help.

the temp fix works like charm, only need to turn on/off manually

What code would we need to put in our config to enable verbose logging for this component?

Something like:

logger:
  logs:
    homeassistant.components.media_player.apple_tv: debug

I enabled debugging and let it run for about a day. You can checkout the log here: http://pastebin.com/jHg73GpK.

It contains a lot bad login id? warnings but I have verified the login from atv matches my config file.

Also confirmed again that it works fine after restarting HA.

Hmm, I still really don’t understand why this happen. I think I will have to add some additional debugging in the next version of pyatv. It seems like the device can no longer be found (errno 113). As I’m moving from polling to push updates, this issue might resolve itself anyway. Push updates support is finished and I’m testing it, but I feel that it’s not mature enough for merging with the upcoming release this weekend.