postlund / pyatv

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

Can't pair with Vizio TV Model V405-G9 #1659

Open ac-monty opened 2 years ago

ac-monty commented 2 years ago

Describe the bug

My Vizio TV is auto-detected during the scan, the PIN number is showing on the screen, and pairing fails after input.

Error log


Enter PIN on screen: 1010
2022-02-12 16:59:26 DEBUG [pyatv.protocols.airplay.pairing]: AirPlay PIN changed to 1010
2022-02-12 16:59:26 DEBUG [pyatv.support.http]: Sending HTTP/1.1 message: b'POST /pair-setup-pin HTTP/1.1\r\nUser-Agent: pyatv/0.10.0\r\nContent-Length: 85\r\n\r\nbplist00\xd2\x01\x02\x03\x04VmethodTuserSpin_\x10\xDDDD13DD3DC333D3A5A3D3\D08\r\x00\x00\x1d\x00\x00\x00\x00\xD0\x00\x01\x01\x0D\x00\x00\x00\x00\x00\x00Dx05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x000'
2022-02-12 16:59:26 DEBUG [pyatv.support.http]: Received: b'HTTP/1.1 403 Forbidden\r\nContent-Length: 0\r\nServer: AirTunes/377.25.06\r\n\r\n'
2022-02-12 16:59:26 DEBUG [pyatv.support.http]: Got HTTP response: HttpResponse(protocol='HTTP', version='1.1', code=403, message='Forbidden', headers={'content-length': '0', 'server': 'AirTunes/377.25.06'}, body=''):
2022-02-12 16:59:26 ERROR [pyatv.scripts.atvremote]: Pairing failed
Traceback (most recent call last):
  File "/Users/usr/opt/anaconda3/envs/Apps_3_10/lib/python3.10/site-packages/pyatv/support/__init__.py", line 33, in error_handler
    return await func(*args, **kwargs)
  File "/Users/usr/opt/anaconda3/envs/Apps_3_10/lib/python3.10/site-packages/pyatv/protocols/airplay/auth/legacy.py", line 53, in finish_pairing
    resp = await self._send_plist(method="pin", user=client_id)
  File "/Users/usr/opt/anaconda3/envs/Apps_3_10/lib/python3.10/site-packages/pyatv/protocols/airplay/auth/legacy.py", line 79, in _send_plist
    return await self.http.post(
  File "/Users/usr/opt/anaconda3/envs/Apps_3_10/lib/python3.10/site-packages/pyatv/support/http.py", line 359, in post
    return await self.send_and_receive(
  File "/Users/usr/opt/anaconda3/envs/Apps_3_10/lib/python3.10/site-packages/pyatv/support/http.py", line 400, in send_and_receive
    raise exceptions.AuthenticationError("not authenticated")
pyatv.exceptions.AuthenticationError: not authenticated

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

Traceback (most recent call last):
  File "/Users/usr/opt/anaconda3/envs/Apps_3_10/lib/python3.10/site-packages/pyatv/scripts/atvremote.py", line 179, in pair
    await self._perform_pairing(pairing)
  File "/Users/usr/opt/anaconda3/envs/Apps_3_10/lib/python3.10/site-packages/pyatv/scripts/atvremote.py", line 212, in _perform_pairing
    await pairing.finish()
  File "/Users/usr/opt/anaconda3/envs/Apps_3_10/lib/python3.10/site-packages/pyatv/protocols/airplay/pairing.py", line 74, in finish
    await error_handler(
  File "/Users/usr/opt/anaconda3/envs/Apps_3_10/lib/python3.10/site-packages/pyatv/support/__init__.py", line 41, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError: not authenticated
2022-02-12 16:59:26 DEBUG [pyatv.support.http]: Connection closed```

### How to reproduce the bug?

Power on Vizio TV.
Wait for the device to be discovered.
Connect to the device.
Get PIN prompt on the screen.
Input PIN.

API and atvremote behave the same.

### What is expected behavior?

Pairing is complete after PIN input.

### Operating System

macOS

### Python

3.10

### pyatv

0.10.0

### Device

Vizio TV V405-G9

### Additional context

Protocol available for TV is:
========================================
Name: Living Room TV
Model/SW: V405-G9, Unknown OS
Deep Sleep: False
Services:
 - Protocol: AirPlay, Port: 7000, Credentials: None, Requires Password: False, Password: None, Pairing: Mandatory

According to their site, it's AirPlay 2:
https://www.vizio.com/en/apple
ac-monty commented 2 years ago

Some additional information, TV is connected to Apple HomeKit, so security settings do not show options like "Anyone connected to the same network". Not sure if it helps.

postlund commented 2 years ago

This is probably an AirPlay 2 device only and pyatv currently does not support them.

postlund commented 1 year ago

@ac-monty Can you try if this works now (since I have implemented AirPlay 2 support)? You will have to add it manually via IP to find it.