from_env
Creates a new Growatt client with configuration loaded from environment variables.Environment Variables
This method reads the following environment variables:The username for Growatt API authentication
The password for Growatt API authentication
Alternative base URL for the Growatt API. Defaults to
https://server.growatt.com if not setSession duration in minutes. Defaults to 30 minutes if not set
Returns
Returns a newGrowatt instance configured with values from environment variables.
Example
You can set environment variables in a
.env file in your project directory. The dotenv crate will automatically load them.with_alternate_url
Configures the client to use the alternate Growatt API URL.Returns
Returnsself with the base URL set to https://openapi.growatt.com.
Example
This method uses the builder pattern and returns
self, allowing method chaining with other configuration methods.with_session_duration
Configures the client session duration.Parameters
The session duration in minutes. Sessions will automatically re-authenticate after this duration expires.
Returns
Returnsself with the session duration configured.
Example
Chaining Multiple Configurations
The client automatically manages session expiration and will re-authenticate when needed, as long as credentials were provided during the initial
login() call.