fishbigger / TapoP100

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

Unable to login to the 530B Bulb due to JSONDecodeError: Expecting value #54

Open amanbatra96 opened 2 years ago

amanbatra96 commented 2 years ago

This is the error I am getting on trying to login: raise JSONDecodeError("Expecting value", s, err.value) from None

I am trying out with the 530B bulb and the following code:

from PyP100 import PyL530

l530 = PyL530.L530("ipaddress", "username", "password") #Creating a L530 bulb object

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

handshake happens without any errors, the error pops up during login

When I was trying to go through other issues, it was suggested that it might be an authentication related issue, but changing passwords did not help either. I am also making sure its an 8 digit password.

Please let me know if any other information is required, I request you to help me solve this, Thanks!

vijayrraut commented 2 years ago

I am also facing same error:

l530.login() Traceback (most recent call last): File "", line 1, in File "/home/pi/.local/lib/python3.7/site-packages/PyP100/PyP100.py", line 156, in login decryptedResponse = self.tpLinkCipher.decrypt(r.json()["result"]["response"]) File "/home/pi/.local/lib/python3.7/site-packages/requests/models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/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)

fishbigger commented 2 years ago

Hi, I can't immediately see what the problem is here. Have you ever had the code working on an older version or is this your first time trying it? I'm trying to work out if I've screwed up somewhere while refactoring some of the code. Thanks.

amanbatra96 commented 2 years ago

Hi, Sorry for the delayed response. This was the first time I was trying to login using the latest code of the time. I am not sure that if code is itself buggy. I was wondering if the router used could have caused some restriction in communication. I will try to test it again sometime using a mobile hotspot based network to confirm. I have actually moved to university so bit difficult to follow up, nevertheless I will update the thread once I experiment with another network. Thanks for your response!

fishbigger commented 2 years ago

Hi, Thanks for your response! Please do let me know if you have any success with the hotspot. I haven't encountered the router as an issue before but if it is that could explain some of the other issues. Thanks.

Lemos97 commented 2 years ago

Facing the same issue as described. The Response.text from the post of the login method returns: <html><body><center>200 OK</center></body></html> Which is why it is raising the following Exception, the same as the original issue.

File "E:\Dev\light-bulb-TPLL530\room.py", line 67, in main
    p100.login() #Sends credentials to the plug and creates AES Key and IV for further methods
  File "E:\Dev\light-bulb-TPLL530\devices\PyP100.py", line 162, in login
    decryptedResponse = r.json()["result"]["response"]
  File "C:\Python39\lib\site-packages\requests\models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Python39\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Python39\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python39\lib\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)
kibabyte commented 2 years ago

Currently getting the same error but i was unable to find a solution, what can i do? grafik

alenoi commented 2 years ago

image So it seems like there is no json in the bulb's reponses anymore only a HTTP200 (the plugs response still contains the json)