core icon indicating copy to clipboard operation
core copied to clipboard

HA -> AppleTV won’t reconnect after ATV reboot without integration restart

Open StSaens opened this issue 1 year ago • 2 comments

The problem

After i rebooted my appletv4k the connection between HA and the ATV won’t be re-initialized until after I restart the integration

What version of Home Assistant Core has the issue?

core 2024.8.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

[apple_tv]

Link to integration documentation on our website

No response

Diagnostics information

Logger: homeassistant.components.apple_tv Source: components/apple_tv/init.py:282 integration: Apple TV (documentation, issues) First occurred: 09:18:53 (1 occurrences) Last logged: 09:18:53

Failed to connect Traceback (most recent call last): File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut ^^^^^^^^^ File "/usr/local/lib/python3.12/asyncio/locks.py", line 212, in wait await fut asyncio.exceptions.CancelledError

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/support/init.py", line 71, in error_handler return await func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/companion/protocol.py", line 120, in _setup_encryption await pair_verifier.verify_credentials() File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/companion/auth.py", line 135, in verify_credentials resp = await self.protocol.exchange_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/companion/protocol.py", line 142, in exchange_auth return await self._exchange_generic_opack(frame_type, data, identifier, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/companion/protocol.py", line 167, in _exchange_generic_opack unpacked_object = await self._queues[identifier].wait(timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyatv/support/collections.py", line 160, in wait await asyncio.wait_for(self._event.wait(), timeout) File "/usr/local/lib/python3.12/asyncio/tasks.py", line 519, in wait_for async with timeouts.timeout(timeout): File "/usr/local/lib/python3.12/asyncio/timeouts.py", line 115, in aexit raise TimeoutError from exc_val TimeoutError

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

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/apple_tv/init.py", line 282, in connect_once await self._connect_once(raise_missing_credentials) File "/usr/src/homeassistant/homeassistant/components/apple_tv/init.py", line 267, in _connect_once await self._connect(conf, raise_missing_credentials) File "/usr/src/homeassistant/homeassistant/components/apple_tv/init.py", line 387, 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/companion/init.py", line 571, in _connect await api.connect() File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/companion/api.py", line 143, in connect await self._protocol.start() File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/companion/protocol.py", line 108, in start await error_handler(self._setup_encryption, exceptions.AuthenticationError) File "/usr/local/lib/python3.12/site-packages/pyatv/support/init.py", line 73, in error_handler raise exceptions.ConnectionFailedError(str(ex)) from ex pyatv.exceptions.ConnectionFailedError

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

StSaens avatar Aug 23 '24 10:08 StSaens

Hey there @postlund, mind taking a look at this issue as it has been labeled with an integration (apple_tv) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of apple_tv can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign apple_tv Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


apple_tv documentation apple_tv source (message by IssueLinks)

home-assistant[bot] avatar Aug 23 '24 12:08 home-assistant[bot]

+1 same thing here, integration will randomly stop working until I restart it.

pauloruberto avatar Sep 19 '24 13:09 pauloruberto

Same story. Docker installation of the Core 2024.9.3

Pristavkin avatar Oct 24 '24 12:10 Pristavkin

Added the "Home Assistant Core Integration: Reload config entry" action to my 'Watch TV' automation. It works, but it's definitely a hack and a workaround.

action:
#... skipped steps ...
  - action: homeassistant.reload_config_entry
    metadata: {}
    data: {}
    target:
      device_id: # long device_id here. Set it up from UI

image

Pristavkin avatar Oct 24 '24 13:10 Pristavkin

+1 Same issue here Core 2024.11.3 (HAOS): AppleTV won’t reconnect after ATV reboot. I have t restart the integration.

EvLnY avatar Nov 23 '24 16:11 EvLnY

This issue is still here in Core 2024.12.1 (HAOS). Still need to reboot from the watch tv automation.

Pristavkin avatar Dec 23 '24 07:12 Pristavkin

+1 - Same issue after ATV Restart

mvinsys avatar Jan 13 '25 08:01 mvinsys

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

this issue is not resolved. Core 2025.4.4

MariekeVDA avatar May 01 '25 09:05 MariekeVDA