Skip to main content
MIX devices are Growatt hybrid inverters with battery storage. This method configures the system time for AC discharge operations, which controls when the battery can discharge to power AC loads or export to the grid.
Sets the AC discharge time period for a MIX device to the current system time. This is typically used to synchronize the device’s internal clock or configure time-based discharge schedules.

Method Signature

pub async fn post_mix_ac_discharge_time_period_now(
    &mut self,
    _plant_id: &str,
    mix_sn: &str
) -> Result<serde_json::Value>

Parameters

_plant_id
&str
required
The unique identifier of the plant containing the MIX device. Note: This parameter is prefixed with underscore as it’s required by the API but not directly used in the current implementation.
mix_sn
&str
required
The serial number of the MIX device. This uniquely identifies the specific hybrid inverter you want to configure.

Returns

Returns a Result<serde_json::Value> containing the response from the device configuration endpoint, or a GrowattError if the request fails.

Errors

  • GrowattError::NotLoggedIn - If the client is not authenticated
  • GrowattError::InvalidResponse - If the response is empty or malformed
  • GrowattError::RequestError - If the HTTP request fails

Example

use growatt_api::GrowattApi;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut api = GrowattApi::new();
    
    // Login first
    api.login("username", "password").await?;
    
    // Set AC discharge time period to current time
    let response = api.post_mix_ac_discharge_time_period_now(
        "123456",
        "ABC1234567"
    ).await?;
    
    println!("Configuration Response: {:#?}", response);
    
    Ok(())
}

Implementation Details

The method automatically captures the current system time using chrono::Local::now() and formats it as YYYY-MM-DD HH:MM:SS. This timestamp is sent to the device as part of the configuration request.
let now = Local::now();
let param1 = now.format("%Y-%m-%d %H:%M:%S").to_string();

API Endpoint

POST /tcpSet.do
The method sends a form-encoded POST request with the following parameters:
  • action: “mixSet”
  • serialNum: The MIX device serial number
  • type: “pf_sys_year”
  • param1: Current timestamp in YYYY-MM-DD HH:MM:SS format

Build docs developers (and LLMs) love