Giter Site home page Giter Site logo

sjord / growatt_api_client Goto Github PK

View Code? Open in Web Editor NEW
66.0 13.0 28.0 40 KB

Use indykoning/PyPi_GrowattServer instead of this project.

Home Page: https://github.com/indykoning/PyPi_GrowattServer

License: MIT License

Python 100.00%
photovoltaic-panels growatt mit-license

growatt_api_client's Introduction

Growatt API client

This Python script logs in to server.growatt.com and retrieves data on solar panels.

Deprecated

Use indykoning/PyPi_GrowattServer instead.

Usage

Create a new GrowattApi instance, log in, retrieve a list of plants and request details of these plants. An example can be found in growatt/__main__.py, and can be run using python -m growatt.

API

Currently this package uses an API that I reverse engineered the API from the Growatt mobile app. This is more of an internal API that can be changed by Growatt if they want.

There is also an API specification for a more standard API, but that is currently not used by this package.

Getting started

Run the following commands to set up a new virtualenv and run the growatt API example:

git clone https://github.com/Sjord/growatt_api_client
cd growatt_api_client
python3 -m venv venv                    # create a new virtual environment in the directory 'venv'
. venv/bin/activate                     # activate this environment
./setup.py install                      # install all dependencies
python -m growatt 'username' 'password' # retrieve data for today

After setting up like this, you can just run the python from the virtualenv each time you want to run it:

venv/bin/python -m growatt 'username' 'password'

If you want to create your own client, start from growatt/__main__.py. Copy it and change it to your liking, and then run it like this:

venv/bin/python myscript.py 'username' 'password'

growatt_api_client's People

Contributors

sjord avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

growatt_api_client's Issues

Growatt data is. W

In Home Assistent every few minutes it gives an error,
using home assistent 0.81.4
Growatt data is. W
11:02 custom_components/sensor/growatt.py (ERROR)

I can't log in

even by putting username and password in single quotes the login exception is raised

"requests" not found during install

Trying to install on termux on Android and get

Processing dependencies for growatt==0.0.4
Searching for requests
Reading https://pypi.org/simple/requests/
Download error on https://pypi.org/simple/requests/: unknown url type: https -- Some packages may not be found!
Couldn't find index page for 'requests' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
Download error on https://pypi.org/simple/: unknown url type: https -- Some packages may not be found!
No local packages or working download links found for requests
error: Could not find suitable distribution for Requirement.parse('requests')

Help!

Growatt API Add Data

How would I add more data to the JSON read out that is not already available there?

I see there are things like "PlantList.do" but where do I find these .do files or tags

Thank you so much for the API btw.

Login using an Installer Account

Anyone tried login using an Installer account? I'm a installer, when I try this code:
"api.login(username, password)" using my credentials, I get this message: "{'success': False, 'msg': '502'}"

I wish I could get a list plant_list of all my instalattions.

no currentPower Data

Hi,

i get all values, but no currenpower data?

is there a reason for it?

best regards

Chris

{'data': [{'plantMoneyText': '112.9 (¥)', 'plantName': 'HomeSolar1', 'plantId': '828578', 'isHaveStorage': 'false', 'todayEnergy': '0.4 kWh', 'totalEnergy': '94.1 kWh', 'currentPower': '0 W'}], 'totalData': {'currentPowerSum': '0 W', 'CO2Sum': '93.82 T', 'isHaveStorage': 'false', 'eTotalMoneyText': '112.9 (¥)', 'todayEnergySum': '0.4 kWh', 'totalEnergySum': '94.1 kWh'}, 'success': True}
{'plantData': {'plantMoneyText': '0.5 (¥)', 'plantName': 'HomeSolar1', 'plantId': '828578', 'currentEnergy': '0.4 kWh'}, 'data': {}, 'success': True}

I have the settings for SPA devices!!!

Its not an issue, but I have finally cracked the SPA api config to get and update the battery settings ie, Bat first etc etc.

I dont know if this is the place to post but if incorrect, please delete or move.

getSpaSetParams
https://server-api.growatt.com/newSpaApi.do?op=getSpaSetParams&kind=0&spaId=IDHERE

spaSetApi
https://server-api.growatt.com/newTcpsetAPI.do?op=spaSetApi&param1=100&param10=21&param11=00&param12=1&param13=10&param14=00&param15=16&param16=00&param17=1&param2=100&param3=04&param4=30&param5=18&param6=00&param7=1&param8=20&param9=30&serialNum=SERIALID&type=spa_ac_charge_time_period

What a pain in the A that was!!!

Getting weekly results

Is there a way to retrieve weekly?
i did edit the __init__py and add week

return date.strftime("%W")
elif self == Timespan.week:

and week = 5

aswell added this api.plant_detail(plant_id, Timespan.week, datetime.date.today())

but getting an error that week doesn't work.

regards

Black listed

Hello,
Everything was running fine, until this week. I think I was blacklisted with my local machine, do you know what I could do?
I can't login with the api anymore (I tested 3 different logins and they worked in UI).

api = GrowattApi()
response = api.login(user_login, password)

Then I got this error:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Then I run in this way to get the response text:

response = api.session.post(
    api.get_url("newLoginAPI.do"),
    data={"userName": user_login, "password": password_md5},
)
response.text

response:
'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>403 Forbidden</title></head><body><h1>403 Forbidden</h1><p>You don\'t have permission to access the URL on this server.</p><p>denied by UA ACL = blacklist</p><hr/>Powered by Tengine <br/>CDN Request Id: 4f85b19f16688496115357515e</body></html>'

Readout SPA Values?

Is there a command to get the battery values of a Growatt SPA? Mix doesn’t deliver any values.

Current Power Value different to web / mobile app

I get the following results from your script... with u'currentPower': u'2.44 kW'

{u'data': [{u'todayEnergy': u'32.6 kWh', u'totalEnergy': u'105 kWh', u'currentPower': u'2.44 kW', u'isHaveStorage': u'false', u'plantMoneyText': u'525.0 ', u'plantId': u'274240', u'plantName': u'R19'}, {u'todayEnergy': u'0 kWh', u'totalEnergy': u'0 kWh', u'currentPower': u'0 W', u'isHaveStorage': u'false', u'plantMoneyText': u'0.0 ', u'plantId': u'274226', u'plantName': u'R18'}], u'success': True, u'totalData': {u'totalEnergySum': u'105 kWh', u'todayEnergySum': u'32.6 kWh', u'eTotalMoneyText': u'525.0 ', u'CO2Sum': u'104.68 T', u'isHaveStorage': u'false', u'currentPowerSum': u'2.44 kW'}}

but on the website and the iOS app, I get Current Power 3.21kW why is there such a significant difference?

Also how do I get rid of the "u" being littered around the data?

Growatt API Documentation

Hi. I'm planning to create an Lib, like yours, but in PHP, that consumes the WEB API from Growatt.

I was searching by a Growatt API documentation, and find a Strange Documentation Here, but it seems to be not working. (Or I am consuming it wrong, maybe?)

After all, my question is: What documentation you use to build the project?

Log in problems - again

Apologies - Have downloaded and installed. Updated as per advice in issue 32 and 30. Have tried all versions of server url (growatt-api.com, growatt-us.com and growatt.com - all with both https:// and http://) but I am still getting failed login. Any advice greatly received. I am trying to use my pi to create a power switch that turns on when the PV panels are generating sufficient power (to charge my EV)

(venv) rstedman@raspberrypi:~/growatt_api_client $ venv/bin/python3.9 -m growatt '{my-username}' '{my-password}'
Traceback (most recent call last):
File "/home/rstedman/growatt_api_client/growatt/init.py", line 71, in login
result = self._back_success_response(response)
File "/home/rstedman/growatt_api_client/growatt/init.py", line 157, in _back_success_response
raise GrowattApiError("Request failed: %s" % response)
growatt.GrowattApiError: Request failed: <Response [400]>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/rstedman/growatt_api_client/growatt/main.py", line 9, in
api.login(username, password)
File "/home/rstedman/growatt_api_client/growatt/init.py", line 76, in login
raise LoginError
growatt.LoginError

Problem with login

Hello have any solutions i cant login

└> python3.8 -m growatt '' ''
Traceback (most recent call last):
File "/home/slaserx/lab/growatt_api_client/growatt/init.py", line 71, in login
result = self._back_success_response(response)
File "/home/slaserx/lab/growatt_api_client/growatt/init.py", line 157, in _back_success_response
raise GrowattApiError("Request failed: %s" % response)
growatt.GrowattApiError: Request failed: <Response [400]>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/slaserx/lab/growatt_api_client/growatt/main.py", line 9, in
api.login(username, password)
File "/home/slaserx/lab/growatt_api_client/growatt/init.py", line 76, in login
raise LoginError
growatt.LoginError

kWh instead of MWh

When I use planet_info I got the total energy in MWh. But I need it in kWh.
Is there a way to set the unit?

new server doesn't work

Growatt created a new server because the old one was getting overloaded (at least that's what they told me). The new server is server-us.growatt.com. The old server is server.growatt.com. I can pull data from accounts on the old server but I'm unable to pull data from the new server with an account that is on the new server. I changed the URL to server-us.growatt.com in the init.py but that didn't seem to work.

SPF 5000 ES errors api.get_all_device_list

Hi! I have a SPF 5000 ES Growatt and I was able to connect to server.growatt.com and use the plant_list, plant_detail, get_user_center_energy methods, but when I call get_all_device_list it throws the following error:
raise JSONDecodeError("Expecting value", s, err.value) from None
JSONDecodeError: Expecting value

Also, I've try to call the methods from Storage, Mix or SPA classes (for example get_storage_energy_data or get_energy_prod_and_cons_data), but I get the Response 400 or 500:
GrowattApiError: Request failed: <Response [500]>

I've look on the Growatt dashboard and under devices there is only one device, type Storage with the associated data logger. I've copy and paste the device sn from the web page and try to call some of the methods, but still have errors.
Do I need to configure additional settings? How can it be solved?
I appreciate your advice!

Current/daily usage

Thank you for this amazing app.

I was wondering if there is an API to find daily consumption?

I'm trying to compare my Solar charge against usage to figure out if my battery has fully charged. (My SOC graph stays on 100% until the battery is pretty much dead- the BMS cannot connect to my inverter).

Exception when launching venv/bin/python -m growatt <user> <password>

Hi,
I've executed all steps but when launching to connect to my growatt server, I receive the following exception. User and password are correct.

``_Traceback (most recent call last):
File "/Users/achimera/dev/growatt_api_client/growatt/init.py", line 71, in login
result = self._back_success_response(response)
File "/Users/achimera/dev/growatt_api_client/growatt/init.py", line 147, in _back_success_response
raise GrowattApiError()
growatt.GrowattApiError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in run_code
exec(code, run_globals)
File "/Users/achimera/dev/growatt_api_client/growatt/main.py", line 9, in
api.login(username, password)
File "/Users/achimera/dev/growatt_api_client/growatt/init.py", line 75, in login
raise LoginError
``

JSONDecodeError: Expecting value: line 6 column 1 (char 10)

Hi! I started using this repository, and initially I always received the login error. So I did some research and realized that the server used for the login and password I have is oss.growatt.com. So I changed the server url, but a new error appeared and I've been trying to solve for days and nothing.
The error is this -> JSONDecodeError: Expecting value: line 6 column 1 (char 10)
Could someone tell me why this is?

HTTP 403 on login due to auth change ?

Seems like Growatt implemented/updated something in the loginflow.
Since a couple of days a html 403 response with working credentials on the webpage

Traceback (most recent call last):
File "C:\Program Files (x86)\Python37-32\lib\site-packages\growatt_init_.py", line 49, in login
return self.back_success_response(response)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\growatt_init
.py", line 82, in _back_success_response
raise GrowattApiError("Request failed: %s" % response)
growatt.GrowattApiError: Request failed: <Response [403]>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\Python37-32\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "C:\Program Files (x86)\Python37-32\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\growatt_main
.py", line 9, in
api.login(username, password)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\growatt_init
.py", line 51, in login
raise LoginError
growatt.LoginError

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.