Timeout with Apple TV (affecting automations)

Great to see the implementation of the Apple TV platform! Just using it for state information at the moment and dimming lights during playback/bringing them back up to full brightness when stopped/paused.

I’ve been seeing erratic performance of this automation and it appears that it’s due to HA timing out when trying to connect. The automations appear to be working fine, the lights will dim when playback on the appleTV starts, but quickly they will go back up to full brightness- correctly triggering a scene per the automation as I believe “playing” is nolonger the current state from the apple tv. The logbook shows the apple TV and the automation working correctly- however it is just happening way to frequently. My logs are full of:
17-02-13 01:39:34 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 01:39:45 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 01:39:56 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 01:40:07 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 01:40:12 ERROR (MainThread) [homeassistant.components.media_player.apple_tv] failed to connect to Apple TV ([Errno 113] Cannot connect to host 10.0.0.93:3689 ssl:False [Can not connect to 10.0.0.93:3689 [Connect call failed ('10.0.0.93', 3689)]]) 17-02-13 03:39:21 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 03:39:33 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 04:27:33 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 04:27:44 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 04:27:55 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 04:28:06 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 04:28:16 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 04:28:27 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 04:28:38 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 04:28:49 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:12:00 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:12:11 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:12:22 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:12:33 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:12:44 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:12:55 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:13:06 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:13:17 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:13:28 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:13:39 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 06:13:50 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 07:27:51 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 07:28:02 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:02:36 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:02:46 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:02:57 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:03:08 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:03:19 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:03:30 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:03:41 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:03:52 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:04:03 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:04:14 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 09:04:25 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:07:08 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:07:19 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:07:30 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:07:41 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:07:52 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:08:03 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:08:14 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:08:25 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:08:36 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:08:47 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:08:58 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:09:09 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:09:20 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:09:31 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:09:43 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:09:54 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV 17-02-13 15:10:05 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] timed out while connecting to Apple TV

Is there any value I can set to extend the polling time or is there anything I can do to ensure my automations run smoother? I’ll post those automation snippets if desired/helpful.

For what it’s worth- I see this issue with the ChromeCast as well and others in the forum have posted the same errors i’ve been seeing (chromecast.py socket timeouts). I have not had this problem with Kodi- HA does not appear to timeout on that platform.
Thanks!

Hi!

Thanks for the report! I had this issue too until recently, when it just suddenly started working like “normal” again. I have written a bit about in here: https://github.com/postlund/pyatv/issues/23. The issue you are seeing likely stem from the same root cause as I could see those errors too. My guess is that it has something to do with power management. What’s interesting is that you seem to have this problem when you are actually using your Apple TV, is that correct?

It would be very useful to me if you could try to ping your Apple TV (from the device you run Home Assistant on) and make sure that works. Also, if you could try the instructions I have written here as well: Apple TV turning on randomly after addition of discovery, that would help troubleshooting a lot.

That’s correct yes- however there are a lot of errors and some might be from while I wasn’t using it.
Here’s the pings from my RPi to my apple TV. They are both wired on the same switch:

pi@hass:~ $ ping 10.0.0.88
PING 10.0.0.88 (10.0.0.88) 56(84) bytes of data.
64 bytes from 10.0.0.88: icmp_seq=1 ttl=64 time=2.23 ms
64 bytes from 10.0.0.88: icmp_seq=2 ttl=64 time=0.941 ms
64 bytes from 10.0.0.88: icmp_seq=3 ttl=64 time=1.84 ms
64 bytes from 10.0.0.88: icmp_seq=4 ttl=64 time=0.808 ms
64 bytes from 10.0.0.88: icmp_seq=5 ttl=64 time=0.919 ms
64 bytes from 10.0.0.88: icmp_seq=6 ttl=64 time=1.72 ms
64 bytes from 10.0.0.88: icmp_seq=7 ttl=64 time=1.97 ms
64 bytes from 10.0.0.88: icmp_seq=8 ttl=64 time=0.738 ms
64 bytes from 10.0.0.88: icmp_seq=9 ttl=64 time=1.80 ms
64 bytes from 10.0.0.88: icmp_seq=10 ttl=64 time=2.57 ms
64 bytes from 10.0.0.88: icmp_seq=11 ttl=64 time=2.74 ms
64 bytes from 10.0.0.88: icmp_seq=12 ttl=64 time=2.75 ms
64 bytes from 10.0.0.88: icmp_seq=13 ttl=64 time=2.81 ms
64 bytes from 10.0.0.88: icmp_seq=14 ttl=64 time=1.68 ms
64 bytes from 10.0.0.88: icmp_seq=15 ttl=64 time=1.84 ms
64 bytes from 10.0.0.88: icmp_seq=16 ttl=64 time=2.78 ms
64 bytes from 10.0.0.88: icmp_seq=17 ttl=64 time=2.78 ms
64 bytes from 10.0.0.88: icmp_seq=18 ttl=64 time=2.66 ms
64 bytes from 10.0.0.88: icmp_seq=19 ttl=64 time=0.851 ms
64 bytes from 10.0.0.88: icmp_seq=20 ttl=64 time=1.85 ms
64 bytes from 10.0.0.88: icmp_seq=21 ttl=64 time=2.31 ms
64 bytes from 10.0.0.88: icmp_seq=22 ttl=64 time=2.18 ms
64 bytes from 10.0.0.88: icmp_seq=23 ttl=64 time=2.65 ms
64 bytes from 10.0.0.88: icmp_seq=24 ttl=64 time=2.68 ms
64 bytes from 10.0.0.88: icmp_seq=25 ttl=64 time=0.875 ms
64 bytes from 10.0.0.88: icmp_seq=26 ttl=64 time=1.81 ms
64 bytes from 10.0.0.88: icmp_seq=27 ttl=64 time=2.15 ms
64 bytes from 10.0.0.88: icmp_seq=28 ttl=64 time=2.77 ms
64 bytes from 10.0.0.88: icmp_seq=29 ttl=64 time=2.72 ms
64 bytes from 10.0.0.88: icmp_seq=30 ttl=64 time=1.17 ms
64 bytes from 10.0.0.88: icmp_seq=31 ttl=64 time=1.86 ms
64 bytes from 10.0.0.88: icmp_seq=32 ttl=64 time=2.15 ms
64 bytes from 10.0.0.88: icmp_seq=33 ttl=64 time=0.958 ms
64 bytes from 10.0.0.88: icmp_seq=34 ttl=64 time=0.991 ms
64 bytes from 10.0.0.88: icmp_seq=35 ttl=64 time=1.94 ms
64 bytes from 10.0.0.88: icmp_seq=36 ttl=64 time=2.68 ms
64 bytes from 10.0.0.88: icmp_seq=37 ttl=64 time=0.852 ms
64 bytes from 10.0.0.88: icmp_seq=38 ttl=64 time=1.82 ms
64 bytes from 10.0.0.88: icmp_seq=39 ttl=64 time=2.57 ms
64 bytes from 10.0.0.88: icmp_seq=40 ttl=64 time=2.70 ms
64 bytes from 10.0.0.88: icmp_seq=41 ttl=64 time=2.77 ms
64 bytes from 10.0.0.88: icmp_seq=42 ttl=64 time=0.799 ms
64 bytes from 10.0.0.88: icmp_seq=43 ttl=64 time=1.05 ms
64 bytes from 10.0.0.88: icmp_seq=44 ttl=64 time=1.82 ms
64 bytes from 10.0.0.88: icmp_seq=45 ttl=64 time=1.85 ms
64 bytes from 10.0.0.88: icmp_seq=46 ttl=64 time=0.901 ms
64 bytes from 10.0.0.88: icmp_seq=47 ttl=64 time=1.79 ms
64 bytes from 10.0.0.88: icmp_seq=48 ttl=64 time=1.76 ms
64 bytes from 10.0.0.88: icmp_seq=49 ttl=64 time=1.83 ms
64 bytes from 10.0.0.88: icmp_seq=50 ttl=64 time=2.74 ms
64 bytes from 10.0.0.88: icmp_seq=51 ttl=64 time=0.868 ms
64 bytes from 10.0.0.88: icmp_seq=52 ttl=64 time=1.85 ms
64 bytes from 10.0.0.88: icmp_seq=53 ttl=64 time=2.63 ms
64 bytes from 10.0.0.88: icmp_seq=54 ttl=64 time=0.854 ms
64 bytes from 10.0.0.88: icmp_seq=55 ttl=64 time=1.84 ms
64 bytes from 10.0.0.88: icmp_seq=56 ttl=64 time=2.12 ms
64 bytes from 10.0.0.88: icmp_seq=57 ttl=64 time=2.03 ms
64 bytes from 10.0.0.88: icmp_seq=58 ttl=64 time=2.42 ms
64 bytes from 10.0.0.88: icmp_seq=59 ttl=64 time=0.820 ms
64 bytes from 10.0.0.88: icmp_seq=60 ttl=64 time=1.86 ms
64 bytes from 10.0.0.88: icmp_seq=61 ttl=64 time=2.77 ms
64 bytes from 10.0.0.88: icmp_seq=62 ttl=64 time=1.49 ms
64 bytes from 10.0.0.88: icmp_seq=63 ttl=64 time=1.77 ms
64 bytes from 10.0.0.88: icmp_seq=64 ttl=64 time=1.92 ms
64 bytes from 10.0.0.88: icmp_seq=65 ttl=64 time=2.74 ms
64 bytes from 10.0.0.88: icmp_seq=66 ttl=64 time=1.15 ms
64 bytes from 10.0.0.88: icmp_seq=67 ttl=64 time=1.72 ms
64 bytes from 10.0.0.88: icmp_seq=68 ttl=64 time=1.90 ms
64 bytes from 10.0.0.88: icmp_seq=69 ttl=64 time=2.31 ms
64 bytes from 10.0.0.88: icmp_seq=70 ttl=64 time=2.77 ms
64 bytes from 10.0.0.88: icmp_seq=71 ttl=64 time=2.77 ms
64 bytes from 10.0.0.88: icmp_seq=72 ttl=64 time=2.66 ms
64 bytes from 10.0.0.88: icmp_seq=73 ttl=64 time=2.90 ms
64 bytes from 10.0.0.88: icmp_seq=74 ttl=64 time=1.61 ms
64 bytes from 10.0.0.88: icmp_seq=75 ttl=64 time=1.86 ms
64 bytes from 10.0.0.88: icmp_seq=76 ttl=64 time=1.81 ms
64 bytes from 10.0.0.88: icmp_seq=77 ttl=64 time=1.83 ms
64 bytes from 10.0.0.88: icmp_seq=78 ttl=64 time=1.84 ms
64 bytes from 10.0.0.88: icmp_seq=79 ttl=64 time=1.02 ms
64 bytes from 10.0.0.88: icmp_seq=80 ttl=64 time=1.86 ms
64 bytes from 10.0.0.88: icmp_seq=81 ttl=64 time=2.76 ms
^C
--- 10.0.0.88 ping statistics ---
81 packets transmitted, 81 received, 0% packet loss, time 80089ms
rtt min/avg/max/mdev = 0.738/1.932/2.907/0.661 ms
pi@hass:~ $ 

Thanks!

Quick question: do you happen to own an AirPort Express or Extreme? If that is the case, can you try to reboot the Apple TV and the AirPort and see if it still happens?

I’ve got a similar problem with my AppleTV component. I’ve got an automation setup to dim the lights when something is playing, and raise them when it’s paused/stopped. If I tie the automation to monitor the play/pause/stop state of the AppleTV, my lights fade in and out about every 10secs.

I’ve posted a similar, possibly related thread here;
https://community.home-assistant.io/t/apple-tv-apple-tv-failed-to-login/

Oh, that must be a bug. Polling is done every 10 seconds but that should not trigger state changes unless anything changes. This will however be fixed once I push support for “push updates”. It will not make it for the release this weekend, but probably the next one.

1 Like