Skip to main content

Method Signature

pub async fn get_mix_ids(&mut self, plant_id: &str) -> Result<serde_json::Value>
Retrieves a list of MIX inverter devices associated with a specific plant. This method extracts the “mix” array from the response, containing device information for all MIX inverters in the plant.

Parameters

plant_id
&str
required
The unique identifier of the plant to retrieve MIX devices from

Returns

Type: Result<serde_json::Value> Returns a JSON value containing an array of MIX inverter devices. Each device object typically includes:
  • Device serial number
  • Device type information
  • Status indicators
  • Additional device-specific metadata

Errors

This method can return the following errors:
  • GrowattError::NotLoggedIn - User is not authenticated
  • GrowattError::RequestError - HTTP request failed
  • GrowattError::InvalidResponse - Empty response or invalid structure
  • GrowattError::JsonError - Failed to parse JSON response

Example

use growatt_api::Growatt;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = Growatt::new();
    
    // Login first
    client.login("username", "password").await?;
    
    // Get MIX device IDs for a plant
    let plant_id = "123456";
    let mix_devices = client.get_mix_ids(plant_id).await?;
    
    println!("MIX Devices: {}", mix_devices);
    
    Ok(())
}

API Endpoint

POST /panel/getDevicesByPlant?plantId={plant_id}

Notes

This method automatically handles session management. If the session has expired, it will attempt to re-authenticate using stored credentials before making the request.
The method specifically extracts the “mix” array from the API response structure obj.mix. If no MIX devices are found, it returns an InvalidResponse error.

Build docs developers (and LLMs) love