Apple TV - apple_tv:failed to login

I don’t have one yet, I’m planning on buying a 4K soon. So no worries there, but thanks for the offer :blush: My biggest issue is time at the moment. I try to work as much as possible, but I don’t have nearly as much time as is needed.

Well if you happen to have an account on patreon, beerpay or similar and happen to post the link here, I’m sure you’d receive some gratitude to help defray the cost… :wink:

I understand this issue is likely being worked on via the support for MRP but I submitted this bug regardless for the record as now ATV4 is completely broken as of 0.55.1: https://github.com/home-assistant/home-assistant/issues/9966

I have an ATV4 running iOS 11 working with Hass 0.56.0.

I managed to get it working by turning off Home Sharing, turning it back on again, restarting the ATV.

Then it stopped working.

Decided to pair it. Worked. Now it’s no longer working.

It’s an uphill battle I tell you.

1 Like

Any ATV4 users here that have succeeded long term?
My ATV is still unresponsive.

Nope. I usually try again after every release but the result is always the same.

@chimpy That’s odd. Mine has never had issues. I use it wired, I wonder if that makes the difference?

Interesting. It’s definitely an Apple TV 4? I have an older gen Apple TV that works just fine, only v4 has issues.

@aaronwolen Mine is definitely a 4. Sold my jailbroken 2 for it when it first came out. I’ll try testing one time on wireless and see if it has issues.

The other factors that could make a difference are: I never turn off my ATV4, never goes to sleep, and also I restart HA almost daily, because I’m addicted to making changes.

I’ve been running 2 ATV 4’s for quite a while now, both on wired and wireless, they both produce the same error.

It’s very interesting… because I have an ATV 4K since a couple of weeks and I don’t see any problems with it at all. It just keeps going.

I’ll be upgrading to a ATV 4K in a week or so, hopefully that fixes the problems.

Seems you and I are experiencing similar issues. I’ll be curious to hear about your experience with the ATV 4k.

Ok, so, hopefully some good news regarding this old issue. It happened to me too yesterday and I have been able to reproduce it by just rebooting the device… My theory was that “old” connection details (something that is retrieved when logging) was not updated when connection was lost to the device. So pyatv just kept re-using the old ones instead of logging in a again. I added some safety guards and resetting them in case of an error and it seems like the connection is recovered correctly after one attempt.

If you want to help me try it out before I make a relase, open this file (might be different path depending on if you are using hassbian or not and your python version): /srv/homeassistant/lib/python3.4/site-packages/pyatv/daap.py. Search for “raise exceptions.AuthenticationError” and add “self._session_id = 0” above it. It should look something like this:

# Retry once if we got a bad response, otherwise bail out
if retry:
        return (yield from self._do(
    		action, False, is_login=is_login, is_daap=is_daap))
else:
        self._session_id = 0
        raise exceptions.AuthenticationError(
        	'failed to login: ' + str(status))

You should still see a “400” error but the connection should recover correctly after about 10 seconds.

2 Likes

Thanks @postlund! I’ll give this a try when I get home.

Got the new ATV 4k all hooked up, but running into more problems:

Found Apple TVs:

  • Apple TV at 192.168.X.X (home sharing disabled)

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

I’ve verified home-sharing is enabled on my computer (itunes), and on the Apple TV, as well as reboot everything. Same issue - home sharing disabled. Any ideas?

Edit: Managed to enable home-sharing by following @chimpy’s advice above.

Hey xstrex, let me know how long this works out for you.
My advice stopped working after a while. I’ll try it again.
Thanks!

Zeroconf isn’t always that reliable I’m afraid. Not sure how often devices broadcast but it’s possible that atvremote misses one, thus you don’t see any devices. I suggest that you try scanning from Home Assistant. There is a scan service under the apple_tv component that you can call from the service panel. Any devices found will be presented as a persistent notification on the Overview screen. This usually works better since Home Assistant generally run for a long time, so at some point it picks up the Apple TV broadcast and caches it.

Yea this worked for maybe 72hrs, then I started getting the “failed to login” messages, and “establishing a connection to…”, after restarting HA, it successfully connected, and worked for the evening; I’ll have to see if it’s still working when I get a chance.

@postlund I’ll get your above “fix” in place later this evening, and report back.

Edit: Fix implemented, we’ll see how it works.

1 Like