Ewelink SDK to control your eWelink smart devices.
Check out the API Documentation http://godoc.org/github.com/pavelbazika/ewelink
The library can be installed through go get
go get github.com/pavelbazika/ewelink
We support the two major Go versions, which are 1.15 and 1.16 at the moment.
- Retrieve devices
- Turn on/off devices
- Get power consumption [TODO]
import (
"context"
"fmt"
"github.com/pavelbazika/ewelink"
)
instance := ewelink.New()
// authenticate using email
session, err := instance.AuthenticateWithEmail(
context.Background(), ewelink.NewConfiguration("REGION"), "EMAIL", "PASSWORD")
// retrieve the list of registered devices
devices, err := instance.GetDevices(context.Background(), session)
// turn on the outlet(s) of the first device
response, err := instance.SetDevicePowerState(context.Background(), session, &devices.Devicelist[0], true)
fmt.Println(response)
fmt.Println(err)
You can provide your own AppId and AppSecret, which can be retrieved from https://dev.ewelink.cc.
ewelink.NewConfiguration("REGION", ewelink.WithAppID("APP_ID"), ewelink.WithAppSecret("APP_SECRET"))
go test -v -race ./...
We use GitHub Actions to make sure the codebase is consistent (golangci-lint run
) and continuously tested (go test -v -race $(go list ./... | grep -v vendor)
). We try to keep comments at a maximum of 120 characters of length and code at 120.
If you find any problems or have suggestions about this library, please submit an issue. Moreover, any pull request, code review and feedback are welcome.