You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+103-2Lines changed: 103 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,14 @@ Package to retrieve PV information from the growatt server.
5
5
Special thanks to [Sjoerd Langkemper](https://github.com/Sjord) who has provided a strong base to start off from https://github.com/Sjord/growatt_api_client
6
6
These projects may merge in the future since they are simmilar in code and function.
7
7
8
+
This library now supports both the legacy password-based authentication and the V1 API with token-based authentication for MIN systems (TLX are identified as MIN system in the public API). Certain endpoints are not supported anymore by openapi.growatt.com. For example `api.min_write_parameter()` should be used instead of old `api.update_tlx_inverter_setting()`.
The public v1 API requires token-based authentication
28
+
29
+
```python
30
+
import growattServer
31
+
32
+
api = growattServer.OpenApiV1(token="YOUR_API_TOKEN")
33
+
#Get a list of growatt plants.
34
+
plants = api.plant_list_v1()
35
+
print(plants)
36
+
```
37
+
19
38
## Methods and Variables
20
39
21
40
### Methods
22
41
23
42
Any methods that may be useful.
24
43
25
-
`api.login(username, password)` Log into the growatt API. This must be done before making any request. After this you will be logged in. You will want to capture the response to get the `userId` variable.
44
+
#### Legacy API Methods
45
+
46
+
`api.login(username, password)` Log into the growatt API. This must be done before making any request. After this you will be logged in. You will want to capture the response to get the `userId` variable. Should not be used for public v1 APIs.
26
47
27
48
`api.plant_list(user_id)` Get a list of plants registered to your account.
28
49
50
+
`api.plant_list_v1()` Get a list of plants registered to your account, using public v1 API.
51
+
52
+
`api.plant_details_v1(plant_id)` Get detailed information about a power station, using public v1 API.
53
+
54
+
`api.plant_energy_overview_v1(plant_id)` Get energy overview data for a plant, using public v1 API.
55
+
56
+
`api.plant_energy_history_v1(plant_id, start_date, end_date, time_unit, page, perpage)` Get historical energy data for a plant for multiple days/months/years, using public v1 API.
57
+
29
58
`api.plant_info(plant_id)` Get info for specified plant.
30
59
31
60
`api.plant_settings(plant_id)` Get the current settings for the specified plant
@@ -38,6 +67,8 @@ Any methods that may be useful.
38
67
39
68
`api.device_list(plant_id)` Get a list of devices in specified plant.
40
69
70
+
`api.device_list_v1(plant_id)` Get a list of devices in specified plant using the public v1 API.
71
+
41
72
`api.inverter_data(inverter_id, date)` Get some basic data of a specific date for the inverter.
42
73
43
74
`api.inverter_detail(inverter_id)` Get detailed data on inverter.
@@ -96,6 +127,34 @@ Any methods that may be useful.
96
127
97
128
`api.update_noah_settings(serial_number, setting_type, parameters)` Applies the provided parameters (dictionary or array) for the specified setting on the specified noah device; see 'Noah settings' below for more information
98
129
130
+
#### V1 API Methods
131
+
132
+
`api.plant_list()` Get a list of plants registered to your account, using public v1 API.
133
+
134
+
`api.plant_details(plant_id)` Get detailed information about a power station, using public v1 API.
135
+
136
+
`api.plant_energy_overview(plant_id)` Get energy overview data for a plant, using public v1 API.
137
+
138
+
`api.plant_energy_history(plant_id, start_date, end_date, time_unit, page, perpage)` Get historical energy data for a plant for multiple days/months/years, using public v1 API.
139
+
140
+
`api.device_list(plant_id)` Get a list of devices in specified plant using the public v1 API.
141
+
142
+
`api.min_energy(device_sn)` Get current energy data for a min inverter, including power and energy values.
143
+
144
+
`api.min_detail(device_sn)` Get detailed data for a min inverter.
145
+
146
+
`api.min_energy_history(device_sn, start_date=None, end_date=None, timezone=None, page=None, limit=None)` Get energy history data for a min inverter (7-day max range).
147
+
148
+
`api.min_settings(device_sn)` Get all settings for a min inverter.
149
+
150
+
`api.min_read_parameter(device_sn, parameter_id, start_address=None, end_address=None)` Read a specific setting for a min inverter.
151
+
152
+
`api.min_write_parameter(device_sn, parameter_id, parameter_values)` Set parameters on a min inverter. Parameter values can be a single value, a list, or a dictionary.
153
+
154
+
`api.min_write_time_segment(device_sn, segment_id, batt_mode, start_time, end_time, enabled=True)` Update a specific time segment for a min inverter.
155
+
156
+
`api.min_read_time_segments(device_sn, settings_data=None)` Read all time segments from a MIN inverter. Optionally pass settings_data to avoid redundant API calls.
157
+
99
158
### Variables
100
159
101
160
Some variables you may want to set.
@@ -118,6 +177,8 @@ The library can be initialised to introduce randomness into the User Agent field
118
177
119
178
This has been added since the Growatt servers started checking for the presence of a `User-Agent` field in the headers that are sent.
120
179
180
+
#### Legacy API Initialization
181
+
121
182
By default the library will use a pre-set `User-Agent` value which identifies this library while also appearing like an Android device. However, it is also possible to pass in parameters to the intialisation of the library to override this entirely, or just add a random ID to the value. e.g.
122
183
123
184
```python
@@ -128,6 +189,12 @@ api = growattServer.GrowattApi(True) # Adds a randomly generated User ID to the
128
189
api = growattServer.GrowattApi(False, "my_user_agent_value") # Overrides the default and uses "my_user_agent_value" in the User-Agent header
129
190
```
130
191
192
+
#### V1 API Initialization
193
+
194
+
```python
195
+
api = growattServer.GrowattApiV1(token="YOUR_API_TOKEN") # Initialize with your API token
196
+
```
197
+
131
198
Please see the `user_agent_options.py` example in the `examples` directory if you wish to investigate further.
132
199
133
200
## Examples
@@ -240,6 +307,40 @@ The four functions `update_tlx_inverter_setting`, `update_mix_inverter_setting`,
240
307
241
308
Only the settings described above have been tested with `update_tlx_inverter_setting` and they all take only one single parameter. It is very likely that the function works with all settings returned by `tlx_get_enabled_settings`, but this has not been tested. A helper function `update_tlx_inverter_time_segment` is provided for the settings that require more than one parameter.
242
309
310
+
## MIN/TLX Inverter Settings Using V1 API
311
+
312
+
For MIN/TLX systems, the public V1 API provides a more robust way to read and write inverter settings:
313
+
314
+
***Read Parameter**
315
+
* function: `api.min_read_parameter`
316
+
* parameters:
317
+
*`device_sn`: The device serial number
318
+
*`parameter_id`: Parameter ID to read (e.g., "discharge_power")
319
+
*`start_address`, `end_address`: Optional, for reading registers by address
320
+
321
+
***Write Parameter**
322
+
* function: `api.min_write_parameter`
323
+
* parameters:
324
+
*`device_sn`: The device serial number
325
+
*`parameter_id`: Parameter ID to write (e.g., "ac_charge")
326
+
*`parameter_values`: Value to set (single value, list, or dictionary)
*`start_time`: Datetime.time object for segment start
335
+
*`end_time`: Datetime.time object for segment end
336
+
*`enabled`: Boolean to enable/disable segment
337
+
338
+
***Read Time Segments**
339
+
* function: `api.min_read_time_segments`
340
+
* parameters:
341
+
*`device_sn`: The device serial number
342
+
*`settings_data`: Optional settings data to avoid redundant API calls
343
+
243
344
## Noah Settings
244
345
The noah settings function allow you to change individual values on your noah system e.g. system default output power, battery management, operation mode and currency
245
346
From what has been reverse engineered from the api, each setting has a `setting_type` and a set of `parameters` that are relevant to it.
@@ -287,4 +388,4 @@ The library contains functions that allow you to modify the configuration of you
287
388
288
389
To the best of our knowledge only the `settings` functions perform modifications to your system and all other operations are read only. Regardless of the operation:
289
390
290
-
***The library is used entirely at your own risk.***
391
+
***The library is used entirely at your own risk.***
0 commit comments