suborb / philips_android_tv

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

Models 2017 #4

Closed uronito closed 3 years ago

uronito commented 6 years ago

In a 2017 model,

Whaen I try to pair, appears "start pairing" and error:

Starting pairing request
^CTraceback (most recent call last):
  File "./philips.py", line 119, in <module>
    main()
  File "./philips.py", line 86, in main
    pair(config)
  File "./philips.py", line 37, in pair
    r = requests.post("https://" + config['address'] + ":1926/pair/request", json=data, verify=False)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python2.7/dist-packages/urllib3/connection.py", line 326, in connect
    ssl_context=context)
  File "/usr/local/lib/python2.7/dist-packages/urllib3/util/ssl_.py", line 325, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python2.7/ssl.py", line 350, in wrap_socket
    _context=self)
  File "/usr/lib/python2.7/ssl.py", line 566, in __init__
    self.do_handshake()
  File "/usr/lib/python2.7/ssl.py", line 788, in do_handshake
    self._sslobj.do_handshake()
KeyboardInterrupt
suborb commented 6 years ago

I presume you interrupted whilst it was hanging?

Obvious question, but was the TV on at the time you were trying?

If you load a browser and go to https://[address]:1926 do you get anything - you'll have to accept the certificate.

uronito commented 6 years ago

The Tv is On,

i 've load a browser and go https://[address]:1926 and dont obtain nothing.

yes, i have interrupted the script.

Regards

uronito commented 6 years ago
Starting pairing request
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:732: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html (This warning will only appear once by default.)
  InsecureRequestWarning)
uronito commented 6 years ago
Starting pairing request
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:732: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html (This warning will only appear once by default.)
  InsecureRequestWarning)
Enter onscreen passcode: 2514
Traceback (most recent call last):
  File "./philips.py", line 119, in <module>
    main()
  File "./philips.py", line 86, in main
    pair(config)
  File "./philips.py", line 48, in pair
    auth['auth_signature'] = create_signature(b64decode(secret_key), str(auth_Timestamp) + str(pin))
  File "./philips.py", line 21, in create_signature
    sign = HMAC.new(secret_key, to_sign, SHA)
  File "/usr/local/lib/python3.4/dist-packages/Crypto/Hash/HMAC.py", line 211, in new
    return HMAC(key, msg, digestmod)
  File "/usr/local/lib/python3.4/dist-packages/Crypto/Hash/HMAC.py", line 129, in __init__
    self.update(msg)
  File "/usr/local/lib/python3.4/dist-packages/Crypto/Hash/HMAC.py", line 148, in update
    self.inner.update(msg)
  File "/usr/local/lib/python3.4/dist-packages/Crypto/Hash/hashalgo.py", line 69, in update
    return self._hash.update(data)
TypeError: Unicode-objects must be encoded before hashing
uronito commented 6 years ago

yeahhhhh!!!!!

Works Perfectly!!!!!!!

Thanks!!!!!!!!!

suborb commented 6 years ago

What change did you make?

uronito commented 6 years ago

Python 2.7 insted of python 3.4

Regards!!!!!

gjdass commented 6 years ago

Related to issue #2 I think. I got same problem, and I ran the command python ../philips.py --host 192.168.0.XX pair with 2.7 it worked well (instead of 3.5). I had to install pycrypto in the venv as well (since I'm using a venv installation, not a Pi or someting).

monza258 commented 6 years ago

Anyone an idea? I have python 2.7.9 on my pi3

pi@raspberrypi:~ $ curl -O https://raw.githubusercontent.com/suborb/philips_android_tv/master/philips.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 4428 100 4428 0 0 16077 0 --:--:-- --:--:-- --:--:-- 16160 pi@raspberrypi:~ $ python ./philips.py --host 192.168.178.48 pair Traceback (most recent call last): File "./philips.py", line 9, in from Crypto.Hash import SHA, HMAC ImportError: No module named Crypto.Hash

arzzen commented 6 years ago

@monza258 you can try my implementation this library https://github.com/arzzen/philips-tv