Documentation ¶
Index ¶
- Constants
- type APIError
- type Access
- type Client
- func (c *Client) Authorize() *APIError
- func (c *Client) Devices() (*Devices, *APIError)
- func (c *Client) DevicesStream(callback func(devices *Devices, err error))
- func (c *Client) Structures() (map[string]*Structure, *APIError)
- func (c *Client) StructuresStream(callback func(structures map[string]*Structure, err error))
- type Combined
- type Devices
- type DevicesEvent
- type ETA
- type SmokeCoAlarm
- type Structure
- type StructuresEvent
- type Tempratures
- type Thermostat
- func (t *Thermostat) SetFanTimerActive(setting bool) *APIError
- func (t *Thermostat) SetHvacMode(mode int) *APIError
- func (t *Thermostat) SetTargetTempC(temp float32) *APIError
- func (t *Thermostat) SetTargetTempF(temp int) *APIError
- func (t *Thermostat) SetTargetTempHighLowC(high float32, low float32) *APIError
- func (t *Thermostat) SetTargetTempHighLowF(high int, low int) *APIError
Constants ¶
const ( // Version is the version of the library Version = "0.0.1" // APIURL is the main URL for the API APIURL = "https://developer-api.nest.com" // AccessTokenURL is the Next API URL to get an access_token AccessTokenURL = "https://api.home.nest.com/oauth2/access_token" // NoStream indicates wedo not want to stream on a GET for server side events NoStream = iota //Stream indicates we want to stream on a GET for server side events Stream // Cool sets HvacMode to "cool" Cool // Heat sets HvacMode to "heat" Heat // HeatCool sets HvacMode to "heat-cool" HeatCool // Off sets HvacMode to "off" Off // Home sets Away mode to "home" Home // Away sets Away mode to "away" Away // AutoAway sets Away mode to "auto-away" AutoAway )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct { Error string `json:"error,omitempty"` Description string `json:"error_description,omitempty"` Status string StatusCode int }
APIError represents an error object from the Nest API
type Access ¶
type Access struct { Token string `json:"access_token,omitempty"` ExpiresIn int `json:"expires_in,omitempty"` }
Access represents a Nest access token object
type Client ¶
type Client struct { ID string State string AuthorizationCode string Secret string Token string ExpiresIn int AccessTokenURL string APIURL string RedirectURL string }
Client represents a client object
func (*Client) Authorize ¶
Authorize fetches and sets the Nest API token https://developer.nest.com/documentation/how-to-auth
client.Authorize()
func (*Client) DevicesStream ¶
DevicesStream emits events from the Nest devices REST streaming API
client.DevicesStream(func(event *Devices) { fmt.Println(event) })
func (*Client) Structures ¶
Structures returns a map of structures https://developer.nest.com/documentation/api#structures
structures := client.Structures()
type Combined ¶
type Combined struct { Devices *Devices `json:"devices,omitempty"` Structures map[string]*Structure `json:"structures,omitempty"` }
Combined represents an object for the entire API including devices and structures
type Devices ¶
type Devices struct { Thermostats map[string]*Thermostat `json:"thermostats,omitempty"` SmokeCoAlarms map[string]*SmokeCoAlarm `json:"smoke_co_alarms,omitempty"` }
Devices represents devices that include thermostats and smokecoalarms
type DevicesEvent ¶
type DevicesEvent struct { Path string `json:"path,omitempty"` Data *Devices `json:"data,omitempty"` }
DevicesEvent represents an object returned by the REST streaming API
type ETA ¶
type ETA struct { TripID string `json:"trip_id,omitempty"` EstimatedArrivalWindowBegin time.Time `json:"estimated_arrival_window_begin,omitempty"` EstimatedArrivalWindowEnd time.Time `json:"estimated_arrival_window_end,omitempty"` }
Eta represents an eta object (estimated time of a arrival for a structure)
type SmokeCoAlarm ¶
type SmokeCoAlarm struct { DeviceID string `json:"device_id,omitempty"` Locale string `json:"locale,omitempty"` SoftwareVersion string `json:"software_version,omitempty"` StructureID string `json:"structure_id,omitempty"` Name string `json:"name,omitempty"` NameLong string `json:"name_long,omitempty"` LastConnection time.Time `json:"last_connection,omitempty"` IsOnline bool `json:"is_online,omitempty"` BatteryHealth string `json:"battery_health,omitempty"` CoAlarmState string `json:"co_alarm_state,omitempty"` SmokeAlarmState string `json:"smoke_alarm_state,omitempty"` UIColorState string `json:"ui_color_state,omitempty"` Client *Client }
SmokeCoAlarm represents a Nest smokecoalarm object (Smoke & CO2 alarm) https://developer.nest.com/documentation/api#smoke_co_alarms https://developer.nest.com/documentation/how-to-smoke-co-alarms-object
type Structure ¶
type Structure struct { StructureID string `json:"structure_id,omitempty"` Thermostats []string `json:"thermostats,omitempty"` SmokeCoAlarms []string `json:"smoke_co_alarms,omitempty"` Away string `json:"away,omitempty"` Name string `json:"name,omitempty"` CountryCode string `json:"country_code,omitempty"` PeakPeriodStartTime time.Time `json:"peak_period_start_time,omitempty"` PeakPeriodEndTime time.Time `json:"peak_period_end_time,omitempty"` TimeZone string `json:"time_zone,omitempty"` ETA *ETA `json:"eta,omitempty"` Client *Client }
Structure represents a Next structure object https://developer.nest.com/documentation/api#structures https://developer.nest.com/documentation/how-to-structures-object
func (*Structure) SetAway ¶
SetAway sets the away status of a structure https://developer.nest.com/documentation/api#away
s.SetAway(nest.Away)
type StructuresEvent ¶
type StructuresEvent struct { Path string `json:"path,omitempty"` Data map[string]*Structure `json:"data,omitempty"` }
StructuresEvent represents an object returned by the REST streaming API
type Tempratures ¶
type Tempratures struct { TargetTemperatureF int `json:"target_temperature_f,omitempty"` TargetTemperatureC float32 `json:"target_temperature_c,omitempty"` TargetTemperatureHighF int `json:"target_temperature_high_f,omitempty"` TargetTemperatureHighC float32 `json:"target_temperature_high_c,omitempty"` TargetTemperatureLowF int `json:"target_temperature_low_f,omitempty"` TargetTemperatureLowC float32 `json:"target_temperature_low_c,omitempty"` }
Tempratures represents all of the possible temprature settings for a Nest thermostat
type Thermostat ¶
type Thermostat struct { DeviceID string `json:"device_id,omitempty"` Locale string `json:"locale,omitempty"` SoftwareVersion string `json:"software_version,omitempty"` StructureID string `json:"structure_id,omitempty"` Name string `json:"name,omitempty"` NameLong string `json:"name_long,omitempty"` LastConnection time.Time `json:"last_connection,omitempty"` IsOnline bool `json:"is_online,omitempty"` CanCool bool `json:"can_cool,omitempty"` CanHeat bool `json:"can_heat,omitempty"` IsUsingEmergencyHeat bool `json:"is_using_emergency_heat,omitempty"` HasFan bool `json:"has_fan,omitempty"` FanTimerActive bool `json:"fan_timer_active,omitempty"` FanTimerTimeout time.Time `json:"fan_timer_timeout,omitempty"` HasLeaf bool `json:"has_leaf,omitempty"` TemperatureScale string `json:"temperature_scale,omitempty"` TargetTemperatureF int `json:"target_temperature_f,omitempty"` TargetTemperatureC float32 `json:"target_temperature_c,omitempty"` TargetTemperatureHighF int `json:"target_temperature_high_f,omitempty"` TargetTemperatureHighC float32 `json:"target_temperature_high_c,omitempty"` TargetTemperatureLowF int `json:"target_temperature_low_f,omitempty"` TargetTemperatureLowC float32 `json:"target_temperature_low_c,omitempty"` AwayTemperatureHighF int `json:"away_temperature_high_f,omitempty"` AwayTemperatureHighC float32 `json:"away_temperature_high_c,omitempty"` AwayTemperatureLowF int `json:"away_temperature_low_f,omitempty"` AwayTemperatureLowC float32 `json:"away_temperature_low_c,omitempty"` HvacMode string `json:"hvac_mode,omitempty"` AmbientTemperatureF int `json:"ambient_temperature_f,omitempty"` AmbientTemperatureC float32 `json:"ambient_temperature_c,omitempty"` Humidity int `json:"humidity,omitempty"` HvacState string `json:"hvac_state,omitempty"` WhereID string `json:"where_id,omitempty"` Client *Client }
Thermostat represents a Nest thermostat object https://developer.nest.com/documentation/api#thermostats https://developer.nest.com/documentation/how-to-thermostats-object
func (*Thermostat) SetFanTimerActive ¶
func (t *Thermostat) SetFanTimerActive(setting bool) *APIError
SetFanTimerActive sets the fan timer on or off https://developer.nest.com/documentation/api#fan_timer_active
t.SetFanTimerActive(true)
func (*Thermostat) SetHvacMode ¶
func (t *Thermostat) SetHvacMode(mode int) *APIError
SetHvacMode sets the HvacMode when a thermostat may heat and cool https://developer.nest.com/documentation/api#hvac_mode
t.SetHvacMode(Cool)
func (*Thermostat) SetTargetTempC ¶
func (t *Thermostat) SetTargetTempC(temp float32) *APIError
SetTargetTempC sets the thermostat to an intended temp in celcius https://developer.nest.com/documentation/api#target_temperature_c
t.SetTargetTempC(28.5)
func (*Thermostat) SetTargetTempF ¶
func (t *Thermostat) SetTargetTempF(temp int) *APIError
SetTargetTempF sets the thermostat to an intended temp in farenheit https://developer.nest.com/documentation/api#target_temperature_f
t.SetTargetTempF(78)
func (*Thermostat) SetTargetTempHighLowC ¶
func (t *Thermostat) SetTargetTempHighLowC(high float32, low float32) *APIError
SetTargetTempHighLowC sets the high target temp in celcius when HvacMode is HeatCool https://developer.nest.com/documentation/api#target_temperature_high_c https://developer.nest.com/documentation/api#target_temperature_low_c
t.SetTargetTempHighLowF(75, 65)
func (*Thermostat) SetTargetTempHighLowF ¶
func (t *Thermostat) SetTargetTempHighLowF(high int, low int) *APIError
SetTargetTempHighLowF sets the high target temp in farenheit when HvacMode is HeatCool https://developer.nest.com/documentation/api#target_temperature_high_f https://developer.nest.com/documentation/api#target_temperature_low_f
t.SetTargetTempHighLowF(75, 65)