unofficialnest

package module
v0.0.0-...-7b576a8 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2015 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

type Credentials struct {
	Email    string
	Password string
}

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

func (device *Device) GetTimestamp() time.Time

GetTimestamp converts the device's $timestamp field into a go time.Time.

func (*Device) SetFanMode

func (device *Device) SetFanMode(fanMode string) error

SetFanMode changes the fan mode of the thermostat. Valid fanModes are 'auto' and 'on'.

func (*Device) Update

func (device *Device) Update(payload interface{}) error

Update sends an API request to change some attribute of the device. Payload is JSON.

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 {
	Timestamp int64 `json:"$timestamp"`
	Version   int   `json:"$version"`

	AutoAway int `json:"auto_away"`

	CanCool bool `json:"can_cool"`
	CanHeat bool `json:"can_heat"`

	CurrentTemperature float64 `json:"current_temperature"`
	TargetTemperature  float64 `json:"target_temperature"`

	ACState     bool `json:"hvac_ac_state"`
	CoolX2State bool `json:"hvac_cool_x2_state"`

	FanState bool `json:"hvac_fan_state"`

	AltHeatState   bool `json:"hvac_alt_heat_state"`
	AltHeatX2State bool `json:"hvac_alt_heat_x2_state"`

	EmerHeatState bool `json:"hvac_emer_heat_state"`

	HeaterState bool `json:"hvac_heater_state"`
	HeatX2State bool `json:"hvac_heat_x2_state"`
	HeatX3State bool `json:"hvac_heat_x3_state"`
	// 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 ScheduleEntry struct {
	EntryType string `json:"entry_type"`
	Type      string `json:"type"`
	Time      int    `json:"time"`
	// contains filtered or unexported fields
}

type Status

type Status struct {
	Device    map[string]Device         `json:"device"`
	Schedule  map[string]DeviceSchedule `json:"schedule"`
	Shared    map[string]DeviceShared   `json:"shared"`
	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.

func (*Structure) SetAway

func (structure *Structure) SetAway(away bool) error

SetAway sets the away status of the structure -- true for away, false for home.

func (*Structure) Update

func (structure *Structure) Update(payload interface{}) error

Update sends an API request to change some attribute of the structure. Payload is JSON.

type StructureWhere

type StructureWhere struct {
	Timestamp int64   `json:"$timestamp"`
	Version   int     `json:"$version"`
	Wheres    []Where `json:"wheres"`
	WhereMap  map[string]*Where
}

type Where

type Where struct {
	Name    string `json:"name"`
	WhereID string `json:"where_id"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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