fishbigger / TapoP100

A module for controlling the TP-Link Tapo P100 Plugs
MIT License
567 stars 139 forks source link

Using this library stopped working after a firmware update #79

Closed RobertVoorn1977 closed 1 year ago

RobertVoorn1977 commented 1 year ago

The below code used to work fine: `from PyP100 import PyP110

p110 = PyP110.P110("ipaddress", "username", "password") #Creating a P110 plug object

p110.handshake() #Creates the cookies required for further methods p110.login() #Sends credentials to the plug and creates AES Key and IV for further methods

p110.turnOn() #Sends the turn on request

p110.turnOff() #Sends the turn off request

print(type(p110.getDeviceInfo().get("device-on"))) #Returns dict with all the device info

print(type(p110.getDeviceInfo())) #Returns dict with all the device info

print(p110.getDeviceInfo()) #Returns dict with all the device info`

The code stopped working, so I readded the Tapo P110 smart plug again and during that process a firmware update was done. After this I get the following error:

`Traceback (most recent call last): File "/Users/robafett/PycharmProjects/BatterySaver/venv/lib/python3.9/site-packages/requests/models.py", line 910, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/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 "/Users/robafett/PycharmProjects/BatterySaver/smart_plug_test.py", line 6, in p110.login() #Sends credentials to the plug and creates AES Key and IV for further methods File "/Users/robafett/PycharmProjects/BatterySaver/venv/lib/python3.9/site-packages/PyP100/PyP100.py", line 160, in login decryptedResponse = self.tpLinkCipher.decrypt(r.json()["result"]["response"]) File "/Users/robafett/PycharmProjects/BatterySaver/venv/lib/python3.9/site-packages/requests/models.py", line 917, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: [Errno Expecting value]

200 OK
: 0`

Is there a solution for this or has the library broken after the firmware update?

RobertVoorn1977 commented 1 year ago

Already solved in https://github.com/fishbigger/TapoP100/issues/76, so closing this ticket