Problems with AppleTV status

Hi!

I seem to have some issues with my AppleTV integration where the remote/media_player changes status from on → off and back again as shown in the picture. This hinders me (or at least I think) from running scripts against my ATV integration.

AppleTV is connected via ethernet cable just to rule out wifi problems. :slight_smile:

I have automations for dimming lights and bring them back to 40% on playing/idle and this works fine.

Any suggestions on what I can try to resolve this?

Thanks in advance!

1 Like

And since I could only post one embedded file in the first post here is the one showing the media_player

Can you try disabling auto-sleep on the device and see if that helps? I suspect that it goes to deep sleep, making the connection drop and trigger a re-connect. It becomes an endless loop basically.

Sounds reasonable. I’ll change the settings first thing in the morning, reload the integration in HA and update the post when I’m off work with the results.

Thanks for the swift reply and an awesome feature for HA!

1 Like

I was noticing the same issue on my end, and disabling sleep corrected it.
Is that the expected behavior though regarding sleep?

Thanks for the help,
CFC

I’ve disabled the sleep, restarted the integration but the issue continued so I removed the integration and added the ATV again but the issue is the same. Media_player going between unavailable and off.

The only thing I haven’t tried is actually restarting the ATV. So this will be the next step. @CFC the status of your ATV is always idle when not playing anything? I’m running the ATV 4K gen 1 if that is of any importance.

Yes @Ola.Lofdahl , that’s correct.
See the picture for a comparison between yesterday morning and this morning for the remote and media player entities.

CFC

As I see it, the alternative would be to just leave the media player in off state and not re-connect. But that means that the media player (in Home Assistant) will remain off until someone manually flicks it on. It’s not possible to “see” if a device and re-connect, at least not that I know off so I currently just re-connect when the connection is lost and that will wake the device up.

1 Like

To bad the solution you had didn´t solve this issue for me but glad it worked for you @CFC :slight_smile:

When looking in the logs this is what I can see as well:

I´ve just updated to 2021.6.0 and restarted everything without any progress. Any last ideas before I scrap my scripts that I wanted to run against the ATV

Ok, so, it’s the heartbeats that are acting up. Can you enable debug logs for pyatv (I.e add pyatv: debug under logs: in the logger component)? Would help me troubleshooting.

2021-06-03 20:35:19 DEBUG (MainThread) [pyatv.mrp.protocol] Sending periodic heartbeat 0
2021-06-03 20:35:19 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 >> Send (Data=082a122438313132354632442d314237452d343431302d424538372d3438443535323632353531312000)
2021-06-03 20:35:19 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 >> Send (Encrypted=b8c0af9f2112e027a3a61af0971efa7c5b23536f51de3ccb4b12771c96b570980d94fe52f46351939c94d32b92eb295676cb3a25388d1ca7848d)
2021-06-03 20:35:19 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 >> Send: Protobuf: type: GENERIC_MESSAGE
identifier: “81125F2D-1B7E-4410-BE87-48D552625511”
errorCode: NoError
2021-06-03 20:35:24 DEBUG (MainThread) [pyatv.mrp.protocol] heartbeat 0 failed
2021-06-03 20:35:24 DEBUG (MainThread) [pyatv.mrp.protocol] Sending periodic heartbeat 1
2021-06-03 20:35:24 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 >> Send (Data=082a122431453339314339322d373339372d343434342d424444392d3446413038383831343933432000)
2021-06-03 20:35:24 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 >> Send (Encrypted=0e09d383be387cc2c2df575e8fcb284e7a2bbcb82bc618424499580d063d67a010ae240ac5511fcbe36ea93a19dc28f95d07e5748eef7ffb1ee6)
2021-06-03 20:35:24 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 >> Send: Protobuf: type: GENERIC_MESSAGE
identifier: “1E391C92-7397-4444-BDD9-4FA08881493C”
errorCode: NoError
2021-06-03 20:35:29 ERROR (MainThread) [pyatv.mrp.protocol] heartbeat 1 failed after 2 tries
2021-06-03 20:35:29 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 Closing connection
2021-06-03 20:35:29 DEBUG (MainThread) [pyatv.mrp.protocol] Stopping heartbeat loop at 2
2021-06-03 20:35:29 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 Disconnected from device: None
2021-06-03 20:35:29 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 Closing connection
2021-06-03 20:35:29 DEBUG (MainThread) [pyatv.mrp.connection] 192.168.1.12:34570<->192.168.1.34:49153 Closing connection
2021-06-03 20:35:29 DEBUG (MainThread) [homeassistant.components.apple_tv] Starting connect loop
2021-06-03 20:35:29 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device 8B834307-C7AC-4391-B66B-E4B9F56671DB
2021-06-03 20:35:29 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.1.34
2021-06-03 20:35:34 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB with address 192.168.1.34, trying to scan
2021-06-03 20:35:34 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-06-03 20:35:34 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-06-03 20:35:34 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.1.12:0
2021-06-03 20:35:39 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB, trying later
2021-06-03 20:35:39 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 1 seconds
2021-06-03 20:35:40 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device 8B834307-C7AC-4391-B66B-E4B9F56671DB
2021-06-03 20:35:40 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.1.34
2021-06-03 20:35:45 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB with address 192.168.1.34, trying to scan
2021-06-03 20:35:45 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-06-03 20:35:45 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-06-03 20:35:45 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.1.12:0
2021-06-03 20:35:50 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB, trying later
2021-06-03 20:35:50 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 2 seconds
2021-06-03 20:35:52 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device 8B834307-C7AC-4391-B66B-E4B9F56671DB
2021-06-03 20:35:52 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.1.34
2021-06-03 20:35:57 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB with address 192.168.1.34, trying to scan
2021-06-03 20:35:57 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-06-03 20:35:57 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-06-03 20:35:57 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.1.12:0
2021-06-03 20:36:02 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB, trying later
2021-06-03 20:36:02 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 6 seconds
2021-06-03 20:36:08 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device 8B834307-C7AC-4391-B66B-E4B9F56671DB
2021-06-03 20:36:08 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.1.34
2021-06-03 20:36:13 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB with address 192.168.1.34, trying to scan
2021-06-03 20:36:13 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-06-03 20:36:13 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-06-03 20:36:13 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.1.12:0
2021-06-03 20:36:18 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB, trying later
2021-06-03 20:36:18 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 5 seconds
2021-06-03 20:36:23 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device 8B834307-C7AC-4391-B66B-E4B9F56671DB
2021-06-03 20:36:23 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.1.34
2021-06-03 20:36:28 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB with address 192.168.1.34, trying to scan
2021-06-03 20:36:28 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-06-03 20:36:28 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-06-03 20:36:28 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.1.12:0
2021-06-03 20:36:33 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB, trying later
2021-06-03 20:36:33 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 19 seconds
2021-06-03 20:36:52 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device 8B834307-C7AC-4391-B66B-E4B9F56671DB
2021-06-03 20:36:52 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.1.34
2021-06-03 20:36:57 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB with address 192.168.1.34, trying to scan
2021-06-03 20:36:57 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-06-03 20:36:57 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-06-03 20:36:57 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.1.12:0
2021-06-03 20:37:02 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB, trying later
2021-06-03 20:37:02 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 11 seconds
2021-06-03 20:37:13 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device 8B834307-C7AC-4391-B66B-E4B9F56671DB
2021-06-03 20:37:13 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.1.34
2021-06-03 20:37:18 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB with address 192.168.1.34, trying to scan
2021-06-03 20:37:18 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-06-03 20:37:18 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-06-03 20:37:18 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.1.12:0
2021-06-03 20:37:23 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device 8B834307-C7AC-4391-B66B-E4B9F56671DB, trying later
2021-06-03 20:37:23 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 51 seconds

So, hmm, it fails to find the device again when reconnecting. That’s a problem for sure. Not sure why that is, will have to think about that for a bit.

Did you ever find a solution? One of my Apple TVs has started doing this exact thing.

No it still looks the same when looking in the history/logs have more or less stopped trying to find a solution.

Did a clean install of my home assistant a week or two ago hoping it would be resolved, it was not. Opened up all the ports that the the pyatv knocks on, no improvement. Have removed the integration several times and added it from the discovery and manual but it still won’t stay connected.

@postlund have you made any progress or been able to replicate the issue?

I have not found any solution to this yet, but I suspect it’s zeroconf related. As I will move over to python-zeroconf from my homegrown implementation, I hope that will help. Unfortunately, Apple is deprecating MRP in tvOS 15, so I need to focus on getting another solution working for that. Otherwise there’s no support to control nor get metadata from a device anyway.

I got the same error like OP.
My Debug log:

2021-07-21 11:52:05 DEBUG (MainThread) [homeassistant.components.apple_tv] Starting connect loop
2021-07-21 11:52:05 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device C591895C-F915-4DC8-89D2-FCE04BF66FF4
2021-07-21 11:52:06 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.2.129
2021-07-21 11:52:07 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4 with address 192.168.2.129, trying to scan
2021-07-21 11:52:07 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-07-21 11:52:07 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-07-21 11:52:07 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.2.106:0
2021-07-21 11:52:07 DEBUG (MainThread) [pyatv.support.net] Binding on 172.17.0.1:0
2021-07-21 11:52:07 DEBUG (MainThread) [pyatv.support.net] Binding on 172.30.32.1:0
2021-07-21 11:52:08 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4, trying later
2021-07-21 11:52:08 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 1 seconds
2021-07-21 11:52:10 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device C591895C-F915-4DC8-89D2-FCE04BF66FF4
2021-07-21 11:52:10 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.2.129
2021-07-21 11:52:10 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4 with address 192.168.2.129, trying to scan
2021-07-21 11:52:10 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-07-21 11:52:10 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-07-21 11:52:10 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.2.106:0
2021-07-21 11:52:10 DEBUG (MainThread) [pyatv.support.net] Binding on 172.17.0.1:0
2021-07-21 11:52:10 DEBUG (MainThread) [pyatv.support.net] Binding on 172.30.32.1:0
2021-07-21 11:52:10 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4, trying later
2021-07-21 11:52:10 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 2 seconds
2021-07-21 11:52:12 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device C591895C-F915-4DC8-89D2-FCE04BF66FF4
2021-07-21 11:52:12 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.2.129
2021-07-21 11:52:12 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4 with address 192.168.2.129, trying to scan
2021-07-21 11:52:12 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-07-21 11:52:12 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-07-21 11:52:12 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.2.106:0
2021-07-21 11:52:13 DEBUG (MainThread) [pyatv.support.net] Binding on 172.17.0.1:0
2021-07-21 11:52:13 DEBUG (MainThread) [pyatv.support.net] Binding on 172.30.32.1:0
2021-07-21 11:52:15 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4, trying later
2021-07-21 11:52:15 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 7 seconds
2021-07-21 11:52:22 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device C591895C-F915-4DC8-89D2-FCE04BF66FF4
2021-07-21 11:52:22 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.2.129
2021-07-21 11:52:22 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4 with address 192.168.2.129, trying to scan
2021-07-21 11:52:22 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-07-21 11:52:22 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-07-21 11:52:22 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.2.106:0
2021-07-21 11:52:22 DEBUG (MainThread) [pyatv.support.net] Binding on 172.17.0.1:0
2021-07-21 11:52:22 DEBUG (MainThread) [pyatv.support.net] Binding on 172.30.32.1:0
2021-07-21 11:52:23 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4, trying later
2021-07-21 11:52:23 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 5 seconds
2021-07-21 11:52:28 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device C591895C-F915-4DC8-89D2-FCE04BF66FF4
2021-07-21 11:52:28 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.2.129
2021-07-21 11:52:28 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4 with address 192.168.2.129, trying to scan
2021-07-21 11:52:28 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-07-21 11:52:28 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-07-21 11:52:28 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.2.106:0
2021-07-21 11:52:28 DEBUG (MainThread) [pyatv.support.net] Binding on 172.17.0.1:0
2021-07-21 11:52:28 DEBUG (MainThread) [pyatv.support.net] Binding on 172.30.32.1:0
2021-07-21 11:52:28 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4, trying later
2021-07-21 11:52:28 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 31 seconds
2021-07-21 11:52:59 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device C591895C-F915-4DC8-89D2-FCE04BF66FF4
2021-07-21 11:52:59 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.2.129
2021-07-21 11:52:59 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4 with address 192.168.2.129, trying to scan
2021-07-21 11:52:59 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-07-21 11:52:59 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-07-21 11:52:59 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.2.106:0
2021-07-21 11:52:59 DEBUG (MainThread) [pyatv.support.net] Binding on 172.17.0.1:0
2021-07-21 11:52:59 DEBUG (MainThread) [pyatv.support.net] Binding on 172.30.32.1:0
2021-07-21 11:52:59 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4, trying later
2021-07-21 11:52:59 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 4 seconds
2021-07-21 11:53:03 DEBUG (MainThread) [homeassistant.components.apple_tv] Discovering device C591895C-F915-4DC8-89D2-FCE04BF66FF4
2021-07-21 11:53:03 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.2.129
2021-07-21 11:53:03 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4 with address 192.168.2.129, trying to scan
2021-07-21 11:53:03 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-07-21 11:53:03 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-07-21 11:53:03 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.2.106:0
2021-07-21 11:53:03 DEBUG (MainThread) [pyatv.support.net] Binding on 172.17.0.1:0
2021-07-21 11:53:03 DEBUG (MainThread) [pyatv.support.net] Binding on 172.30.32.1:0
2021-07-21 11:53:03 DEBUG (MainThread) [homeassistant.components.apple_tv] Failed to find device C591895C-F915-4DC8-89D2-FCE04BF66FF4, trying later
2021-07-21 11:53:03 DEBUG (MainThread) [homeassistant.components.apple_tv] Reconnecting in 84 seconds

But after I go down to 2021.7.2 it worked again.

Maybe this can help somehow?

So no other changes made than reverting to an older version? I’ve had this issue for quite some time and no upgrade has solved this issue.

What’s your setup like @Berb ?
I run my HA in Core version on Raspbian OS thinking if this could be what is causing the issue for me.

No i have not made any changes. After the update to 2021.7.3 the problem occurred. Back to 2021.7.2 it ran without problems. Update again on 2021.7.3 and I had the problem again.

I run my HA on a raspberry installed by this tutorial

Okey so then it doesn’t matter if you run the native OS or the core version.

I was actually thinking about getting a second PI just for running HA in the supervised mode to see if that would change anything but then I don’t need to do it since we now know it’s not working there either.

I’m in no hurry to have this issue resolved, would just be a nice feature to be able to launch specific shows as scripts from HA. :slight_smile:

@postlund found this in the logs today:
2021-07-23 08:58:35 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 08:58:35 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 08:59:16 ERROR (MainThread) [pyatv.mrp.protocol] heartbeat 1 failed after 2 tries

2021-07-23 09:04:49 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:04:49 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:05:29 ERROR (MainThread) [pyatv.mrp.protocol] heartbeat 1 failed after 2 tries

2021-07-23 09:11:26 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:11:26 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:12:08 ERROR (MainThread) [pyatv.mrp.protocol] heartbeat 1 failed after 2 tries

2021-07-23 09:20:16 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:20:16 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:20:57 ERROR (MainThread) [pyatv.mrp.protocol] heartbeat 1 failed after 2 tries

2021-07-23 09:21:12 WARNING (MainThread) [zeroconf] Choked at offset 0 while unpacking b’\n\xba\x10\x00’

Traceback (most recent call last):

File “/srv/homeassistant/lib/python3.8/site-packages/zeroconf/_protocol.py”, line 99, in init

self.read_header()

File “/srv/homeassistant/lib/python3.8/site-packages/zeroconf/_protocol.py”, line 137, in read_header

) = self.unpack(b’!6H’)

File “/srv/homeassistant/lib/python3.8/site-packages/zeroconf/_protocol.py”, line 124, in unpack

info = struct.unpack(format_, self.data[self.offset : self.offset + length])

struct.error: unpack requires a buffer of 12 bytes

2021-07-23 09:21:16 ERROR (MainThread) [pyatv.support.mdns] exception during data handling

Traceback (most recent call last):

File “/srv/homeassistant/lib/python3.8/site-packages/pyatv/support/mdns.py”, line 256, in datagram_received

delegate.datagram_received(data, addr)

File “/srv/homeassistant/lib/python3.8/site-packages/pyatv/support/mdns.py”, line 366, in datagram_received

services = parse_services(DnsMessage().unpack(data))

File “/srv/homeassistant/lib/python3.8/site-packages/pyatv/support/dns.py”, line 365, in unpack

header = DnsHeader.unpack_read(buffer)

File “/srv/homeassistant/lib/python3.8/site-packages/pyatv/support/dns.py”, line 286, in unpack_read

return cls._make(unpack_stream(">6H", buffer))

File “/srv/homeassistant/lib/python3.8/site-packages/pyatv/support/dns.py”, line 22, in unpack_stream

return struct.unpack(fmt, buffer.read(size))

struct.error: unpack requires a buffer of 12 bytes

2021-07-23 09:26:11 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:26:11 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:26:41 WARNING (MainThread) [pyatv.mrp.protocol] There were 1 outstanding requests

2021-07-23 09:26:41 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV “MojitoTV”

2021-07-23 09:26:41 ERROR (MainThread) [pyatv.mrp.protocol] heartbeat 1 failed after 2 tries

2021-07-23 09:26:41 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:26:41 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:27:23 ERROR (MainThread) [pyatv.mrp.protocol] heartbeat 1 failed after 2 tries

2021-07-23 09:27:23 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly.

2021-07-23 09:27:23 ERROR (MainThread) [homeassistant] Error doing job: An open stream object is being garbage collected; call “stream.close()” explicitly