suborb / philips_android_tv

Tools to control Philips 2016 Android TVs
GNU General Public License v2.0
121 stars 61 forks source link

55PUS6754 (2019 model) Connection Refused #22

Open JangoBritt opened 4 years ago

JangoBritt commented 4 years ago
Starting pairing request
Traceback (most recent call last):
  File "./philips.py", line 123, in <module>
    main()
  File "./philips.py", line 90, in main
    pair(config)
  File "./philips.py", line 41, in pair
    r = requests.post("https://" + config['address'] + ":1926/6/pair/request", json=data, verify=False)
  File "/home/hoobs/.local/lib/python2.7/site-packages/requests/api.py", line 110, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/hoobs/.local/lib/python2.7/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/hoobs/.local/lib/python2.7/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/hoobs/.local/lib/python2.7/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/hoobs/.local/lib/python2.7/site-packages/requests/adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='{redacted}', port=1926): Max retries exceeded with url: /6/pair/request (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb60bae10>: Failed to establish a new connection: [Errno 111] Connection refused',))

on my 2019 Ambilight, I'm not able to start a pairing connection.

On the Browser, I can access the JSON only on HTTP and 1925, but does not display a JSON when using HTTPS and 1926

I tried changing the code to http and 1925, but then the error changed to ("No JSON object could be decoded")

SchmuFoo commented 4 years ago

Problem still existing? According to some other websites TP-Vision accidentally broke the API earlier this year on some 2019 models. I‘m using one with an fresh firmware and http://up:1925/system AND https://ip:1926/6/system ARE working

straubus commented 4 years ago

Same issue for me, only http://up:1925/system is responsive. I've got pus7304

BETEP-ok commented 4 years ago

Same here - pus7354

feels like @SchmuFoo is right and something got broken TV side. the whole firmware behaviour feels very very broken to me ( not just the joint space

straubus commented 4 years ago

Mine freezes on "starting pairing requests" and then connection timed out. I have bought a new tv and can't add it to Homekit setup, and I've got a few automations based on tv.

korgboll commented 4 years ago

Same problems here (7354). No news on a solution to fix jointspace on this model?

suborb commented 4 years ago

So...after a few years I ended up buying a new TV, this time a Saphi based 6704 and the fancy pairing method has been removed from that - so this project is sort of redundant for these models.

https as been removed and we're back on port 1925 unencrypted. It looks like it's a prefix of /6/ as well.

For commands, a set of Basic auth credentials are created on the client which seems to have a username of 1 and a password which I've yet to decode how it's formed.

However, it's constant across app launches so it's may well be reusable one you've captured it from the network traffic, which since it's http is a bit of a doddle!

I'll see if I can figure out what goes into generating the password just to satisfy my own curiousity.

Edit:

Oh, this has made me laugh, the base64 version of the password is the "secret HMAC key". So the header needed for authentication for that TV range is here:

Authorization: Basic 1:ZmVay1EQVFOaZhwQ4Kv81ypLAZNczV9sG4KkseXWn1NEk6cXmPKO/MCa9sryslvLCFMnNe4Z4CPXzToowvhHvA==
ArnoutVerbeken commented 4 years ago

Thank you for the research and the header information. But can you please explain how we should do this to authenticate our TV? Should we modify the .py file?

suborb commented 4 years ago

This project is redundant really for the Saphi range of TVs - the main point was to do the pairing for Android TVs so the credentials can be plugged into something else a little more user friendly/usable.

The Saphi TVs allow unauthenticated access for the get functions, the credentials are only needed for actions.

So, if you're using this project and want to connect it a Saphi based TV you'll need to make the following changes:

  1. Change http:// to https://
  2. Change port 1926 to 1925

The post_command function should be replaced with this:

def post_command(config):
    r = requests.post("http://" + config['address'] + ":1925/" + config['path'], json=config['body'], verify=False,auth=("1", secret_key))
    print(r)
BETEP-ok commented 4 years ago

just a quick update:

Philips 65PUS7354 2019

After firmware update 001.002.173.010 AND factory reset I finally managed to run the script properly and integrate my TV to the Homebridge service.

So now I can at least enjoy the with on\off function from the HomeKit

feels like the factory reset made the difference