Closed TheWalrus2 closed 2 years ago
My Home Assistant integration stopped working out of nowhere. And I get the same error using just the python package:
>>> import growattServer
>>> api = growattServer.GrowattApi()
>>> login_response = api.login("myusername", "mypassword" )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lars/.local/lib/python3.10/site-packages/growattServer/__init__.py", line 119, in login
data = json.loads(response.content.decode('utf-8'))['back']
File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/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)
I got the same error log. I am using this package stand alone in Domiticz.
Unfortunaly i dont have time too debug it.
I got the same error! The newLoginAPI.do url is returning error 400!
I got the same error! The newLoginAPI.do url is returning error 400!
Can you try LoginApi.do ?
I got the same error! The newLoginAPI.do url is returning error 400!
Can you try LoginApi.do ?
It works but return data with a diferent format...
When dumping the response.content it is a html formatted status report with this content:
type Status report
message Parameter conditions "op=apiserverlogin" OR "op=validate" OR "op=updateValidate" OR "op=testPushData" OR "op=apiserverlogin2" OR "op=apppush" OR "op=getUserServerUrlPost" OR "op=getServerUrlByName" OR "op=getServerUrlList" OR "op=updateValidateServer" OR "op=getSetPass" OR "op=saveAppErrorMsg" OR "op=flowCardExpirePush" OR "op=getPrivacyPolicyUrl" OR "op=getPrivacyPolicyUrlShinetools" OR "op=getChatOnlineUrl" OR "op=openSmartFamily" not met for actual request parameters: userName={MY_USERNAME}, password={MY_PASSWORD_HASH}
description The request sent by the client was syntactically incorrect.
I got the same error! The newLoginAPI.do url is returning error 400!
Can you try LoginApi.do ?
It works but return data with a diferent format...
Maybe we can start on a solution from there. Tomorrow i have time.
Hi Guys, Looks like Growatt decided to change the API again :)
I've got some time now so I'm going to take a look and see how far I can get, I'll report back. It'll require me to look through what the latest version of the app is now doing.
Lots of comments on the home assistant repos about this too, so I'm looking to see what I can do to get it fixed so we can bump the version over there as well.
Will report back when I've made some progress later.
Looks like the shine app has been updated to use newTwoLoginAPI.do
(seriously who picks these names!!).
I've run tests locally to reproduce the breakage:
Then changed the api call and everything sprang back to life:
I've also hacked my local homeassistant installation and got that to work as well:
Confirmed by comparing my Grafana dashboard against the growatt server website:
Grafana
Growatt
Will submit a PR now and as soon as we have a release from @indykoning I'll make the change to homeassistant as well. (I'll also post on the linked bug in homeassistant with the hack that I made to make it work so people can patch it themselves until the change is merged & released.
I could fix the login error by reversing the data formatting (Technically not necessary but some implementation depend on one or the other format) on line 115
response = self.session.post(self.get_url('LoginAPI.do'), data={
'userName': username,
'password': password
})
data = json.loads(response.content.decode('utf-8'))['back']
if data['success']:
data.update({
'user': {
'id': data['userId'],
'rightlevel': data['userLevel']
}
})
return data
But now I'm getting a different error, as it look like they have removed the newTwoPlantAPI.do endpoint.
@Lrss - Please try using the change I have suggested above and report back.
Simply change line 115 to newTwoLoginAPI.do
and it should fix the login issues.
Also, the plant_info
function which uses the newTwoPlantAPI.do
endpoint seems to be working fine for me.
If I use your pull request #29 as you explained, I get the Chinese html error page about not being logged in. error.txt
If I use your pull request #29 as you explained, I get the Chinese html error page about not being logged in. error.txt
What server URL are you using? I'm using the default https://server-api.growatt.com/
that's the only thing I could think that would cause this difference. I've got people over on the home-assistant channel that have reported it's working for them.
It's late here now so I'm going to stop for the day, I'll check for updates from people in the morning though and see if there's anything I can do to help out. It's just down to @indykoning now though to do the approval, merge & release.
Yes I'm using https://server-api.growatt.com/
and LoginAPI.do
works, (but gives a different format, as I explained), and newTwoLoginApi.do
gives the aforementioned error.
@muppet3000 thanks buddie. For me it is working again. changed newLoginApi.do --> newTwoLoginApi.do
I've changed line 115 at /srv/homeassistant/lib/python3.9/site-packages/growattServer/init.py
from:
response = self.session.post(self.get_url('newLoginAPI.do'), data={
to
response = self.session.post(self.get_url('newTwoLoginApi.do'), data={
But after herstarting HA i'm still getting:
Error while setting up growatt_server platform for sensor Traceback (most recent call last): File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform await asyncio.shield(task) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/growatt_server/sensor.py", line 74, in async_setup_entry devices, plant_id = await hass.async_add_executor_job(get_device_list, api, config) File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/growatt_server/sensor.py", line 42, in get_device_list login_response = api.login(config[CONF_USERNAME], config[CONF_PASSWORD]) File "/srv/homeassistant/lib/python3.9/site-packages/growattServer/__init__.py", line 119, in login data = json.loads(response.content.decode('utf-8'))['back'] File "/usr/lib/python3.9/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/usr/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/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 3 column 1 (char 2)
Well my issues are resolved regarding #29 after trying again this morning, maybe it is something rolling out gradually to the customers.
I've changed line 115 at /srv/homeassistant/lib/python3.9/site-packages/growattServer/init.py
from:
response = self.session.post(self.get_url('newLoginAPI.do'), data={
to
response = self.session.post(self.get_url('newTwoLoginApi.do'), data={
But after herstarting HA i'm still getting:
Error while setting up growatt_server platform for sensor Traceback (most recent call last): File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform await asyncio.shield(task) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/growatt_server/sensor.py", line 74, in async_setup_entry devices, plant_id = await hass.async_add_executor_job(get_device_list, api, config) File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/growatt_server/sensor.py", line 42, in get_device_list login_response = api.login(config[CONF_USERNAME], config[CONF_PASSWORD]) File "/srv/homeassistant/lib/python3.9/site-packages/growattServer/__init__.py", line 119, in login data = json.loads(response.content.decode('utf-8'))['back'] File "/usr/lib/python3.9/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/usr/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/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 3 column 1 (char 2)
Can we discuss this over in the Home Assistant bug? This one: https://github.com/home-assistant/core/issues/71577
This repo is specifically for fixing issues with the library that home assistant uses.
Maybe it took some time! It's working again! :)
Not working. Still not logging in.
If I use your pull request #29 as you explained, I get the Chinese html error page about not being logged in. error.txt
me too. exactly the same.
Okay, I figured it out and I hope it works for you too:
The correct endpoint is newTwoLoginAPI.do
and NOT newTwoLoginApi.do
So, basically, the API
should still be completely uppercase, since Api
is wrong.
That must be the reason it didn't work for me last night. Nice catch @capedra
Ah, so my PR is correct but the comment I made above was wrong!!! I've just updated my comment above in case anyone else sees it and copies from there. Thanks for spotting it. Glad to see that it works for all in that case!!
For anyone else coming to this thread fresh this is the change that needs to be made if you're "hacking" the library until the release is made by @indykoning: https://github.com/indykoning/PyPi_GrowattServer/pull/29/files
I'm running HA on a Raspberry PI and I removed the Growatt Integration to check if re-adding works. But now I'm not able to add the integration again (Unknown error occurred) and also cannot see any of the files on my RPI.... Anyone that could give me a hint?
I'm running HA on a Raspberry PI and I removed the Growatt Integration to check if re-adding works. But now I'm not able to add the integration again (Unknown error occurred) and also cannot see any of the files on my RPI.... Anyone that could give me a hint?
Anything HA related should be discussed over in the HA ticket: https://github.com/home-assistant/core/issues/71577
Don't know what changed server side. But i get an error after login. Issue started suddenly.