|
2 | 2 |
|
3 | 3 | This version of the API follows the newer [OpenAPI V1 API](https://www.showdoc.com.cn/262556420217021/0) Growatt has made available. |
4 | 4 |
|
5 | | -It extends our ["Legacy" ShinePhone](./shinephone.md) so methods from [there](./shinephone.md#methods) should be available, but it's safer to rely on the functions described in this file where possible. |
| 5 | +It extends our ["Legacy" ShinePhone](./shinephone.md) so methods from [there](./shinephone.md#methods) should be available, but it's safer to rely on the methods described in this file where possible. |
6 | 6 |
|
7 | 7 | ## Usage |
8 | 8 |
|
@@ -33,6 +33,36 @@ Methods that work across all device types. |
33 | 33 | | `api.plant_energy_history(plant_id, start_date, end_date, time_unit, page, perpage)` | plant_id: String, start_date: Date, end_date: Date, time_unit: String, page: Int, perpage: Int | Get historical energy data for a plant for multiple days/months/years. | |
34 | 34 | | `api.device_list(plant_id)` | plant_id: String | Get a list of devices in specified plant. | |
35 | 35 |
|
| 36 | +#### Devices |
| 37 | + |
| 38 | +Devices offer a generic way to interact with your device using the V1 API without needing to provide your S/N every time. And can be used instead of the more specific device methods in the API class. |
| 39 | + |
| 40 | +```python |
| 41 | +import growattServer |
| 42 | +from growattServer.open_api_v1.devices import Sph, Min |
| 43 | + |
| 44 | +api = growattServer.OpenApiV1(token="YOUR_API_TOKEN") |
| 45 | + |
| 46 | +my_inverter = Sph(api, 'YOUR_DEVICE_SERIAL_NUMBER') # or Min(api, 'YOUR_DEVICE_SERIAL_NUMBER') |
| 47 | +my_inverter.detail() |
| 48 | +my_inverter.energy() |
| 49 | +my_inverter.energy_history() |
| 50 | +my_inverter.read_parameter() |
| 51 | +my_inverter.write_parameter() |
| 52 | +``` |
| 53 | + |
| 54 | +| Method | Arguments | Description | |
| 55 | +|:---|:---|:---| |
| 56 | +| `device.energy()` | None | Get current energy data for any inverter, including power and energy values. | |
| 57 | +| `device.detail()` | None | Get detailed data for any inverter. | |
| 58 | +| `device.energy_history(start_date=None, end_date=None, timezone=None, page=None, limit=None)` | start_date: Date, end_date: Date, timezone: String, page: Int, limit: Int | Get energy history data for any inverter (7-day max range). | |
| 59 | +| `device.read_parameter(parameter_id, start_address=None, end_address=None)` | parameter_id: String, start_address: Int, end_address: Int | Read a specific setting for any inverter. | |
| 60 | +| `device.write_parameter(parameter_id, parameter_values)` | parameter_id: String, parameter_values: Dict/Array | Set parameters on any inverter. Parameter values can be a single value, a list, or a dictionary. | |
| 61 | + |
| 62 | +For more details see: [OpenApiV1 Devices](./openapiv1/devices.md) |
| 63 | + |
| 64 | +The remaining methods below all actually use these device methods. |
| 65 | + |
36 | 66 | #### MIN Methods |
37 | 67 |
|
38 | 68 | Methods for MIN devices (type 7). |
@@ -73,7 +103,7 @@ Convenience methods that wrap the core SPH methods above for common use cases. |
73 | 103 |
|
74 | 104 | #### Classic methods |
75 | 105 |
|
76 | | -Methods from [classic API](./shinephone.md#methods) should be available, but it's safer to rely on the functions described in this section where possible. There is no guarantee that the classic API methods will work, or remain stable through updates. |
| 106 | +Methods from [classic API](./shinephone.md#methods) should be available, but it's safer to rely on the methods described in this section where possible. There is no guarantee that the classic API methods will work, or remain stable through updates. |
77 | 107 |
|
78 | 108 | ### Variables |
79 | 109 |
|
|
0 commit comments