Documentation
¶
Overview ¶
unoficialnest provides an interface to the "unofficial" Nest Labs API for thermostats and Nest Protect devices. Although Nest provides an official API through their developer program, there is information that isn't exposed through the official API, including whether the heating or cooling are actually on. The unofficial API is the endpoint used by Nest's own web and mobile apps to interact with the servers; this code impersonates a mobile device to get information and change settings for Nest devices.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
Credentials is the information needed to log into the Nest app or website. Email address (aka username) and password.
type Device ¶
type Device struct {
Timestamp int64 `json:"$timestamp"`
Version int `json:"$version"`
SerialNumber string `json:"serial_number"`
BatteryLevel float64 `json:"battery_level"`
CurrentHumidity float64 `json:"current_humidity"`
ErrorCode string `json:"error_code"`
FanMode string `json:"fan_mode"`
HasAltHeat bool `json:"has_alt_heat"`
HasEmerHeat bool `json:"has_emer_heat"`
HasFan bool `json:"has_fan"`
Leaf bool `json:"leaf"`
RSSI float64 `json:"rssi"`
WhereID string `json:"where_id"`
// contains filtered or unexported fields
}
Device contains information about a Nest device (Thermostat or Protect). If you can't find what you're looking for in here, it's probably in DeviceShared instead; find it by looking in status.Shared with this device's SerialNumber.
func (*Device) GetTimestamp ¶
GetTimestamp converts the device's $timestamp field into a go time.Time.
func (*Device) SetFanMode ¶
SetFanMode changes the fan mode of the thermostat. Valid fanModes are 'auto' and 'on'.
type DeviceSchedule ¶
type DeviceSchedule struct {
TimeStamp int64 `json:"$timestamp"`
Version int `json:"$version"`
Days map[string]ScheduleDay
// contains filtered or unexported fields
}
type DeviceShared ¶
type DeviceShared struct {
// contains filtered or unexported fields
}
DeviceShared contains information about the state of a Nest device (Thermostat or Protect), including the temperature and whether it is heating, cooling, blowing the fan, etc.
func (*DeviceShared) SetTargetTemperature ¶
func (shared *DeviceShared) SetTargetTemperature(tempC float64) error
SetTargetTemperature changes the target temperature of the thermostat. tempC is in degrees Celsius.
func (*DeviceShared) Update ¶
func (shared *DeviceShared) Update(payload interface{}) error
Update sends an API request to change some attribute of the device shared structure. Payload is JSON.
type NestSession ¶
type NestSession struct {
Credentials
// contains filtered or unexported fields
}
NestSession is the main point of interaction with the API. It is created with a set of Credentials and contains state used for interacting with the service.
func NewSession ¶
func NewSession(creds Credentials) *NestSession
NewSession creates a NestSession from a set of Credentials.
func (*NestSession) GetStatus ¶
func (nest *NestSession) GetStatus() (status Status, err error)
GetStatus gets a Status from the Nest API and returns it.
func (*NestSession) GetStatusRaw ¶
func (nest *NestSession) GetStatusRaw() (interface{}, error)
type ScheduleDay ¶
type ScheduleDay map[string]ScheduleEntry
type ScheduleEntry ¶
type Status ¶
type Status struct {
Device map[string]Device `json:"device"`
Schedule map[string]DeviceSchedule `json:"schedule"`
Structure map[string]Structure `json:"structure"`
Where map[string]StructureWhere `json:"where"`
// contains filtered or unexported fields
}
Status contains a report about the devices, structures, and users associated with an account.
type Structure ¶
type Structure struct {
Timestamp int64 `json:"$timestamp"`
Version int `json:"$version"`
Away bool `json:"away"`
Devices []string `json:"devices"`
// contains filtered or unexported fields
}
Structure is the building containing one or more Nest devices. It contains information about the building itself, and the devices within it.