Skip to main content

Method Signature

pub async fn get_energy_stats_yearly(
    &mut self,
    year: &str,
    plant_id: &str,
    mix_sn: &str
) -> Result<serde_json::Value>
Retrieves energy statistics for a specific year for a MIX inverter. Returns monthly energy production and consumption data for the entire year.

Parameters

year
&str
required
The year for which to retrieve statistics.
Format: YYYY (e.g., “2025”)
plant_id
&str
required
The unique identifier of the plant.
mix_sn
&str
required
The serial number of the MIX inverter.

Returns

Result<serde_json::Value>
Result
Returns a Result containing:
  • Ok(serde_json::Value): JSON object with yearly energy statistics including monthly breakdown
  • Err(GrowattError): Error if the request fails, authentication is invalid, or response is empty

Example

use growatt_api::GrowattApi;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut api = GrowattApi::new();
    api.login("username", "password").await?;
    
    let stats = api.get_energy_stats_yearly(
        "2025",
        "1234567",
        "ABC123XYZ"
    ).await?;
    
    println!("Yearly energy stats: {}", stats);
    
    Ok(())
}

API Endpoint

POST /panel/mix/getMIXEnergyYearChart

Notes

  • Requires authentication via login() before calling
  • Automatically checks login status before making the request
  • Returns monthly energy data for each month in the specified year
  • Throws InvalidResponse error if the response is empty or null

Build docs developers (and LLMs) love