Documentation
¶
Overview ¶
Package tado provides an API Client for the Tadoº smart thermostat devices
Using this package typically involves creating an APIClient as follows:
client := tado.New("your-tado-username", "your-tado-password", "your-tado-secret")
Once a client has been created, you can query tado.com for information about your different Tado devices. Currently, the following endpoints are supported:
GetZones: get the different zones (rooms) defined in your home GetZoneInfo: get metrics for a specified zone in your home GetWeatherInfo: get overall weather information GetMobileDevices: get status of each registered mobile device SetZoneOverlay set a permanent overlay for a zone SetZoneOverlayWithDuration set a temporary overlay for a zone DeleteZoneOverlay delete the overlay for a zone
Index ¶
- Constants
- type API
- type APIClient
- func (client *APIClient) DeleteZoneOverlay(ctx context.Context, zoneID int) (err error)
- func (client *APIClient) GetMobileDevices(ctx context.Context) (tadoMobileDevices []MobileDevice, err error)
- func (client *APIClient) GetWeatherInfo(ctx context.Context) (weatherInfo WeatherInfo, err error)
- func (client *APIClient) GetZoneInfo(ctx context.Context, zoneID int) (tadoZoneInfo ZoneInfo, err error)
- func (client *APIClient) GetZones(ctx context.Context) (zones []Zone, err error)
- func (client *APIClient) SetZoneOverlay(ctx context.Context, zoneID int, temperature float64) (err error)
- func (client *APIClient) SetZoneOverlayWithDuration(ctx context.Context, zoneID int, temperature float64, duration time.Duration) (err error)
- type Authenticator
- type ConnectionState
- type Device
- type MobileDevice
- type MobileDeviceLocation
- type MobileDeviceLocationState
- type MobileDeviceSettings
- type Percentage
- type Temperature
- type Value
- type WeatherInfo
- type Zone
- type ZoneInfo
- type ZoneInfoActivityDataPoints
- type ZoneInfoOpenWindow
- type ZoneInfoOverlay
- type ZoneInfoOverlaySetting
- type ZoneInfoOverlayTermination
- type ZoneInfoSensorDataPoints
- type ZoneInfoSetting
- type ZoneState
Constants ¶
const ( // ZoneStateUnknown indicates the zone's state is not initialized yet ZoneStateUnknown = iota // ZoneStateOff indicates the zone's heating is switched off ZoneStateOff // ZoneStateAuto indicates the zone's heating is controlled manually (e.g. as per schedule) ZoneStateAuto // ZoneStateTemporaryManual indicates the zone's target temperature is set manually, for a period of time ZoneStateTemporaryManual // ZoneStateManual indicates the zone's target temperature is set manually ZoneStateManual )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
GetZones(context.Context) ([]Zone, error)
GetZoneInfo(context.Context, int) (ZoneInfo, error)
GetWeatherInfo(context.Context) (WeatherInfo, error)
GetMobileDevices(context.Context) ([]MobileDevice, error)
SetZoneOverlay(context.Context, int, float64) error
SetZoneOverlayWithDuration(context.Context, int, float64, time.Duration) error
DeleteZoneOverlay(context.Context, int) error
}
API for the Tado APIClient.
type APIClient ¶
type APIClient struct {
// Authenticator handles logging in to the Tado server
Authenticator Authenticator
// HTTPClient is used to perform HTTP requests
HTTPClient *http.Client
// APIURL can be left blank. Only exposed for unit tests.
APIURL string
HomeID int
// contains filtered or unexported fields
}
APIClient represents a Tado API client.
func New ¶ added in v0.5.0
New creates a new client
clientSecret can typically be left blank. If the default secret does not work, your client secret can be found by visiting https://my.tado.com/webapp/env.js after logging in to https://my.tado.com
func (*APIClient) DeleteZoneOverlay ¶
DeleteZoneOverlay deletes the overlay (manual temperature setting) for the specified ZoneID
func (*APIClient) GetMobileDevices ¶
func (client *APIClient) GetMobileDevices(ctx context.Context) (tadoMobileDevices []MobileDevice, err error)
GetMobileDevices retrieves the status of all registered mobile devices.
func (*APIClient) GetWeatherInfo ¶
func (client *APIClient) GetWeatherInfo(ctx context.Context) (weatherInfo WeatherInfo, err error)
GetWeatherInfo retrieves weather information for the user's Home.
func (*APIClient) GetZoneInfo ¶
func (client *APIClient) GetZoneInfo(ctx context.Context, zoneID int) (tadoZoneInfo ZoneInfo, err error)
GetZoneInfo gets the info for the specified ZoneID
func (*APIClient) GetZones ¶
GetZones retrieves the different Zones configured for the user's Home ID
func (*APIClient) SetZoneOverlay ¶
func (client *APIClient) SetZoneOverlay(ctx context.Context, zoneID int, temperature float64) (err error)
SetZoneOverlay sets an overlay (manual temperature setting) for the specified ZoneID
func (*APIClient) SetZoneOverlayWithDuration ¶ added in v0.4.1
func (client *APIClient) SetZoneOverlayWithDuration(ctx context.Context, zoneID int, temperature float64, duration time.Duration) (err error)
SetZoneOverlayWithDuration sets an overlay (manual temperature setting) for the specified ZoneID for a specified amount of time. If duration is zero, it calls SetZoneOverlay.
type Authenticator ¶ added in v0.5.0
type Authenticator interface {
AuthHeaders(ctx context.Context) (header http.Header, err error)
Reset()
}
Authenticator provides authentication services for tado.com
type ConnectionState ¶
ConnectionState contains the connection state of a Tado device
type Device ¶
type Device struct {
DeviceType string `json:"deviceType"`
Firmware string `json:"currentFwVersion"`
ConnectionState ConnectionState `json:"connectionState"`
BatteryState string `json:"batteryState"`
}
Device contains attributes of a Tado device
type MobileDevice ¶
type MobileDevice struct {
ID int `json:"id"`
Name string `json:"name"`
Settings MobileDeviceSettings `json:"settings"`
Location MobileDeviceLocation `json:"location"`
}
MobileDevice contains the response to /api/v2/homes/<HomeID>/mobileDevices
func (*MobileDevice) IsHome ¶ added in v0.2.90
func (mobileDevice *MobileDevice) IsHome() (state MobileDeviceLocationState)
IsHome returns the location of the MobileDevice
func (*MobileDevice) String ¶
func (mobileDevice *MobileDevice) String() string
String serializes a MobileDevice into a string. Used for logging.
type MobileDeviceLocation ¶
MobileDeviceLocation is a sub-structure of MobileDevice
type MobileDeviceLocationState ¶ added in v0.2.90
type MobileDeviceLocationState int
MobileDeviceLocationState is the state of the user's device (mobile phone), i.e. home or away
const ( // DeviceUnknown means the device state is not initialized yet DeviceUnknown MobileDeviceLocationState = iota // DeviceHome means the user's device is home DeviceHome // DeviceAway means the user's device is not home DeviceAway )
type MobileDeviceSettings ¶
type MobileDeviceSettings struct {
GeoTrackingEnabled bool `json:"geoTrackingEnabled"`
}
MobileDeviceSettings is a sub-structure of MobileDevice
type Percentage ¶
type Percentage struct {
Percentage float64 `json:"percentage"`
}
Percentage contains a percentage (0-100%)
type Temperature ¶
type Temperature struct {
Celsius float64 `json:"celsius"`
}
Temperature contains a temperature in degrees Celsius
type WeatherInfo ¶
type WeatherInfo struct {
OutsideTemperature Temperature `json:"outsideTemperature"`
SolarIntensity Percentage `json:"solarIntensity"`
WeatherState Value `json:"weatherState"`
}
WeatherInfo contains the response to /api/v2/homes/<HomeID>/weather
This structure provides the following key information:
OutsideTemperature.Celsius: outside temperate, in degrees Celsius SolarIntensity.Percentage: solar intensity (0-100%) WeatherState.Value: string describing current weather (list TBD)
func (WeatherInfo) String ¶
func (weatherInfo WeatherInfo) String() string
String converts WeatherInfo to a loggable string
type ZoneInfo ¶
type ZoneInfo struct {
Setting ZoneInfoSetting `json:"setting"`
ActivityDataPoints ZoneInfoActivityDataPoints `json:"activityDataPoints"`
SensorDataPoints ZoneInfoSensorDataPoints `json:"sensorDataPoints"`
OpenWindow ZoneInfoOpenWindow `json:"openwindow,omitempty"`
Overlay ZoneInfoOverlay `json:"overlay,omitempty"`
}
ZoneInfo contains the response to /api/v2/homes/<HomeID>/zones/<zoneID>/state
This structure provides the following key information:
Setting.Power: power state of the specified zone (0-1) Temperature.Celsius: target temperature for the zone, in degrees Celsius OpenWindow.DurationInSeconds: how long an open window has been detected in seconds ActivityDataPoints.HeatingPower.Percentage: heating power for the zone (0-100%) SensorDataPoints.Temperature.Celsius: current temperature, in degrees Celsius SensorDataPoints.Humidity.Percentage: humidity (0-100%)
type ZoneInfoActivityDataPoints ¶
type ZoneInfoActivityDataPoints struct {
HeatingPower Percentage `json:"heatingPower"`
}
ZoneInfoActivityDataPoints contains the zone's heating info
type ZoneInfoOpenWindow ¶
type ZoneInfoOpenWindow struct {
DetectedTime time.Time `json:"detectedTime"`
DurationInSeconds int `json:"durationInSeconds"`
Expiry time.Time `json:"expiry"`
RemainingTimeInSeconds int `json:"remainingTimeInSeconds"`
}
ZoneInfoOpenWindow contains info on an open window. Only set if a window is open
type ZoneInfoOverlay ¶
type ZoneInfoOverlay struct {
Type string `json:"type"`
Setting ZoneInfoOverlaySetting `json:"setting"`
Termination ZoneInfoOverlayTermination `json:"termination"`
}
ZoneInfoOverlay contains the zone's manual settings
func (ZoneInfoOverlay) String ¶
func (overlay ZoneInfoOverlay) String() string
String serializes a ZoneInfoOverlay into a string. Used for logging.
type ZoneInfoOverlaySetting ¶
type ZoneInfoOverlaySetting struct {
Type string `json:"type"`
Power string `json:"power"`
Temperature Temperature `json:"temperature"`
}
ZoneInfoOverlaySetting contains the zone's overlay settings
func (ZoneInfoOverlaySetting) String ¶
func (setting ZoneInfoOverlaySetting) String() string
String serializes a ZoneInfoOverlaySetting into a string. Used for logging.
type ZoneInfoOverlayTermination ¶
type ZoneInfoOverlayTermination struct {
Type string `json:"type"`
RemainingTime int `json:"remainingTimeInSeconds,omitempty"`
DurationInSeconds int `json:"durationInSeconds,omitempty"`
}
ZoneInfoOverlayTermination contains the termination parameters for the zone's overlay
type ZoneInfoSensorDataPoints ¶
type ZoneInfoSensorDataPoints struct {
Temperature Temperature `json:"insideTemperature"`
Humidity Percentage `json:"humidity"`
}
ZoneInfoSensorDataPoints contains the zone's current temperature & humidity
type ZoneInfoSetting ¶
type ZoneInfoSetting struct {
Power string `json:"power"`
Temperature Temperature `json:"temperature"`
}
ZoneInfoSetting contains the zone's current power & target temperature