Apple TV 4K shows "Establishing a Connection to Apple TV"

Okay, I have started to understand more and more in Home Assistant and Hassio but I have a problem that I had at startup which I must grab now:
I have paired my Apple TV 4K (5th gen) in the living room by the following:

- host: XXX ...
  login_id: XXX ...
  credentials: XXX ...
  start_off: false

(XXX … is replaced with the correct information)

The problem is that periodically it loses the connection and shows “Establishing a Connection to Apple TV” … To solve this, I need to restart Apple TV for the contact to resume.
Have followed the guides online when setting up Apple TV (“Scanning for devices” etc …)

I’ve checked the Apple TV’s IP and it’s the same all the time. Home sharing is on.
Is there any way to solve this.

When the Apple TV stop working the log says:
A <class ‘pyatv.exceptions.AuthenticationError’> error occurred: failed to login: 503

Everything works flawlessly on the Apple TV 4 (4th gen) in the bedroom.

Thanks in advance!

I am experiencing the exact same issue. I have an appleTV 4k which periodically loses connection, and an appleTV 4th gen that has never done so. I get the exact same error message in the logs. Additional messages that appear when home assistant loses connection to the appleTV 4K are below:

2019-02-15 22:58:31 INFO (MainThread) [pyatv.daap] implicitly logged out, logging in again

2019-02-15 22:58:31 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b’103’

2019-02-15 22:58:31 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b’103’

2019-02-15 22:58:31 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] A <class ‘pyatv.exceptions.AuthenticationError’> error occurred: failed to login: 503

2019-02-15 22:58:41 INFO (MainThread) [pyatv.daap] implicitly logged out, logging in again

2019-02-15 22:58:41 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b’103’

2019-02-15 22:58:41 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b’103’

Same issue here on 0.88… Log just fills with tons of:

2019-02-24 17:21:24 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b'103'
2019-02-24 17:21:24 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b'103'
2019-02-24 17:21:24 WARNING (MainThread) [homeassistant.components.apple_tv.media_player] A <class 'pyatv.exceptions.AuthenticationError'> error occurred: failed to login: 503

Its strange. I have the same issue. But my apple tv component is not active its commented out. I had a similar problem with the harmony remote.

2019-03-08 09:44:16 WARNING (MainThread) [homeassistant.components.apple_tv.media_player] A <class 'pyatv.exceptions.AuthenticationError'> error occurred: failed to login: 503
2019-03-08 09:44:26 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b'103'
2019-03-08 09:44:26 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b'103'

#  - host:
#    login_id: 00000000-xxxx-xxxxxxxxxxxxxxxxx
#    name: Apple_TV

Is there any hope for these Apple TV issues?

The only way I’ve figured out how to fix is is by rebooting the Apple TV. I have 4 in my house and this just isn’t a suitable solution.

Do other people have the Apple TV component working reliably? Even after a reboot, eventually this just happens again after a couple of days.

1 Like

I have the same issue myself with two Apple TVs. Only solution I’ve found when it happens is to reboot.

It’s odd because I run…

$ atvremote scan

It only seems to find the one that’s working properly and telling me that home sharing needs to be enabled. I check both of them and they are both showing home sharing enabled.

It would be great if this didn’t require a reboot every time.

1 Like

Same here, also my whole log is full of those unknown data b'103' and failed to login: 503 errors. I tried to turn on home sharing, get a new login id, updating apple tv, set the apple tv to not go in standby, but nothing really solved the issue, the only thing what helps for a week is rebooting the device once a week. (Apple TV Gen 4)

1 Like

I’m experiencing the same issue. Wondering if there is anyway to automate a reboot intermittently every week.

Edit: rebooting doesn’t seem to resolve the issue in my case. Even though Home sharing is enabled and paired my 4K ATV isn’t seen via scan or the existing connection controllable.

Has anyone solved this?

I’ve had this same problem for over a year with my Apple TV 4K. My solution has been to have my Apple TV power plugged into a smart switch and an automation that cycles the power to reboot. It’s an ugly solution, but it works.

- alias: Reboot Apple TV
    platform: state
    entity_id: media_player.apple_tv
    to: 'unknown'
      minutes: 1
    - service: switch.turn_off
      entity_id: switch.sonoff_apple_tv_switch
    - delay: 00:00:01
    - service: switch.turn_on
      entity_id: switch.sonoff_apple_tv_switch

The 1 minute delay is to prevent false positives, which I used to have issues with as the state of the apple tv would sometimes be briefly ‘unknown’ when transistioning between states. Not sure why, but the reboot automation seems to be triggered most frequently when watching Netflix and leaving a show paused for a few minutes until the screen saver starts. Once I resume playback, the state goes to unknown i.e. “Establishing a connection…”

I have this exact same issue. My Apple TV 4th gen works great but my Apple TV 4k has the same intermittent issues. Reboot usually fixes it but it comes back in a week or two. Interesting idea about the smart switch to reboot the device, I will have to try it.

In troubleshooting I think this is more of an apple issue than Home Assistant / pyatv issue. According to the pyatv docs it is looking for the Bonjour service _appletv-v2._tcp.local to connect to the Apple TV. I downloaded a Bonjour scanner app (iOS app called Discovery in my case, but there are many others) and notice that when the issue occurs my Apple TV 4k is no longer listed in the _appletv-v2._tcp.local service but my Apple TV 4th gen is. After restarting the Apple TV 4k is listed in the _appletv-v2._tcp.local service again in the Discovery app and Home Assistant can connect. No idea what this means, I’m no Bonjour expert, but it’s a clue at least. Would be interested to know if others see the same thing or might have some insight.