core: Growatt integration HTTP (s) error

The problem

Since yesterday the growatt server does not update (stating unavailable). Is this an issue because I am using duckdns / letsencrypt integration?

Error:

Logger: homeassistant.components.sensor Source: components/growatt_server/sensor.py:870 Integration: Sensor (documentation, issues) First occurred: 9:01:09 AM (3 occurrences) Last logged: 9:10:36 AM

Error while setting up growatt_server platform for sensor Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 249, in _async_setup_platform await asyncio.shield(task) File “/usr/src/homeassistant/homeassistant/components/growatt_server/sensor.py”, line 885, in async_setup_entry devices, plant_id = await hass.async_add_executor_job(get_device_list, api, config) File “/usr/local/lib/python3.9/concurrent/futures/thread.py”, line 52, in run result = self.fn(*self.args, **self.kwargs) File “/usr/src/homeassistant/homeassistant/components/growatt_server/sensor.py”, line 870, in get_device_list devices = api.device_list(plant_id) File “/usr/local/lib/python3.9/site-packages/growattServer/init.py”, line 440, in device_list return self.plant_info(plant_id)[‘deviceList’] File “/usr/local/lib/python3.9/site-packages/growattServer/init.py”, line 453, in plant_info data = json.loads(response.content.decode(‘utf-8’)) File “/usr/local/lib/python3.9/json/init.py”, line 346, in loads return _default_decoder.decode(s) File “/usr/local/lib/python3.9/json/decoder.py”, line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File “/usr/local/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 7 column 1 (char 19)

log:

What is version of Home Assistant Core has the issue?

core-2021.09.05

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

growatt

Link to integration documentation on our website

https://www.home-assistant.io/integrations/growatt_server/

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:00 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547628479200] Received invalid command: energy/info
2021-09-10 09:01:09 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up growatt_server platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/usr/src/homeassistant/homeassistant/components/growatt_server/sensor.py", line 885, in async_setup_entry
devices, plant_id = await hass.async_add_executor_job(get_device_list, api, config)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/growatt_server/sensor.py", line 870, in get_device_list
devices = api.device_list(plant_id)
File "/usr/local/lib/python3.9/site-packages/growattServer/__init__.py", line 440, in device_list
return self.plant_info(plant_id)['deviceList']
File "/usr/local/lib/python3.9/site-packages/growattServer/__init__.py", line 453, in plant_info
data = json.loads(response.content.decode('utf-8'))
File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/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 7 column 1 (char 19)

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 82 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Perfect timing @djoenez I’ve just finished logging the ticket in the upstream library that myself and @indykoning manage. You can see more here: https://github.com/indykoning/PyPi_GrowattServer/issues/16

Short version - Something has changed on the growatt server api/interface and the python library that we’ve written has stopped working. All Growatt integration with HomeAssistant will have stopped working as a result.

The problem we have right now is trying to understand what the bug is, because the API call is identical but we’re now getting back a 500 error from the server in our library, but the ShineApp (the phone app which makes the same call) gets the data back correctly.

I’ll take another look at it later, but I’m hoping Indy might have some ideas in the meantime.

I also had some issues finding the source files in my Home Assistant OS installation. I finally (temporally) fixed my Growatt integration by creating a custom component (/config/custom_componenents/growatt_server), by copying the files from the core github (https://github.com/home-assistant/core/tree/dev/homeassistant/components/growatt_server). Subsequently used to changes in the PR (https://github.com/home-assistant/core/pull/56084/files) to adjust the custom integration.

  1. Changed in sensor.py line 882 in to user_id = login_response["user"]["id"]
  2. Changed in config_flow.py line 50 in to self.user_id = login_response["user"]["id"]
  3. Changed ‘manifest.json’ in:
{
  "domain": "growatt_server",
  "name": "Growatt",
  "config_flow": true,
  "documentation": "https://www.home-assistant.io/integrations/growatt_server/",
  "requirements": ["growattServer==1.1.0"],
  "codeowners": ["@indykoning", "@muppet3000", "@JasperPlant"],
  "iot_class": "cloud_polling",
  "version": "1.1.0"
}

As soon the code is fixed in the next release don’t forget to remove the custom_integration otherwise you might miss some future updates.

Hi All, just a brief update from me. The PR is now ready to merge, if it gets merged in before the nightly build those of you using docker should be able to simply change the the dev build of the docker image and you won’t need any further hacks or custom modules as it will have been built with all the correct fixes. I’m looking forward to seeing the back of this problem!

For those of you (e.g. @zjean) that wanted my docker implementation (which will persist if you restart docker/reboot your server/restart that container).

  1. Make a directory somewhere on your host e.g. mkdir /opt/hass_growatt_patch
  2. Ensure the home assistant container is running and find out it’s name docker ps
  3. Run the following commands to copy the files that need patching out of the running container into the temporary path
#Replace 'home-assistant' with the name you got from number 2.
docker cp home-assistant:/usr/local/lib/python3.9/site-packages/growattServer/__init__.py /opt/hass_growatt_patch/
docker cp home-assistant:/usr/src/homeassistant/homeassistant/components/growatt_server/sensor.py /opt/hass_growatt_patch/
  1. Patch the files as follows: File /opt/hass_growatt_patch/__init__.py line 57: Replace LoginAPI.do with newLoginAPI.do File /opt/hass_growatt_patch/sensor.py line 864: Replace user_id = login_response["userId"] with user_id = login_response["user"]["id"]
  2. Update your docker run command to include the following additional volume mounts: -v /opt/hass_growatt_patch/__init__.py:/usr/local/lib/python3.9/site-packages/growattServer/__init__.py -v /opt/hass_growatt_patch/sensor.py /usr/src/homeassistant/homeassistant/components/growatt_server/sensor.py (If you’re using docker-compose add these two commands but without the -v argument in the ‘volumes’ section of your docker-compose.yml)
  3. Restart your docker container (either with docker compose or docker stop followed by docker run etc.)

I hope that’s clear enough for everyone, let me know how you get on.

Those of you using the docker version, the next nightly build should contain the fixes for this. I’ll test it tomorrow and confirm.

@Nakebod thanks.

@TheWalrus2 I agree. Also we definitely are logged in and I’ve also tried re-logging in immediately before trying the call again. I reckon something has changed on a firewall somewhere or something but that doesn’t explain why the app still works. Unless they’re only blocking the python library we’re using. I’m working today but I’ll try and take another look tonight when I’m done for the day.

I have half a mind to log a bug through the shineapp with Growatt, but they don’t officially support the API that we’ve reverse engineered, and the app still works, so they’ve got no reason to fix it. 😦

People with docker. Hass.io having problems, Not everyone is confident to do what muppet3000 proposed Make a directory somewhere on your host e.g. mkdir /opt/hass_growatt_patch Ensure the home assistant container is running and find out it’s name docker ps Run the following commands to copy the files that need patching out of the running container into the temporary path

I was waiting for HA to release their own update thinking that for growatt is a official integration it would fix it. It is not the case with the latest update HA core-2021.9.6. Very sad why it is not there. When can we see the fix in HA update please?

Thanks @daxy01 I was looking at my dev branch which is a bit out of date that’s all, I should have pulled the latest code, thanks for the info. At a minimum that will help others looking to patch the issue. I’ll get all mine fixed in a little while and get the PR ready for when Indy has build and released the fixed library.

I’ve got it working as well by doing this:

  • Edit /usr/local/lib/python3.9/site-packages/growattServer/init.py
  • Change line 57 to: response = self.session.post(self.get_url('newLoginAPI.do'), data={
  • Edit /usr/src/homeassistant/homeassistant/components/growatt_server/sensor.py
  • Uncomment Line 864 (Add # in front of the line, won’t be used)
  • Change line866 to: plant_info = api.plant_list(login_response['user']['id'])
  • Restart Home-Assistant

@MartinHjelmare

ok sorry about that,

thanks for the info 👍

Please don’t use this issue for questions or problems that are not related to the original reported issue.

Please use our help channels for questions. https://www.home-assistant.io/help/#communication-channels

If there are new bugs, please open new issues in this issue tracker. Thanks!

For those of you still following this. I pulled the latest “dev” version of the HASS docker image this morning and spun it up without any of my changes and it’s all working correctly.

Thanks for being so prompt, and looking out for these kind of issues. A user of an integration can only wish for such good care. 👍