PlantData struct represents comprehensive information about a specific solar plant, including energy production metrics and current operational status.
Structure
This struct is defined in
src/lib.rs:52-67 and represents the detailed data returned by the Growatt API for a specific plant.Fields
All fields inPlantData are optional (Option<T>) as the API may not return all data points depending on the plant’s configuration or current status.
Name of the plant. Serialized as
"plantName" in the API.Unique identifier for the plant. Serialized as
"plantId" in the API.Total installed capacity of the plant, typically in kilowatts (kW).
Energy produced today in kilowatt-hours (kWh). Serialized as
"todayEnergy" in the API.Cumulative total energy produced since installation in kilowatt-hours (kWh). Serialized as
"totalEnergy" in the API.Current power output in watts (W). Serialized as
"currentPower" in the API.Usage Example
Handling Optional Fields
Since all fields are optional, you should use pattern matching or theOption API methods:
Calculating Metrics
You can combine fields to calculate useful metrics:Difference from Plant
ThePlant struct contains basic identification and configuration information, while PlantData provides operational metrics and energy statistics:
| Plant | PlantData |
|---|---|
| Basic info (ID, name, address) | Energy metrics |
| Static data | Dynamic/current data |
Returned by get_plants() | Returned by get_plant() |
| All plants at once | Single plant details |
Related Methods
get_plant()- RetrievesPlantDatafor a specific plantget_plants()- Retrieves list of all plants (returnsPlant, notPlantData)
The API may add additional fields in the future. The comment in the source code (
// Add more fields as needed based on the actual API response) indicates this struct may be extended.