Closed ftk789 closed 1 year ago
Dear,
It works perfectly before, but now I obtain the same error message:
python turnoff.py
Traceback (most recent call last):
File "turnoff.py", line 9, in <module>
p100.turnOff() #Sends the turn off request
File "C:\Python38\lib\site-packages\PyP100\PyP100.py", line 228, in turnOff
decryptedResponse = self.tpLinkCipher.decrypt(r.json()["result"]["response"])
KeyError: 'result'
python turnon.py
Traceback (most recent call last):
File "turnon.py", line 9, in <module>
p100.turnOn()#Sends the turn on request
File "C:\Python38\lib\site-packages\PyP100\PyP100.py", line 195, in turnOn
decryptedResponse = self.tpLinkCipher.decrypt(r.json()["result"]["response"])
KeyError: 'result'
The script is as follow:
from PyP100 import PyP100
p100 = PyP100.P100("xxx.xxx.xxx.xxx", "email", "password") #Creating a P100 plug object
p100.handshake() #Creates the cookies required for further methods
p100.login() #Sends credentials to the plug and creates AES Key and IV for further methods
p100.turnOn()#Sends the turn on request
I really don't know where it come from. Maybe an update of the Tapo P100 device.
Thank you for your help
Dear,
It works perfectly before, but now I obtain the same error message:
python turnoff.py Traceback (most recent call last): File "turnoff.py", line 9, in <module> p100.turnOff() #Sends the turn off request File "C:\Python38\lib\site-packages\PyP100\PyP100.py", line 228, in turnOff decryptedResponse = self.tpLinkCipher.decrypt(r.json()["result"]["response"]) KeyError: 'result'
python turnon.py Traceback (most recent call last): File "turnon.py", line 9, in <module> p100.turnOn()#Sends the turn on request File "C:\Python38\lib\site-packages\PyP100\PyP100.py", line 195, in turnOn decryptedResponse = self.tpLinkCipher.decrypt(r.json()["result"]["response"]) KeyError: 'result'
The script is as follow:
from PyP100 import PyP100 p100 = PyP100.P100("xxx.xxx.xxx.xxx", "email", "password") #Creating a P100 plug object p100.handshake() #Creates the cookies required for further methods p100.login() #Sends credentials to the plug and creates AES Key and IV for further methods p100.turnOn()#Sends the turn on request
I really don't know where it come from. Maybe an update of the Tapo P100 device.
Thank you for your help
I fixed it, My problem was that the IP was wrong, I had the IP set up as a name, And it worked at first, But then when the plug disconnected, The local IP changed so not the same name, And it kept giving me that error, Replaced it with the right IP and it worked, Try checking if it's the same IP or not, And let me know so I can close this issue.
The Tapo has a static IP, I just checked it: it still the same IP as in my script.
The Tapo firmware is 1.4.10 Build 20211104 Rel 35882
I can ping the Tapo IP
I don't know what's the cause then, Mine got fixed like that, I'll keep the issue open just in case someone helps.
Likely an issue with that model.
I just tested my P110 as i did an update (i do them manually) when i noticed it was available the other night and i have no issues - you had me worried :)
P110 - Firmware 1.2.3 Build 230425 Rel. 142542
For me (using current IP addresses):
model: L510E hw: 1.0.0 fw: 1.2.2 Build 20220110 Rel. 72329 result: error
model: L530E hw: 2.0 fw: 1.0.10 Build 221129 Rel. 193015 result: works
It's fixed. After just unplug and plug back the P100 it works again.... Sorry for that.
@sonic74 Do what @JeanDaraspe2 Did, Hope it works for you as well, I'm doing to close the issue.
After powercycling my L510E, it still doesn't work, neither with IP address nor hostname.
It doesn't work for me, neither with IP address nor hostname.
Try the local ip address: 192.168.xxx.xxx
I did:
s:/tp-link# PyP100/bin/python tapo.py 192.168.30.36
Traceback (most recent call last):
File "/tp-link/PyP100/lib/python3.11/site-packages/PyP100/PyP100.py", line 168, in login
self.token = ast.literal_eval(decryptedResponse)["result"]["token"]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'result'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tp-link/tapo.py", line 15, in <module>
p100.login() #Sends credentials to the plug and creates AES Key and IV for further methods
^^^^^^^^^^^^
File "/tp-link/PyP100/lib/python3.11/site-packages/PyP100/PyP100.py", line 172, in login
raise Exception(f"Error Code: {errorCode}, {errorMessage}")
Exception: Error Code: -1501, Invalid Request or Credentials
When deliberately using a wrong address, the exception looks different:
s:/tp-link# PyP100/bin/python tapo.py localhost
Traceback (most recent call last):
File "/tp-link/PyP100/lib/python3.11/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tp-link/tapo.py", line 14, in <module>
p100.handshake() #Creates the cookies required for further methods
^^^^^^^^^^^^^^^^
File "/tp-link/PyP100/lib/python3.11/site-packages/PyP100/PyP100.py", line 129, in handshake
encryptedKey = r.json()["result"]["key"]
^^^^^^^^
File "/tp-link/PyP100/lib/python3.11/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
In openHAB, it's the same: L530E works, L510E doesn't. At least with the open source Tapocontrol binding. Via the Amazon binding, both work.
After a firmware update:
model: L530E hw: 2.0 fw: 1.10.0 Build 230721 Rel. 224802
L530E now also doesn't work.
This repo seems to be abandoned; fixed in https://github.com/almottier/TapoP100
When normally logging in and handshaking: