homeassistant-growatt_server_api icon indicating copy to clipboard operation
homeassistant-growatt_server_api copied to clipboard

BUG - Growatt Server Connect & Stability Issues

Open Saentist opened this issue 2 years ago • 253 comments

Again offline

Logger: homeassistant.components.sensor
Source: custom_components/growatt_server_api/sensor.py:44
Integration: Sensor (documentation, issues)
First occurred: 17:34:47 (1 occurrences)
Last logged: 17:34:47

Error while setting up growatt_server_api platform for sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 358, in connect
    self.sock = conn = self._new_conn()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fa019425db0>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='server-api.growatt.com', port=443): Max retries exceeded with url: /newTwoLoginAPI.do (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa019425db0>: Failed to establish a new connection: [Errno -3] Try again'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/growatt_server_api/sensor.py", line 88, in async_setup_entry
    devices, plant_id = await hass.async_add_executor_job(get_device_list, api, config)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/growatt_server_api/sensor.py", line 44, in get_device_list
    login_response = api.login(config[CONF_USERNAME], config[CONF_PASSWORD])
  File "/usr/local/lib/python3.10/site-packages/growattServer/__init__.py", line 128, in login
    response = self.session.post(self.get_url('newTwoLoginAPI.do'), data={
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 565, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='server-api.growatt.com', port=443): Max retries exceeded with url: /newTwoLoginAPI.do (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa019425db0>: Failed to establish a new connection: [Errno -3] Try again'))

Is it again problem with UA And is it possible UA to be "HA_[HA-Ver]_Growatt-client-Version"

Saentist avatar Jan 29 '23 16:01 Saentist

I haven't got the same issue and the integration is now written to choose a new user agent string every time Home Assistant starts, can you please try restarting home assistant and see if it fixes it?

Also, I've noticed sometimes that my home IP gets blocked, if you get a dynamic IP address from your ISP, try restarting your router to get a new IP address for your home and see if that fixes the issue.

If you still have an issue after that let me know and I'll try and investigate further.

muppet3000 avatar Jan 29 '23 16:01 muppet3000

My IP is Dynamic but is always SAME. I installed latest Update of HA with restart HA.

Is there a way to see clear message "reason of error"?

Saentist avatar Jan 29 '23 16:01 Saentist

The new version of the pypi library has better error handling so I'll try and include that in my next release. I'll also try and handle the errors better by catching them.

The error you're seeing is weird though, it doesn't seem like the same one you get when the UA gets blocked or when your IP gets banned.

Your dynamic IP doesn't seem very dynamic 😋. Does the mobile phone app still work from the same network? When my IP gets blocked then my phone stops working as well unless I switch it to 4/5G.

muppet3000 avatar Jan 29 '23 20:01 muppet3000

if it help, log from in HA integration

Logger: homeassistant.components.sensor
Source: components/growatt_server/sensor.py:43
Integration: Sensor (documentation, issues)
First occurred: 17:34:44 (1 occurrences)
Last logged: 17:34:44

Error while setting up growatt_server platform for sensor
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 72, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 358, in connect
    self.sock = conn = self._new_conn()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fa01a446290>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='server-api.growatt.com', port=443): Max retries exceeded with url: /newTwoLoginAPI.do (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa01a446290>: Failed to establish a new connection: [Errno -3] Try again'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 289, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/growatt_server/sensor.py", line 87, in async_setup_entry
    devices, plant_id = await hass.async_add_executor_job(get_device_list, api, config)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/growatt_server/sensor.py", line 43, in get_device_list
    login_response = api.login(config[CONF_USERNAME], config[CONF_PASSWORD])
  File "/usr/local/lib/python3.10/site-packages/growattServer/__init__.py", line 128, in login
    response = self.session.post(self.get_url('newTwoLoginAPI.do'), data={
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 635, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 565, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='server-api.growatt.com', port=443): Max retries exceeded with url: /newTwoLoginAPI.do (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fa01a446290>: Failed to establish a new connection: [Errno -3] Try again'))

Saentist avatar Jan 29 '23 20:01 Saentist

Is this still happening @Saentist ? I'm not sure if there's anything that I can do to fix it other than improve the logging. While this issue was happening did the ShinePhone app also stop working if it was on the same network?

muppet3000 avatar Jan 30 '23 19:01 muppet3000

App was never stopped, integration after latest reload 30min ago reconnect.

But most strange is somehow bug https://github.com/muppet3000/homeassistant-growatt_server_api/issues/3 reappear in integrated in HA rename plant to alias, but this time without change in cloud.

Guess local CEE CDN is transfer finished ;)

Saentist avatar Jan 30 '23 20:01 Saentist

That's really odd, on all fronts. The fact that nobody else logged a bug makes me thing it's specific to yourself. I just have no idea how to assist! Unfortunately I was away from my system yesterday otherwise I would have tried spinning up a new HA system using the credentials you gave me and see if it had the same problem.

Very weird. I'll leave this issue open as a reminder to improve the logging!

muppet3000 avatar Jan 30 '23 20:01 muppet3000

(Accidentally closed it - I've re-opened though.)

muppet3000 avatar Jan 30 '23 20:01 muppet3000

Offline here too since 11:00 today image image

GertJanArts avatar Feb 07 '23 12:02 GertJanArts

The API endpoints have been bouncing up and down all morning, this isn't the application getting blocked, I've been experiencing the same problem on the Android app over wi-fi and 4g all morning. I'll continue to monitor throughout the day.

Note: I plan to re-add the "server.growatt.com" URL to the endpoints to give people more options going forward if this continues to happen. It was only removed in the past because we thought it had been deprecated altogether.

muppet3000 avatar Feb 07 '23 12:02 muppet3000

I'm just looking into my issue and saw this update. Sounds the same: for me as of today the integration can't connect but also looks they've been changing things at the server as I seem to be logged out of the growatt web dashboard frequently with a "The Server Has A 500 Error(2023-02-07 12:31:34)" message

I was using the core version, remembered this version would likely be ahead with any more recent fixes so tried to install it and it can't connect "Unknown error occurred". It was working fine yesterday.

BobC76 avatar Feb 07 '23 12:02 BobC76

I'm just looking into my issue and saw this update. Sounds the same: for me as of today the integration can't connect but also looks they've been changing things at the server as I seem to be logged out of the growatt web dashboard frequently with a "The Server Has A 500 Error(2023-02-07 12:31:34)" message

I was using the core version, remembered this version would likely be ahead with any more recent fixes so tried to install it and it can't connect "Unknown error occurred". It was working fine yesterday.

See my previous comment, this is certainly maintenance on the server side of things, once it stabilises things should start working again.

On the odd occasion I've been able to get to the web UI I've noticed big gaps in the data that has been uploaded indicating also that this is a server side problem.

muppet3000 avatar Feb 07 '23 12:02 muppet3000

FWIW I locally changed the url to the "deprecated" server.growatt.com and seems to be working again. Obviously I don't know if that's coincidence and they stopped mucking around at the back end, but that url doesn't seem any less functional at any rate...

BobC76 avatar Feb 07 '23 14:02 BobC76

FWIW I locally changed the url to the "deprecated" server.growatt.com and seems to be working again. Obviously I don't know if that's coincidence and they stopped mucking around at the back end, but that url doesn't seem any less functional at any rate...

Correct, that URL is working (I've tested the same and intend to do a release with it back in tonight when I'm back from work), however I've looked at my data and it hasn't been updated in over an hour, so there's definitely still something happening on the back end.

In the ShinePhone app on my phone I've actually found that I'm now getting an "account locked" message which is new/different so I'll continue to monitor that. I'm also assuming that's related to the random changes they seem to be applying.

muppet3000 avatar Feb 07 '23 14:02 muppet3000

I was using the core version, remembered this version would likely be ahead with any more recent fixes so tried to install it and it can't connect "Unknown error occurred". It was working fine yesterday.

Haha, I did exactly the same thing today ... and ended up in the same place :-)

Geo-Ron avatar Feb 07 '23 16:02 Geo-Ron

@BobC76 @Geo-Ron @GertJanArts - Can you guys all confirm that this has stabilised for you now?

I haven't had any problems for a few hours.

muppet3000 avatar Feb 07 '23 20:02 muppet3000

I had trouble this morning, and then got 'User is blocked' on the phone app from the same network which I've never seen before - although I only started using the HA integration 2-3 days ago so that's not saying much.

Shut down HA for about 6 hours, started it again, all OK since.

catch56 avatar Feb 07 '23 20:02 catch56

I had trouble this morning, and then got 'User is blocked' on the phone app from the same network which I've never seen before - although I only started using the HA integration 2-3 days ago so that's not saying much.

Shut down HA for about 6 hours, started it again, all OK since.

To get around the 'user is blocked' thing on my phone I created some new users via the Growatt website, including a new one explicitly for use by home-assistant. The FAQ on how to create more users is here: https://github.com/muppet3000/homeassistant-growatt_server_api/blob/dev/FAQ.md#how-do-i-share-my-credentials-with-you-for-testingadding-new-features-for-my-system-type (rather than sending me the credentials, just create more for yourself :P)

muppet3000 avatar Feb 07 '23 20:02 muppet3000

Thanks got that set up, felt a bit risky potentially sacrificing my one and only account! (although no such message on the website).

catch56 avatar Feb 07 '23 20:02 catch56

@BobC76 @Geo-Ron @GertJanArts - Can you guys all confirm that this has stabilised for you now?

I haven't had any problems for a few hours.

Yep seems to have stabilised

BobC76 avatar Feb 07 '23 21:02 BobC76

Stable here since 14:18u ShinePhone app and Growatt website were stable all day

GertJanArts avatar Feb 07 '23 22:02 GertJanArts

I had trouble this morning, and then got 'User is blocked' on the phone app from the same network which I've never seen before - although I only started using the HA integration 2-3 days ago so that's not saying much.

Shut down HA for about 6 hours, started it again, all OK since.

My account that was blocked yesterday on my phone is now working again, so maybe try your previous account again. Maybe it was just a 12/24 hour block.

muppet3000 avatar Feb 08 '23 08:02 muppet3000

My accounts got blocked again - both on the server-api.growatt.com endpoint and the server.growatt.com endpoint. I was querying every 1 minute though. So I've changed that to every 3 minutes and I've created yet another account to test it with. It may be that they're just rate-limiting.

muppet3000 avatar Feb 08 '23 11:02 muppet3000

My account isnt blocked, but also all the sensors are not available. At the moment they are available, but they only update every 2 hours. Is it possible to get the information from the datalogger faster? Since a few updates ago, i also have 2 entities. One i think is the growatt and the other one is the datalogger that is connected with usb. ShinePhone is working too, but didnt show the current value.

Fannboy1337 avatar Feb 08 '23 12:02 Fannboy1337

My account isnt blocked, but also all the sensors are not available. At the moment they are available, but they only update every 2 hours. Is it possible to get the information from the datalogger faster? Since a few updates ago, i also have 2 entities. One i think is the growatt and the other one is the datalogger that is connected with usb. ShinePhone is working too, but didnt show the current value.

At present the issues with the server side of things makes this scenario very difficult to debug. Can I suggest that we wait a couple of days for all the server work to have stabilised and then you log a ticket with specifics of the issues your facing (if you're still facing them) and any functionality that you believe to be missing.

muppet3000 avatar Feb 08 '23 16:02 muppet3000

My accounts got blocked again - both on the server-api.growatt.com endpoint and the server.growatt.com endpoint. I was querying every 1 minute though. So I've changed that to every 3 minutes and I've created yet another account to test it with. It may be that they're just rate-limiting.

Do you agree now? We have major issue with the API... i going to change to every 3 minutes to

TheWalrus2 avatar Feb 08 '23 16:02 TheWalrus2

At the moment they are available, but they only update every 2 hours.

Their server has definitely been flaky today:

Logger: custom_components.growatt_server_api.sensor
Source: custom_components/growatt_server_api/sensor.py:178
Integration: Growatt Server API (documentation, issues)
First occurred: 10:14:00 (7 occurrences)
Last logged: 12:04:08

Unable to fetch data from Growatt server

On their server dashboard page, I also see gaps of 20-30 mins in the log between those hours.

Another thing to check, and this may be nothing to do with people's issues, but have you eliminated the possibility of local network issues affecting the upload from your datalogger to their server? Is the data on their server normally updated every 5 mins, or whatever your logger update frequency is set to? Is it only the HA sensor that is updating every 2 hours?

My wifi dongle is a long way from the nearest wifi access point, so the datalogger signal reports "poor" and so aside from the integration not able to reach their server, if the dongle can't reach it either there would be gaps with no update.

BobC76 avatar Feb 08 '23 17:02 BobC76

At the moment they are available, but they only update every 2 hours.

Their server has definitely been flaky today:

Logger: custom_components.growatt_server_api.sensor
Source: custom_components/growatt_server_api/sensor.py:178
Integration: Growatt Server API (documentation, issues)
First occurred: 10:14:00 (7 occurrences)
Last logged: 12:04:08

Unable to fetch data from Growatt server

On their server dashboard page, I also see gaps of 20-30 mins in the log between those hours.

Another thing to check, and this may be nothing to do with people's issues, but have you eliminated the possibility of local network issues affecting the upload from your datalogger to their server? Is the data on their server normally updated every 5 mins, or whatever your logger update frequency is set to? Is it only the HA sensor that is updating every 2 hours?

My wifi dongle is a long way from the nearest wifi access point, so the datalogger signal reports "poor" and so aside from the integration not able to reach their server, if the dongle can't reach it either there would be gaps with no update.

No issues with data being uploaded here. It's all server problems, I'm certain of it (I have a shine-lan box hard-wired to my ethernet 30cm away from my RF Dongle). It has all just stabilised again now as the evening has set in here in the UK.

I have decreased my polling interval in HA to 3 minutes (I was polling every 1 minute and my account got blocked again). I'll update again tomorrow if this remains stable. We may just have to accept less frequent updates.

Separately I'm going to have a look at some of the more 'local' options e.g. Grott, but while the API calls are still (kind of) working I'm going to keep supporting this integration. At least until I have a really solid, easy-to-use alternative.

muppet3000 avatar Feb 08 '23 17:02 muppet3000

@mjooris & @JimGermany

Just tagging you over here as you mentioned the similar issues over in the HA Core Repo: https://github.com/home-assistant/core/issues/87696

If you guys are happy to "hack" things in HA Core, then I'd really recommend just switching over to this version of the integration instead. I'm actively maintaining things over here and I'm able to deploy rapid fixes to critical issues.

The 'dev' build of this repo has the ability to use the growatt.server.com endpoint again and I plan to do a formal release as soon as I've fixed one final bug.

Notably, there's actually nothing I can really do from a code perspective to resolve the issues that we've encountered with the Growatt servers over the last 2 days other than to encourage people not to poll for information any more than every 3 minutes (the default for this Integration is 5).

muppet3000 avatar Feb 08 '23 20:02 muppet3000

Hi guys, just to add - starting from 30min ago I have a similar issue with the login in server-us.growatt.com. I use growattServer api to host a local http server with summary of my solar data. I check it this morning around 06:30 utc time and it was showing the data correctly. Since then I got the login error. I try as requested created new user - but the error remains the same even with the new user. The Andoid app is working fine and showing statistics.

I guess Growatt changed something within login routines This is my code.

def get_solar_data():
      api = growattServer.GrowattApi()
      api.server_url = 'https://server-us.growatt.com/'
      #login_response = api.login('XXX', 'XXX')	#app user and pass
      login_response = api.login('XXX', 'XXX')	#new user and pass
      print('Login response is:%s'%login_response)	#Login response is:{'msg': '507', 'success': False}

      #plant_list = api.plant_list(login_response['user']['id'])	 *****#get error   File "c:\Stani\IntranetX\pv_data\server.py", line 87, in get_solar_data plant_list = api.plant_list(login_response['user']['id']) KeyError: 'user' *****
	  
	  plant_list = api.plant_list(api.login('XXX', 'XXX'))*******#get error   File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\growattServer\__init__.py", line 135, in plant_list raise RuntimeError("Request failed: %s", response) RuntimeError: ('Request failed: %s', <Response [302]>)**** 

edibg avatar Feb 09 '23 07:02 edibg