Documentation
¶
Index ¶
- func GetEndPointsURI(client *http.Client) (string, error)
- func GetToken(tokenFile string, config *oauth2.Config) (*oauth2.Token, error)
- func LoadToken(fname string) (*oauth2.Token, error)
- func NewOAuthConfig(client, secret string) *oauth2.Config
- func SaveToken(fname string, token *oauth2.Token) error
- type Auth
- type DeviceCommand
- type DeviceInfo
- type DeviceList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEndPointsURI ¶
GetEndPointsURI returns the smartthing endpoints URI. The endpoints URI is the base for all app requests.
func GetToken ¶
GetToken returns the token for the ClientID and Secret specified in config. The function attempts to load the token from tokenFile first, and failing that, starts a full token authentication cycle with SmartThings. If tokenFile is blank, the function uses a default name under the current user's home directory. The token is saved to local disk before being returned to the caller.
This function represents the most common (and possibly convenient) way to retrieve a token for a given ClientID and Secret.
func LoadToken ¶
LoadToken loads the token from a file on disk. If nil is used for filename a default filename user the user's directory is used.
func NewOAuthConfig ¶
NewOAuthConfig creates a new oauth2.config structure with the correct parameters to use smartthings.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth contains the SmartThings authentication related data.
type DeviceCommand ¶
type DeviceCommand struct {
Command string `json:"command"`
Params map[string]interface{} `json:"params"`
}
DeviceCommand holds one command a device can accept.
func GetDeviceCommands ¶
GetDeviceCommands returns a slice of commands a specific device accepts.
type DeviceInfo ¶
type DeviceInfo struct {
DeviceList
Attributes map[string]interface{} `json:"attributes"`
}
DeviceInfo holds information about a specific device.
func GetDeviceInfo ¶
GetDeviceInfo returns device specific information about a particular device.
type DeviceList ¶
type DeviceList struct {
ID string `json:"id"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
}
DeviceList holds the list of devices returned by /devices
func GetDevices ¶
func GetDevices(client *http.Client, endpoint string) ([]DeviceList, error)
GetDevices returns the list of devices from smartthings using the specified http.client and endpoint URI.