Closed denko81 closed 7 years ago
So either the PIN or the timestamp are not in ascii. It looks like the PIN is good, so it must be the timestamp.
I'm just updating my TV to see if a later software revision has changed things.
The process still remains the same on QME164E.0.1.15.118 (19/1/2017) so it must be your environment.
I've not got a windows machine so I can't test this for you, but some logging of timestamp around line 47 will probably be useful to help diagnose
You are right, it was my environment. But can I ask you a question, do you know any guide or tutorial in translating a Python script to Groovy_
I want my Samsung Smartthings homeautomation controller torn off the TV when I am leaving my home.
Can you share as to what was wrong?
I'm not sure you need to translate the script. Which is why I've not that much with this project! The difficult bit is the pairing and then everything else is then just HTTP/JSON calls.
So, just use this bit of python to pair and extract the username and password that's needed.
Then in SmartThings you just need to make a digest auth HTTP request with the appropriate JSON payload.
So to hit standby you probably need to query the power state:
https://ip:1926/6/powerstate
Parse the JSON (I've not got an example at the moment) to determine whether it's currently on, and then send a standby remote command:
https://ip:1926/6/input/key
with a payload of:
{ "key" : "Standby" }
It was missmatching versions of Python and pycripto.
The problem is that both Python, Groovy and JSON are new for me as I learned Java in school and mostly used PHP.
I am getting this error.
D:\philips>python philips.py pair --host 192.168.1.232 Starting pairing request C:\Python\lib\site-packages\requests\packages\urllib3\connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/.../advanced-usage.html... InsecureRequestWarning) Enter onscreen passcode: 3821 Traceback (most recent call last): File "philips.py", line 118, in
main()
File "philips.py", line 85, in main
pair(config)
File "philips.py", line 47, in pair
auth['auth_signature'] = create_signature(b64decode(secret_key), str(auth_Timestamp) + str(pin))
File "philips.py", line 20, in create_signature
sign = HMAC.new(secret_key, to_sign, SHA)
File "C:\Python\lib\site-packages\Crypto\Hash\HMAC.py", line 211, in new
return HMAC(key, msg, digestmod)
File "C:\Python\lib\site-packages\Crypto\Hash\HMAC.py", line 129, in init
self.update(msg)
File "C:\Python\lib\site-packages\Crypto\Hash\HMAC.py", line 148, in update
self.inner.update(msg)
File "C:\Python\lib\site-packages\Crypto\Hash\hashalgo.py", line 69, in update
return self._hash.update(data)
TypeError: Unicode-objects must be encoded before hashing