-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with api #49
Comments
It might be worth failing gracefully - with an error message including the response - when the login fails. (I'm not a python programmer and it's just taken me a couple of hours of stepping through a .py file with pdb to find out why the code is dying with a JSON decode error. Takes me back to debugging in the '70s on a teletype terminal.) I guess I could/should have come here first. Maybe an error message could even include the suggestion to visit this site if the response is 403. |
This issue seems to be caused by Growatt returning an unexpected http code and this package not handling that correctly. I do not believe this package should silently handle these errors since that can cause unexpected behavior in applications implementing this package, however the thrown exception can be clearer and must be easier to be properly caught and debugged. as an example
|
UPDATE: I had been writing down all the steps I did and where I was struggling , how I came to this site and on the way also seemed to find a solution which other newbies coming from windows / a bit of raspberry python scripting + homeassistant work might help those too. So this is a trial and error story hopefully to a success. I am total new to the whole idea, had played a bit with python before under raspi so can code a bit, use micropython for some Pimoroni BADGER PICO adventures, but here I am stuck richt now and got your error message mentioned in the last line. But here is my starting point and steps done. #2 Looked like that had worked fine too cause since then i get a "requirement already satisfied" message if I had tried the install command again with: pip install growattServer #3 #4 #5 That looked great so far - but did not pay of cause did not work. I got this error message:
#6 No progress at all, at least for me. And here I am stucked and can not get any further with my limited skills. #7 And here I used this 3rd option successfully at least for now I guess
finally got a nice reply which also might help others with limited skills and experience to get it solved. Override default User-Agent And from there the story might continue. Final question: might this work on a raspberry pico W too ? thanks. |
It was working good but I start to receive this message instead
Traceback (most recent call last):
File "C:\Users\lucas\PycharmProjects\teste\main.py", line 13, in
login_response = api.login(gw_username, gw_user_pass)
File "C:\Users\lucas\PycharmProjects\teste\venv\lib\site-packages\growattServer_init_.py", line 132, in login
data = json.loads(response.content.decode('utf-8'))['back']
File "C:\Users\lucas\AppData\Local\Programs\Python\Python310\lib\json_init_.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\lucas\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\lucas\AppData\Local\Programs\Python\Python310\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)
The text was updated successfully, but these errors were encountered: