tado

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenURL      = "https://login.tado.com/oauth2/token"
	AuthorizeURL  = "https://login.tado.com/oauth2/authorize"
	DeviceAuthURL = "https://login.tado.com/oauth2/device_authorize"
	TenantID      = "1d543ad5-a8ac-4704-b9e2-26838b4d6513"
)
View Source
const (
	// User agent matching real iOS Safari traffic
	IOSUserAgent = "" /* 135-byte string literal not displayed */

	// User agent for API requests
	IOSAPIUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
)
View Source
const (
	BaseURL = "https://my.tado.com"
)
View Source
const (
	// Firefox User Agent from real traffic
	FirefoxUserAgent = "Mozilla/5.0 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0"
)

Variables

This section is empty.

Functions

func GetWebAppRelease added in v1.0.4

func GetWebAppRelease() string

func NewAPIClient

func NewAPIClient(platform string) *req.Client

NewAPIClient creates an API client for the given client type

func NewAuthClient

func NewAuthClient(platform string) *req.Client

func NewFirefoxAPIClient

func NewFirefoxAPIClient() *req.Client

NewFirefoxAPIClient creates an HTTP client configured for API requests (Firefox)

func NewFirefoxAuthClient

func NewFirefoxAuthClient() *req.Client

NewFirefoxAuthClient creates an HTTP client configured for auth requests (Firefox)

func NewFirefoxClient

func NewFirefoxClient() *req.Client

NewFirefoxClient creates an HTTP client that impersonates Firefox with proper TLS fingerprinting and header ordering matching real traffic

func NewFirefoxTokenClient

func NewFirefoxTokenClient() *req.Client

NewFirefoxTokenClient creates an HTTP client configured for token exchange requests (Firefox)

func NewIOSSafariAPIClient

func NewIOSSafariAPIClient() *req.Client

NewIOSSafariAPIClient creates an HTTP client configured for API requests

func NewIOSSafariAuthClient

func NewIOSSafariAuthClient() *req.Client

NewIOSSafariAuthClient creates an HTTP client configured for auth requests

func NewIOSSafariClient

func NewIOSSafariClient() *req.Client

NewIOSSafariClient creates an HTTP client that impersonates iOS Safari with proper TLS fingerprinting and header ordering matching real traffic

func NewIOSSafariTokenClient

func NewIOSSafariTokenClient() *req.Client

NewIOSSafariTokenClient creates an HTTP client configured for token exchange requests

func NewTokenClient

func NewTokenClient(platform string) *req.Client

NewTokenClient creates a token client for the given client type

Types

type APIError

type APIError struct {
	StatusCode int
	Body       string
}

func (*APIError) Error

func (e *APIError) Error() string

type Auth added in v1.2.0

type Auth struct{}

Auth handles OAuth authentication with tado's API. It implements tokens.TokenAuthProvider. It is stateless and can be safely shared across goroutines.

func NewAuth added in v1.2.0

func NewAuth() *Auth

NewAuth creates a new Auth instance.

func (*Auth) Authorize added in v1.2.0

func (a *Auth) Authorize(
	ctx context.Context,
	clientID, redirectURI, scope,
	email, password, platform string,
) (*tokens.TokenResult, error)

Authorize performs the OAuth password grant flow. Implements tokens.TokenAuthProvider.

func (*Auth) DeviceAuthorize added in v1.2.0

func (a *Auth) DeviceAuthorize(ctx context.Context, clientID, scope string) (*DeviceAuthResponse, error)

DeviceAuthorize initiates device code authorization flow.

func (*Auth) ExchangeDeviceCode added in v1.2.0

func (a *Auth) ExchangeDeviceCode(ctx context.Context, clientID, deviceCode string) (*tokens.TokenResult, error)

ExchangeDeviceCode exchanges a device code for tokens.

func (*Auth) RefreshToken added in v1.2.0

func (a *Auth) RefreshToken(ctx context.Context, clientID, refreshToken, platform string) (*tokens.TokenResult, error)

RefreshToken refreshes an OAuth token. Implements tokens.TokenAuthProvider.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles tado-specific business logic like account creation and device codes.

func NewClient

func NewClient(app core.App, auth *Auth, tokenManager *tokens.Manager) *Client

NewClient creates a new Client.

func (*Client) CreateCode

func (c *Client) CreateCode(e *core.RecordRequestEvent) error

func (*Client) DeleteUnusedCodes added in v1.0.4

func (c *Client) DeleteUnusedCodes() error

func (*Client) GetMe

func (c *Client) GetMe(ctx context.Context, accessToken, platform string) (*MeResponse, error)

func (*Client) LoadAccountData

func (c *Client) LoadAccountData(ctx context.Context, account *core.Record) error

LoadAccountData creates tokens for all password grant clients and fetches account homes.

func (*Client) Register

func (c *Client) Register()

Register sets up event hooks for the client.

func (*Client) WaitForDeviceAuthorization

func (c *Client) WaitForDeviceAuthorization(
	ctx context.Context,
	clientRecord *core.Record,
	codeRecord *core.Record,
) error

type DeviceAuthResponse

type DeviceAuthResponse struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri"`
	VerificationURIComplete string `json:"verification_uri_complete"`
	ExpiresIn               int    `json:"expires_in"`
	Interval                int    `json:"interval"`
}

DeviceAuthResponse is the device authorization response.

type MeResponse

type MeResponse struct {
	ID    string `json:"id"`
	Homes []struct {
		ID   int    `json:"id"`
		Name string `json:"name"`
	}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL