maxileith / homebridge-appletv-enhanced

Homebridge plugin that exposes Apple TVs with features that should be native to Apple HomeKit.
MIT License
185 stars 3 forks source link

Won't connect or detect Apple TV after upgrade to tvOS 18 public beta #514

Closed stuartwood-apple closed 1 month ago

stuartwood-apple commented 2 months ago

Preconditions

Analysis

Apple TV Enhanced gets stuck in the discovery phase of finding Apple TV's on the network since my Apple TV upgraded to tvOS 18 last night.

Expected Behavior

Connect to my Apple TV

Steps To Reproduce

The issues happens when HomeBridge is running or is restarted... currently all the time no matter what I try.

Logs

[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] Initializing AppleTVEnhanced platform...
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [I] Platform: Finished initializing platform: Apple TV Enhanced
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [D] Platform: Executed didFinishLaunching callback
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [I] Update check: The update checker is configured to check for updates between 3:00 and 3:59, excluding betas. Auto updating is turned off.
Setup Payload:
X-HM://00240CBY8VK3Z
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐     
    │ 326-01-984 │     
    └────────────┘     

[7/29/2024, 1:40:19 PM] Homebridge v1.8.4 (HAP v0.12.2) (Homebridge 8CDB) is running on port 51363.
[7/29/2024, 1:40:19 PM] 

NOTICE TO USERS AND PLUGIN DEVELOPERS
> Homebridge 2.0 is on the way and brings some breaking changes to existing plugins.
> Please visit the following link to learn more about the changes and how to prepare:
> https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0

[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [D] Update check: The latest AppleTV Enhanced version (excluding betas) is 1.5.1
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [I] Update check: You are using the latest version of AppleTV Enhanced (excluding betas): 1.5.1
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [D] Update check: Starting update check interval.
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [D] Update check: Skipping initial update check.
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [D] Python check: Using python3 as the python executable
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [I] Python check: Starting python check.
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [I] Python check: plugin dir exists.
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [I] Python check: Python 3.11.8 is installed and supported by the plugin.
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [I] Python check: Virtual environment already exists.
[7/29/2024, 1:40:19 PM] [Apple TV Enhanced] [I] Python check: Virtual environment is using the systems default python environment. Continuing ...
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [I] Python check: Venv pip version: 24.2
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [I] Python check: Checking if there is an update for venv pip ...
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [I] Python check: Venv pip is up-to-date
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [I] Python check: Python requirements are satisfied.
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [I] Python check: Finished
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [D] Platform: Setting the storage path of the PyATV instance to /Users/apple/.homebridge
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [D] CustomPyATVInstance: Set atvscript path to "/Users/apple/.homebridge/appletv-enhanced/.venv/bin/atvscript".
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [D] CustomPyATVInstance: Set atvremote path to "/Users/apple/.homebridge/appletv-enhanced/.venv/bin/atvremote".
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [I] Platform: Starting device discovery ...
[7/29/2024, 1:40:20 PM] [Apple TV Enhanced] [D] Platform: Starting device discovery ...
[7/29/2024, 1:40:25 PM] [Apple TV Enhanced] [D] Platform: finished multicast device discovery
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] Platform: finished unicast device discovery
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] Platform: Found Apple TV TV (52:37:FC:9A:5C:6F / 192.168.86.29).
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [I] Platform: Adding Apple TV TV (52:37:FC:9A:5C:6F)
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] Platform: Waiting for Apple TV TV (52:37:FC:9A:5C:6F) to boot ...
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): Accessory Config: {"name":"Apple TV Enhanced","deviceStateDelay":0,"remoteKeysAsSwitch":["turn_off","turn_on"],"avadaKedavraAppAmount":15,"disableVolumeControlRemote":false,"absoluteVolumeControl":false,"setTopBox":false,"discover":{"multicast":true,"unicast":["192.168.86.29"]},"forceVenvRecreate":false,"logLevel":4,"updateCheckLevel":"stable","updateCheckTime":3,"deviceSpecificOverrides":[{"overrideMediaTypes":false,"overrideDeviceStates":false,"overrideDeviceStateDelay":false,"deviceStateDelay":0,"overrideRemoteKeysAsSwitch":false,"overrideAvadaKedavraAppAmount":false,"avadaKedavraAppAmount":15,"overrideCustomInputURIs":false,"overrideDisableVolumeControlRemote":false,"disableVolumeControlRemote":false,"overrideAbsoluteVolumeControl":false,"absoluteVolumeControl":false,"overrideSetTopBox":false,"setTopBox":false},{"overrideMediaTypes":false,"overrideDeviceStates":false,"overrideDeviceStateDelay":false,"deviceStateDelay":0,"overrideRemoteKeysAsSwitch":false,"overrideAvadaKedavraAppAmount":false,"avadaKedavraAppAmount":15,"overrideCustomInputURIs":false,"overrideDisableVolumeControlRemote":false,"disableVolumeControlRemote":false,"overrideAbsoluteVolumeControl":false,"absoluteVolumeControl":false,"overrideSetTopBox":false,"setTopBox":false}],"platform":"AppleTVEnhanced"}
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): Loaded credentials: undefined
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): Loaded credentials: undefined
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] Platform: Found Apple TV TV (52:37:FC:9A:5C:6F / 192.168.86.29).
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] Platform: Apple TV TV (52:37:FC:9A:5C:6F) with UUID 03cac8c4-929f-4a7c-b238-aa826da0407c already exists. Skipping.
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] Platform: Finished device discovery.
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [W] TV (52:37:FC:9A:5C:6F): Credentials are no longer valid. Need to repair ...
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): Got empty credentials, initiating pairing process.
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): Wait for the atvremote process to terminate
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [W] TV (52:37:FC:9A:5C:6F): You need to pair your Apple TV before the plugin can connect to it. Enter the PIN that is currently displayed on the device here: http://192.168.86.43:42029/
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): stdout: 2024-07-29 13:40:26 ERROR [pyatv.scripts.atvremote]: Pairing failed
Traceback (most recent call last):
  File "/Users/apple/.homebridge/appletv-enhanced/.venv/lib/python3.11/site-packages/pyatv/support/__init__.py", line 71, in error_handler
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.homebridge/appletv-enhanced/.venv/lib/python3.11/site-packages/pyatv/protocols/companion/auth.py", line 63, in start_pairing
    pairing_data = _get_pairing_data(resp)
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.homebridge/appletv-enhanced/.venv/lib/python3.11/site-packages/pyatv/protocols/companion/auth.py", line 33, in _get_pairing_data
    raise exceptions.AuthenticationError(stringify(tlv))
pyatv.exceptions.AuthenticationError: Error=BackOff, BackOff=6203s, SeqNo=M2
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/Users/apple/.homebridge/appletv-enhanced/.venv/lib/python3.11/site-packages/pyatv/scripts/atvremote.py", line 196, in pair
    await self._perform_pairing(pairing)
  File "/Users/apple/.homebridge/appletv-enhanced/.venv/lib/python3.11/site-packages/pyatv/scripts/atvremote.py", line 206, in _perform_pairing
    await pairing.begin()
  File "/Users/apple/.homebridge/appletv-enhanced/.venv/lib/python3.11/site-packages/pyatv/protocols/companion/pairing.py", line 47, in begin
    await error_handler(
  File "/Users/apple/.homebridge/appletv-enhanced/.venv/lib/python3.11/site-packages/pyatv/support/__init__.py", line 77, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError: Error=BackOff, BackOff=6203s, SeqNo=M2

[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [W] TV (52:37:FC:9A:5C:6F): Apple TV TV: Too many attempts. Waiting for 6208 seconds before retrying. The webpage to pair the Apple TV will become available again when the plugin is attempting the next pairing attempt.
[7/29/2024, 1:40:26 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): 6208 seconds remaining.
[7/29/2024, 1:40:27 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): 6207 seconds remaining.
[7/29/2024, 1:40:28 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): 6206 seconds remaining.
[7/29/2024, 1:40:29 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): 6205 seconds remaining.
[7/29/2024, 1:40:30 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): 6204 seconds remaining.
[7/29/2024, 1:40:31 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): 6203 seconds remaining.
[7/29/2024, 1:40:32 PM] [Apple TV Enhanced] [D] TV (52:37:FC:9A:5C:6F): 6202 seconds remaining.

Configuration

{
    "name": "Apple TV Enhanced",
    "deviceStateDelay": 0,
    "remoteKeysAsSwitch": [
        "turn_off",
        "turn_on"
    ],
    "avadaKedavraAppAmount": 15,
    "disableVolumeControlRemote": false,
    "absoluteVolumeControl": false,
    "setTopBox": false,
    "discover": {
        "multicast": true,
        "unicast": [
            "192.168.86.29"
        ]
    },
    "forceVenvRecreate": false,
    "logLevel": 4,
    "updateCheckLevel": "stable",
    "updateCheckTime": 3,
    "deviceSpecificOverrides": [
        {
            "overrideMediaTypes": false,
            "overrideDeviceStates": false,
            "overrideDeviceStateDelay": false,
            "deviceStateDelay": 0,
            "overrideRemoteKeysAsSwitch": false,
            "overrideAvadaKedavraAppAmount": false,
            "avadaKedavraAppAmount": 15,
            "overrideCustomInputURIs": false,
            "overrideDisableVolumeControlRemote": false,
            "disableVolumeControlRemote": false,
            "overrideAbsoluteVolumeControl": false,
            "absoluteVolumeControl": false,
            "overrideSetTopBox": false,
            "setTopBox": false
        },
        {
            "overrideMediaTypes": false,
            "overrideDeviceStates": false,
            "overrideDeviceStateDelay": false,
            "deviceStateDelay": 0,
            "overrideRemoteKeysAsSwitch": false,
            "overrideAvadaKedavraAppAmount": false,
            "avadaKedavraAppAmount": 15,
            "overrideCustomInputURIs": false,
            "overrideDisableVolumeControlRemote": false,
            "disableVolumeControlRemote": false,
            "overrideAbsoluteVolumeControl": false,
            "absoluteVolumeControl": false,
            "overrideSetTopBox": false,
            "setTopBox": false
        }
    ],
    "platform": "AppleTVEnhanced"
}

Operating System

Mac Os

Operating System: Bits

64-bit

Operating System: Distribution

12.6.1

Operating System: Distribution Version

21G217

Docker

no

Docker Image

None

Docker Image Tag

No response

Homebridge Version

1.8.4

Homebridge Config UI Version

v4.56.4

Homebridge Storage Path

/Users/apple/.homebridge

Homebridge Apple TV Enhanced Version

1.5.1

Node Version

v20.16.0

NPM Version

10.8.1

Python Version

3.11.8

PIP Version

24.0.0

HDMI Hops

No response

Audio Output

no

Same Subnet

yes

Additional Context

Nothing I don't think

github-actions[bot] commented 2 months ago

✔️ Have a coffee ☕

Your opened issue fulfills all requirements validated in the pre-checks 🎉

My master will take a look at the problem as soon as he has the time for it 🤖

Time to get a coffee ☕

maxileith commented 2 months ago

From the logs it looks like the plugin is behaving as expected. You need to repair your Apple TV as the plugin currently does not have valid credentials.

From the logs you get the remaining time until the plugin retries to connect. Set a timer ... or alternatively, stop the plugin wait for the time to expire then start the plugin and enter the pairing code.

maxileith commented 1 month ago

Answered in issue #620