postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
891 stars 100 forks source link

Regular Errors, Failed to connect / Failed to set up remote control channel #2050

Closed pickett closed 1 year ago

pickett commented 1 year ago

Describe the bug

HA Apple TV integration throws constant errors and warnings including "Failed to connect" "Failed to set up remote control channel" and "Lost Connection" I recognize this is likely a tricky issue to track down but I'd like to help in any way possible as I can never use the Apple TV integration and I know others have experienced it as well.

My setup:

Home Assistant 2023.6.1 Supervisor 2023.06.2 Operating System 10.2 Apple TV 4K, tvOS 16.5

Failed to connect error:

Source: components/apple_tv/__init__.py:324 
Integration: Apple TV ([documentation](https://www.home-assistant.io/integrations/apple_tv), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+apple_tv%22)) 
First occurred: June 13, 2023 at 2:51:29 PM (67 occurrences) 
Last logged: 1:49:55 PM

Failed to connect
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/mrp/protocol.py", line 274, in _receive
    await semaphore.acquire()
  File "/usr/local/lib/python3.11/asyncio/locks.py", line 387, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 222, in connect_once
    await self._connect(conf, raise_missing_credentials)
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 324, in _connect
    self.atv = await connect(conf, self.hass.loop, session=session)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/__init__.py", line 135, in connect
    await atv.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/core/facade.py", line 638, in connect
    if await setup_data.connect():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/mrp/__init__.py", line 996, in _connect
    await protocol.start()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/mrp/protocol.py", line 142, in start
    self.device_info = await self.send_and_receive(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/mrp/protocol.py", line 261, in send_and_receive
    return await self._receive(identifier, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/mrp/protocol.py", line 273, in _receive
    async with async_timeout.timeout(timeout):
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.11/site-packages/async_timeout/__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError
TimeoutError

Failed to set up remote control channel error:

Logger: pyatv.protocols.airplay
Source: /usr/local/lib/python3.11/site-packages/pyatv/protocols/airplay/__init__.py:266 
First occurred: June 13, 2023 at 2:51:24 PM (253 occurrences) 
Last logged: 1:49:48 PM

Failed to set up remote control channel
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/airplay/__init__.py", line 257, in _connect_rc
    await control.start(str(core.config.address), control_port, credentials)
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/airplay/remote_control.py", line 55, in start
    self.connection = await http_connect(address, control_port)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/support/http.py", line 559, in http_connect
    _, connection = await loop.create_connection(HttpConnection, address, port)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('192.168.7.248', 7000)

Lost Connection Warning:

Logger: homeassistant.components.apple_tv
Source: components/apple_tv/__init__.py:169 
Integration: Apple TV ([documentation](https://www.home-assistant.io/integrations/apple_tv), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+apple_tv%22)) 
First occurred: June 13, 2023 at 2:48:27 PM (633 occurrences)
Last logged: 1:54:23 PM

Connection lost to Apple TV "Basement Theatre Apple TV"

Error log

A sample of debug logs - there is a ton of output so if you could guide me on how to share longer debug files I would happily share them.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 222, in connect_once
    await self._connect(conf, raise_missing_credentials)
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 324, in _connect
    self.atv = await connect(conf, self.hass.loop, session=session)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/__init__.py", line 135, in connect
    await atv.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/core/facade.py", line 638, in connect
    if await setup_data.connect():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/__init__.py", line 472, in _connect
    await api.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/api.py", line 126, in connect
    await self._protocol.start()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/protocol.py", line 101, in start
    await self.connection.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/connection.py", line 80, in connect
    await self.loop.create_connection(lambda: self, self.host, self.port)
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.7.248', 49153)
2023-06-13 23:14:12.430 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:15:13.995 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:17:02.043 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:17:39.349 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:18:10.002 WARNING (MainThread) [pyatv.support.http] Got response without having a request: HttpResponse(protocol='RTSP', version='1.0', code=200, message='OK', headers={'date': 'Wed, 14 Jun 2023 03:18:10 GMT', 'content-length': '55', 'content-type': 'application/x-apple-binary-plist', 'server': 'AirTunes/690.7.1', 'cseq': '4'}, body=b'bplist00\xd1\x01\x02Wstreams\xa0\x08\x0b\x13\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14')
2023-06-13 23:18:14.010 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:18:40.116 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:19:52.350 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:20:54.003 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:22:42.127 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:24:34.828 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:25:34.803 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:26:40.472 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:28:34.657 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:29:20.910 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:30:22.880 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:31:22.822 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:32:10.107 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:33:13.754 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:33:51.091 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:34:21.778 WARNING (MainThread) [pyatv.support.http] Got response without having a request: HttpResponse(protocol='RTSP', version='1.0', code=200, message='OK', headers={'date': 'Wed, 14 Jun 2023 03:34:21 GMT', 'content-length': '55', 'content-type': 'application/x-apple-binary-plist', 'server': 'AirTunes/690.7.1', 'cseq': '4'}, body=b'bplist00\xd1\x01\x02Wstreams\xa0\x08\x0b\x13\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14')
2023-06-13 23:34:25.785 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:34:51.876 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:35:52.074 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:36:58.610 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:38:47.367 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:40:39.869 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:41:41.748 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:43:35.766 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:44:19.971 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:45:23.413 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:47:34.862 ERROR (MainThread) [pyatv.protocols.airplay] Failed to set up remote control channel
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/airplay/__init__.py", line 257, in _connect_rc
    await control.start(str(core.config.address), control_port, credentials)
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/airplay/remote_control.py", line 55, in start
    self.connection = await http_connect(address, control_port)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/support/http.py", line 559, in http_connect
    _, connection = await loop.create_connection(HttpConnection, address, port)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
TimeoutError: [Errno 110] Connect call failed ('192.168.7.248', 7000)
2023-06-13 23:47:53.297 ERROR (MainThread) [homeassistant.components.apple_tv] Failed to connect
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 222, in connect_once
    await self._connect(conf, raise_missing_credentials)
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 324, in _connect
    self.atv = await connect(conf, self.hass.loop, session=session)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/__init__.py", line 135, in connect
    await atv.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/core/facade.py", line 638, in connect
    if await setup_data.connect():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/__init__.py", line 472, in _connect
    await api.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/api.py", line 126, in connect
    await self._protocol.start()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/protocol.py", line 101, in start
    await self.connection.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/connection.py", line 80, in connect
    await self.loop.create_connection(lambda: self, self.host, self.port)
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.7.248', 49153)
2023-06-13 23:48:52.523 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Basement Theatre Apple TV"
2023-06-13 23:49:08.561 ERROR (MainThread) [pyatv.protocols.airplay] Failed to set up remote control channel
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/airplay/__init__.py", line 257, in _connect_rc
    await control.start(str(core.config.address), control_port, credentials)
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/airplay/remote_control.py", line 55, in start
    self.connection = await http_connect(address, control_port)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/support/http.py", line 559, in http_connect
    _, connection = await loop.create_connection(HttpConnection, address, port)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.7.248', 7000)
2023-06-13 23:49:11.637 ERROR (MainThread) [homeassistant.components.apple_tv] Failed to connect
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 222, in connect_once
    await self._connect(conf, raise_missing_credentials)
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 324, in _connect
    self.atv = await connect(conf, self.hass.loop, session=session)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/__init__.py", line 135, in connect
    await atv.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/core/facade.py", line 638, in connect
    if await setup_data.connect():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/__init__.py", line 472, in _connect
    await api.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/api.py", line 126, in connect
    await self._protocol.start()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/protocol.py", line 101, in start
    await self.connection.connect()
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/companion/connection.py", line 80, in connect
    await self.loop.create_connection(lambda: self, self.host, self.port)
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.7.248', 49153)
2023-06-13 23:49:27.953 ERROR (MainThread) [pyatv.protocols.airplay] Failed to set up remote control channel
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/airplay/__init__.py", line 257, in _connect_rc
    await control.start(str(core.config.address), control_port, credentials)
  File "/usr/local/lib/python3.11/site-packages/pyatv/protocols/airplay/remote_control.py", line 55, in start
    self.connection = await http_connect(address, control_port)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyatv/support/http.py", line 559, in http_connect
    _, connection = await loop.create_connection(HttpConnection, address, port)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.7.248', 7000)

How to reproduce the bug?

The disconnects are constant on my system. I wish I had better repro steps but these logs just continuously come in.

What is expected behavior?

These warnings and disconnects rapidly cycle the state management of the device and jump it from "Apple TV On" to "Unknown". Expected behavior is for there not to be constant disconnects and errors which at times cause automations to fail and states to be reported inaccurately.

Operating System

Mac

Python

3.6

pyatv

Latest

Device

Apple TV 4K, tvOS 16.5

Additional context

As I said above, I am happy to help provide even more debug logs or strip everything down, remove the integrations, start fresh and share debug logs. Guidance is really what I need.

pickett commented 1 year ago

Screenshot 2023-06-14 at 2 12 54 PM

And as far as how this really manifests... see above. I wasn't interacting with the Apple TV at all during this time and I'm pretty sure it was just asleep.

postlund commented 1 year ago

This looks more like a network/firewall problem to me. Do you have any exotic setup? Are all devices on the same network?

pickett commented 1 year ago

Hmmm. I don't think it's an exotic setup, just a few Eero routers with an unmanaged network switch - everything on the same network.

pickett commented 1 year ago

Apple TV is connected via Ethernet to the same switch that connects to the Mac running HA in a VM.

postlund commented 1 year ago

Hmm, that sounds strange. Would it be possible for you to set up a plain core install (without OS, supervisor or anything) and just run the Apple TV integration? An additional thing to try is using atvrmote to listen for push updates (e.g. atvremote ... push_updates) and see if it disconnects in the same manner.

postlund commented 1 year ago

Errno 113 is "no route to host", which is why I'm suspecting a network error btw.

pickett commented 1 year ago

I am willing to try anything. Will read up on how to do that.

On Thu, Jun 15, 2023 at 7:36 AM Pierre Ståhl @.***> wrote:

Errno 113 is "no route to host", which is why I'm suspecting a network error btw.

— Reply to this email directly, view it on GitHub https://github.com/postlund/pyatv/issues/2050#issuecomment-1592877059, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAWLWQ6MANOGTRZYKF6SJDXLLXVJANCNFSM6AAAAAAZGXPW5Y . You are receiving this because you authored the thread.Message ID: @.***>

postlund commented 1 year ago

That would be great! Let me know if you have any questions, I'll try to answer as good as I can.

pickett commented 1 year ago

Will do. I’ll start with atV remote since that seems to be an easier first step. If the same behavior I’ll look into a new install.

On Thu, Jun 15, 2023 at 7:57 AM Pierre Ståhl @.***> wrote:

That would be great! Let me know if you have any questions, I'll try to answer as good as I can.

— Reply to this email directly, view it on GitHub https://github.com/postlund/pyatv/issues/2050#issuecomment-1592902787, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAWLWQF7OR6ISDVS4JWDXTXLL2AZANCNFSM6AAAAAAZGXPW5Y . You are receiving this because you authored the thread.Message ID: @.***>

pickett commented 1 year ago

This ended up being a local configuration issue. And it was indeed a firewall issue. I had at some point firewalled the wifi connectivity from the device to force it to use Ethernet. Seems that was having some unexpected results. Thanks for the tip on what the error was referring to!