+
Skip to content

gonzolino/gotado

Repository files navigation

gotado

CodeQL Go Report Card PkgGoDev

Go client for the tado° Web API. Still in early development, so only a subset of the API functionality is implemented.

Installation

Install gotado with go get:

go get github.com/gonzolino/gotado

Then you can import "github.com/gonzolino/gotado" in your packages. Have a look at the examples directory to see example code.

Usage

Authentication

Authentication to the tado° API is done using OAuth 2.0. The details are documented here.

Gotado requires an oauth2.Config and a oauth2.Token to make authenticated requests. An authentication flow on the CLI could look like this:

ctx := context.Background()
config := gotado.AuthConfig(clientID)

deviceAuth, err := config.DeviceAuth(ctx)

// The user must visit the verification URI and authenticate with his personal credentials.
// Afterwards an access token will be generated.
fmt.Printf("To authenticate, visit %s\n", deviceAuth.VerificationURIComplete)

token, err := config.DeviceAccessToken(ctx, deviceAuth)

Be aware that an access token is only valid for 10 minutes. To keep authenticated for longer, you will need to request a refresh token during authentication. You can do this by adding the offline_access scope to the auth config:

config := gotado.AuthConfig(clientID, "offline_access")

Gotado will automatically refresh the access token when it expires, if a refresh token is available.

Getting Started

Get started by creating a client object:

tado := gotado.New(ctx, config, token)

With the client you can start using the gotado functions:

me, err := tado.Me(ctx)
fmt.Printf("User Email: %s\n", me.Email)

home, err := me.GetHome(ctx, "My Home Name")
fmt.Printf("Home Address:\n%s\n%s %s\n", *home.Address.AddressLine1, *home.Address.ZipCode, *home.Address.City)

Just have a look at the package documentation to learn more about whats possible.

Contributing

Please feel free to submit issues and/or pull requests if you discover bugs or missing features.

About

Go client for the tado° Web API

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 8

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载