maxileith / homebridge-appletv-enhanced

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

iOS tvOS 18 plugin does not connect to Apple TV #620

Closed maxileith closed 2 weeks ago

maxileith commented 2 months ago

Preconditions

Issue

Hello everybody,

I have updated to iOS / tvOS 18 beta and discovered that there are some inconveniences. Apple TVs exposes themself with other MAC-addresses as their identifiers after the update to 18. Because the ids of the Apple TV have changed, the plugin cannot match the Apple TV with the ones that it already knows. However, you can just pair the Apple TV with the plugin again.

If you are familiar with the command line, you can use the following command to move the folder with the configuration files for an Apple TV assuming the old Mac is AA:BB:CC:DD:EE:FF and the new one is 11:22:33:44:55:66. That way, the plugin can match the Apple TVs with the configurations that it already knows.

mv appletv-enhanced/AABBCCDDEEFF appletv-enhanced/112233445566

Be aware that either way, it is required to readd the Apple TV to HomeKit and adjust your automations.

If you have found another issue, feel free to open an issue here on GitHub.

ukiews commented 2 months ago

How do you repair? I cannot get the pairing screen to come up that allows to insert pin displayed on TV. Get error "site can't be reached"

[9/17/2024, 11:58:30 AM] [Apple TV Enhanced] [D] Apple-TV (7A:2D:5F:51:BB:D1): stdout: 2024-09-17 11:58:30 ERROR [pyatv.scripts.atvremote]: Pairing failed
Traceback (most recent call last):
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.9/site-packages/pyatv/support/__init__.py", line 71, in error_handler
    return await func(*args, **kwargs)
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.9/site-packages/pyatv/protocols/companion/auth.py", line 63, in start_pairing
    pairing_data = _get_pairing_data(resp)
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.9/site-packages/pyatv/protocols/companion/auth.py", line 33, in _get_pairing_data
    raise exceptions.AuthenticationError(stringify(tlv))
pyatv.exceptions.AuthenticationError: Error=BackOff, BackOff=626s, SeqNo=M2

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

Traceback (most recent call last):
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.9/site-packages/pyatv/scripts/atvremote.py", line 196, in pair
    await self._perform_pairing(pairing)
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.9/site-packages/pyatv/scripts/atvremote.py", line 206, in _perform_pairing
    await pairing.begin()
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.9/site-packages/pyatv/protocols/companion/pairing.py", line 47, in begin
    await error_handler(
  File "/var/lib/homebridge/appletv-enhanced/.venv/lib/python3.9/site-packages/pyatv/support/__init__.py", line 77, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError: Error=BackOff, BackOff=626s, SeqNo=M2
maxileith commented 2 months ago

You have to wait until the backoff timer is over. The repairing will be initiated automatically. I'd suggest to deactivate the plugin until you are certain the backoff timer is over. Then start the plugin and pair the Apple TV.

CardenB commented 2 months ago

After copying the directories over to the new location, I found one of my TVs works while the other one doesn't. Is this expected?

I haven't repeated the pairing process. Currently the backoff timer is very large for both TVs

EDIT: Also the window for pairing is so small I can't really hope to enter the code in time. Checking the logs, I had two seconds to enter the pairing code.

maxileith commented 1 month ago

the window for pairing is so small I can't really hope to enter the code in time. Checking the logs, I had two seconds to enter the pairing code.

You always have 30 seconds like when pairing any other device like an iPhone. Besides that, I have updated the pairing process in v1.8.0-0 which should make it a bit easier and user friendly.

maxileith commented 1 month ago

After copying the directories over to the new location, I found one of my TVs works while the other one doesn't. Is this expected?

You have to be more specific, e.g. share logs. What am I supposed to tell you when all I know about your case is "it does not work".

CardenB commented 1 month ago

Apologies for not sharing enough information. I disabled the plugin for the backoff to expire and then tried again as you suggested. I was able to get it to work after that.

dmytrokoren commented 1 month ago

Hey @maxileith, quick question – the plugin works well overall, but I’ve noticed some inconsistent behavior with automation. I have it set to turn on the lights when Apple TV is powered on, which works perfectly when I use the physical remote or the native iOS remote. However, when I turn on the Apple TV using the plugin remote, the automation to turn on the lights doesn’t trigger.

Looking at the logs, I see the states as either “on” or “turn_on” Any suggestions? Thanks!

maxileith commented 1 month ago

Hey @maxileith, quick question – the plugin works well overall, but I’ve noticed some inconsistent behavior with automation. I have it set to turn on the lights when Apple TV is powered on, which works perfectly when I use the physical remote or the native iOS remote. However, when I turn on the Apple TV using the plugin remote, the automation to turn on the lights doesn’t trigger.

Looking at the logs, I see the states as either “on” or “turn_on” Any suggestions? Thanks!

When you see Rocket Remote: turn_on in the logs, it means that the turn on command has been sent to the Apple TV. This does not update the power state of the accessory itself. Once the Apple TV powers on, no matter what the trigger was, the Apple TV exposes that information and then the plugin updates the powerstate New Active State: On.

If that does not work, please open a support request. The template asks for everything that I need to know to understand the problem.

maxileith commented 2 weeks ago

Closing this issue as most people probably have updated to TvOS 18 until now.