Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skoef/growatt
Growatt API Golang client
https://github.com/skoef/growatt
golang growatt
Last synced: about 1 month ago
JSON representation
Growatt API Golang client
- Host: GitHub
- URL: https://github.com/skoef/growatt
- Owner: skoef
- Created: 2019-10-28T13:30:55.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-02T13:55:05.000Z (almost 2 years ago)
- Last Synced: 2024-06-20T22:44:40.103Z (6 months ago)
- Topics: golang, growatt
- Language: Go
- Size: 11.7 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Growatt API Golang client
[![Go Report Card](https://goreportcard.com/badge/github.com/skoef/growatt)](https://goreportcard.com/report/github.com/skoef/growatt) [![Documentation](https://godoc.org/github.com/skoef/growatt?status.svg)](http://godoc.org/github.com/skoef/growatt) [![Building](https://travis-ci.com/skoef/growatt.svg?branch=master)](https://travis-ci.com/skoef/growatt/)
This is a simple golang library using the rather quirky Growatt API on https://server.growatt.com. This libary is inspired by indykoning's [PyPi_GrowattServer](https://github.com/indykoning/PyPi_GrowattServer) and Sjord's [growatt_api_client](https://github.com/Sjord/growatt_api_client). It tries to normalize objects as much as possible, so API output is parsed and then converted into defined types within the library.
For simplicity sake, currently only several API endpoints are supported. If you miss specific features in the library, please open an issue!
## Example usage
An example for using the API client is shown below, where the credentials are those you would login to https://server.growatt.com/ with:```golang
package mainimport (
"fmt""github.com/skoef/growatt"
)func main() {
api := growatt.NewAPI("johndoe", "s3cr3t")
plants, err := api.GetPlantList()
if err != nil {
panic(err)
}fmt.Printf("found %d plants in your Growatt account\n", len(plants))
for _, plant := range plants {
inverters, err := api.GetPlantInverterList(plant.ID)
if err != nil {
continue
}fmt.Printf("plant %d has %d inverters\n", plant.ID, len(inverters))
for _, inverter := range inverters {
fmt.Printf("inverter %s is generating %0.2fW\n", inverter.Serial, inverter.CurrentPower)
}
fmt.Printf("the plant's total combined power is %0.2fW\n", plant.CurrentPower)
}
}
```