home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.8k stars 30.06k forks source link

Apple TV integration constantly requires reconfiguration after tvOS 17 install #100572

Open mikesalz opened 1 year ago

mikesalz commented 1 year ago

The problem

Upgraded my 3 Apple TVs to tvOS 17 today, and now they require constant reconfiguration.

What version of Home Assistant Core has the issue?

core-2023.9.2

What was the last working version of Home Assistant Core?

core-2023.9.2

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Apple TV

Link to integration documentation on our website

https://www.home-assistant.io/integrations/apple_tv

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Not sure yet, but this might only manifest after restarting the Apple TV.

kevinhaas commented 2 months ago

I got another ATV4K and this is still an issue. I added it to HA, then performed an upgrade from 17.2 -> 17.5 and now it's unavailable in HA. Reloading the integration does nothing. I can't re-add the device to HA without factory resetting it either. Both my ATV4Ks entered this same bad state after updating firmware.

Trying to re-add the same ATV by name/IP without factory resetting it first results in: No devices found on the network

I can assign it the same IP after factory reset, and adding it to HA works fine. Some key is getting bungled up here.

If this isn't going to be addressed, it should be noted in the documentation at the least. "Don't add the device to HA until you update the firmware or you'll have to set it up again".

EDIT: I also had to turn off airplay entirely for this device to re-add, very strange. I never explicitly did this before. It asked me for an "RAOP" PIN but wouldn't accept what the screen displayed. My other ATV has airplay on and I don't remember this.

EDIT 2: Haha! Now my original ATV is not showing in HA! Good thing I really only use one app and don't actually need this integration. This one has reached my time limit of messing around.

Kerryliu commented 2 months ago

From what I can tell, all the “fixes” in this issue are temporary. After a while (for me it was a day) the Apple TV becomes available again.

kevinhaas commented 2 months ago

My original has never fallen off, and I just re-added my new one after factory re-setting and now it works as expected.

Most likely different issues.

EDIT: My original ATV device has fallen off now for the first time ever and the new one is also not connecting to HA after initially showing the correct status. Looks like messing with the configuration or adding other devices borks this beyond repair.

image

Here is Channels DVR which is playing on the ATV reporting correctly while both ATVs show the wrong statuses. I'm disabling this integration for now and will check back in a few months. Luckily I only use one app and can work around this.

image

Haha, my original stable ATV fell off the moment I added my new one, I just didn't notice. That was the only Apple device on my network and worked flawless for nearly a year. Looks like other people have issues with multiple Apple devices outside of ATVs also. No way I'm wasting time trying factory resetting again ;)

mscodemonkey commented 2 months ago

Hi postlund sorry to say it but I'm still getting this error. Log entry enclosed. Both Apple TV and HA are updated to latest as of today.

However, If I go into the HA interface and restart the Apple TV integration then it connects and all good.

Logger: homeassistant.components.apple_tv
Source: components/apple_tv/__init__.py:281
integration: Apple TV (documentation, issues)
First occurred: July 14, 2024 at 8:26:37 PM (2 occurrences)
Last logged: 3:02:22 AM

Failed to connect
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/http.py", line 463, in send_and_receive
    await pending_request.event.wait()
  File "/usr/local/lib/python3.12/asyncio/locks.py", line 212, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/http.py", line 462, in send_and_receive
    async with async_timeout.timeout(timeout):
  File "/usr/local/lib/python3.12/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.12/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyatv/core/protocol.py", line 56, in heartbeater
    await sender_func(message)
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/airplay/ap2_session.py", line 94, in _send_feedback
    await self.rtsp.feedback()
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/rtsp.py", line 248, in feedback
    return await self.exchange("POST", uri="/feedback", allow_error=allow_error)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/rtsp.py", line 293, in exchange
    resp = await self.connection.send_and_receive(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/http.py", line 474, in send_and_receive
    raise TimeoutError(f"no response to {method} {uri} ({protocol})") from ex
TimeoutError: no response to POST /feedback (RTSP/1.0)

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 281, in connect_once
    await self._connect_once(raise_missing_credentials)
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 266, in _connect_once
    await self._connect(conf, raise_missing_credentials)
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 386, in _connect
    self.atv = await connect(conf, self.hass.loop, session=session)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/__init__.py", line 155, in connect
    await atv.connect()
  File "/usr/local/lib/python3.12/site-packages/pyatv/core/facade.py", line 684, in connect
    if await setup_data.connect():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/mrp/__init__.py", line 1092, in _connect
    await protocol.start()
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/mrp/protocol.py", line 133, in start
    await self.connection.connect()
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/mrp/connection.py", line 104, in connect
    await self.loop.create_connection(lambda: self, self.host, self.port)
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1122, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1104, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1007, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.62', 7000)