ecobee

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 13 Imported by: 0

README

Go Report Card Godoc Release

Go client for the ecobee API

Currently, does not support any requests that are accessible by EMS or Utility accounts only. If you strongly feel the client needs to support these requests please log an enhancement request, and I'll consider it.

The below example illustrates how to:

  • Fetch a persisted OAuth2 token from a file in JSON format if one exists.
  • Authorize an app and create the OAuth2 token using the ecobee PIN authorization method if no persisted OAuth2 token is found.
  • Create an http.Client using the OAuth2 token. The Client will auto-refresh the token as necessary.
  • Create an ecobee.Client.
  • Retrieve a selection of thermostat data for one or more thermostats.
  • Retrieve the OAuth2 token from the ecobee.Client (In case it was auto-refreshed).
  • Persist the OAuth2 token to a file in JSON format
package main

import (
	"bufio"
	"context"
	"encoding/json"
	"flag"
	"fmt"
	"io/ioutil"
	"os"
	"time"

	"golang.org/x/oauth2"

	"github.com/sherif-fanous/go-ecobee"
	"github.com/sherif-fanous/go-ecobee/objects"
)

var applicationKey string
var filename string
var oauth2Endpoint = oauth2.Endpoint{
	AuthURL:  "https://api.ecobee.com/authorize",
	TokenURL: "https://api.ecobee.com/token",
}

func persistToken(oauth2Token *oauth2.Token) error {
	b, err := json.MarshalIndent(oauth2Token, "", " ")
	if err != nil {
		return err
	}

	if err := ioutil.WriteFile(filename, b, 0644); err != nil {
		return err
	}

	return nil
}

func fetchToken() (*oauth2.Token, error) {
	b, err := ioutil.ReadFile(filename)
	if err != nil {
		if os.IsNotExist(err) {
			return nil, nil
		}

		return nil, err
	}

	oauth2Token := oauth2.Token{}

	if err := json.Unmarshal(b, &oauth2Token); err != nil {
		return nil, err
	}

	return &oauth2Token, nil
}

func main() {
	flag.StringVar(&applicationKey, "key", "", "ecobee Application Key")
	flag.StringVar(&filename, "file", "", "token persistent store path")
	flag.Parse()

	oauth2Token, err := fetchToken()
	if err != nil {
		fmt.Println(err)

		return
	}

	if oauth2Token == nil {
		client := ecobee.NewClient()

		ctx := context.Background()
		ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
		defer cancel()

		fmt.Println("PINAuthorization...Step #1")
		fmt.Println()

		authorizeResponse, err := client.PINAuthorization(ctx, applicationKey, ecobee.ScopeSmartWrite)
		if err != nil {
			fmt.Println(err)

			return
		}

		fmt.Printf("AuthorizeResponse %s\n", authorizeResponse)
		fmt.Println()

		fmt.Printf("Please goto ecobee.com, login to the web portal and click on the settings tab. "+
			"Ensure the My Apps widget is enabled. If it is not click on the My Apps option in the menu on the left. "+
			"In the My Apps widget paste '%s' in the textbox labelled 'Enter your 4 digit pin to install your third party app' "+
			"and then click 'Install App'. The next screen will display any permissions the app requires and will ask you to click "+
			"'Authorize' to add the application.\n\nAfter completing this step please hit 'Enter' to continue", authorizeResponse.PIN())

		input := bufio.NewScanner(os.Stdin)
		input.Scan()

		fmt.Println()
		fmt.Println("PINAuthorization...Step #2")
		fmt.Println()

		nowUTC := time.Now().UTC()

		ctx = context.Background()
		ctx, cancel = context.WithTimeout(ctx, 5*time.Second)
		defer cancel()

		tokensResponse, err := client.RequestTokens(ctx, applicationKey, authorizeResponse.AuthorizationToken())
		if err != nil {
			fmt.Println(err)

			return
		}

		fmt.Printf("TokensResponse %s\n", tokensResponse)

		oauth2Token = &oauth2.Token{
			TokenType:    tokensResponse.TokenType(),
			AccessToken:  tokensResponse.AccessToken(),
			Expiry:       nowUTC.Add(time.Second * time.Duration(tokensResponse.ExpiresIn())),
			RefreshToken: tokensResponse.RefreshToken(),
		}
	}

	oauth2Config := &oauth2.Config{
		ClientID: applicationKey,
		Endpoint: oauth2Endpoint,
	}

	client := ecobee.NewClient(ecobee.WithHTTPClient(oauth2Config.Client(context.Background(), oauth2Token)))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	selection := objects.Selection{
		SelectionType:   ecobee.String("registered"),
		SelectionMatch:  ecobee.String(""),
		IncludeSettings: ecobee.Bool(true),
	}

	thermostatResponse, err := client.Thermostat(ctx, &selection, nil)
	if err != nil {
		fmt.Println(err)

		return
	}

	fmt.Printf("ThermostatResponse %s\n", thermostatResponse)

	// Get the updated token
	oauth2Token = client.OAuth2Token()

	if err := persistToken(oauth2Token); err != nil {
		fmt.Println(err)

		return
	}
}

Full documentation is available on GoDoc.

Documentation

Overview

Package ecobee provides a Go client for the ecobee API.

For more information about the ecobee API, see the documentation: https://www.ecobee.com/home/developer/api/introduction/index.shtml

Authentication

By design, the ecobee Client accepts any http.Client so OAuth2 requests can be made by using the appropriate authenticated client. Use the https://github.com/golang/oauth2 package to obtain an http.Client which transparently authorizes requests.

Usage

You use the library by creating a Client and invoking its methods. The client can be created manually with NewClient.

The below example illustrates how to:

- Fetch a persisted OAuth2 token from a file in JSON format if one exists.

- Authorize an app and create the OAuth2 token using the ecobee PIN authorization method if no persisted OAuth2 token is found.

- Create an http.Client using the OAuth2 token. The Client will auto-refresh the token as necessary.

- Create an ecobee.Client.

- Retrieve a selection of thermostat data for one or more thermostats.

- Retrieve the OAuth2 token from the ecobee.Client (In case it was auto-refreshed).

- Persist the OAuth2 token to a file in JSON format

package main

import (
	"bufio"
	"context"
	"encoding/json"
	"flag"
	"fmt"
	"io/ioutil"
	"os"
	"time"

	"golang.org/x/oauth2"

	"github.com/sherif-fanous/go-ecobee"
	"github.com/sherif-fanous/go-ecobee/objects"
)

var applicationKey string
var filename string
var oauth2Endpoint = oauth2.Endpoint{
	AuthURL:  "https://api.ecobee.com/authorize",
	TokenURL: "https://api.ecobee.com/token",
}

func persistToken(oauth2Token *oauth2.Token) error {
	b, err := json.MarshalIndent(oauth2Token, "", " ")
	if err != nil {
		return err
	}

	if err := ioutil.WriteFile(filename, b, 0644); err != nil {
		return err
	}

	return nil
}

func fetchToken() (*oauth2.Token, error) {
	b, err := ioutil.ReadFile(filename)
	if err != nil {
		if os.IsNotExist(err) {
			return nil, nil
		}

		return nil, err
	}

	oauth2Token := oauth2.Token{}

	if err := json.Unmarshal(b, &oauth2Token); err != nil {
		return nil, err
	}

	return &oauth2Token, nil
}

func main() {
	flag.StringVar(&applicationKey, "key", "", "ecobee Application Key")
	flag.StringVar(&filename, "file", "", "token persistent store path")
	flag.Parse()

	oauth2Token, err := fetchToken()
	if err != nil {
		fmt.Println(err)

		return
	}

	if oauth2Token == nil {
		client := ecobee.NewClient()

		ctx := context.Background()
		ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
		defer cancel()

		fmt.Println("PINAuthorization...Step #1")
		fmt.Println()

		authorizeResponse, err := client.PINAuthorization(ctx, applicationKey, ecobee.ScopeSmartWrite)
		if err != nil {
			fmt.Println(err)

			return
		}

		fmt.Printf("AuthorizeResponse %s\n", authorizeResponse)
		fmt.Println()

		fmt.Printf("Please goto ecobee.com, login to the web portal and click on the settings tab. "+
			"Ensure the My Apps widget is enabled. If it is not click on the My Apps option in the menu on the left. "+
			"In the My Apps widget paste '%s' in the textbox labelled 'Enter your 4 digit pin to install your third party app' "+
			"and then click 'Install App'. The next screen will display any permissions the app requires and will ask you to click "+
			"'Authorize' to add the application.\n\nAfter completing this step please hit 'Enter' to continue", authorizeResponse.PIN())

		input := bufio.NewScanner(os.Stdin)
		input.Scan()

		fmt.Println()
		fmt.Println("PINAuthorization...Step #2")
		fmt.Println()

		nowUTC := time.Now().UTC()

		ctx = context.Background()
		ctx, cancel = context.WithTimeout(ctx, 5*time.Second)
		defer cancel()

		tokensResponse, err := client.RequestTokens(ctx, applicationKey, authorizeResponse.AuthorizationToken())
		if err != nil {
			fmt.Println(err)

			return
		}

		fmt.Printf("TokensResponse %s\n", tokensResponse)

		oauth2Token = &oauth2.Token{
			TokenType:    tokensResponse.TokenType(),
			AccessToken:  tokensResponse.AccessToken(),
			Expiry:       nowUTC.Add(time.Second * time.Duration(tokensResponse.ExpiresIn())),
			RefreshToken: tokensResponse.RefreshToken(),
		}
	}

	oauth2Config := &oauth2.Config{
		ClientID: applicationKey,
		Endpoint: oauth2Endpoint,
	}

	client := ecobee.NewClient(ecobee.WithHTTPClient(oauth2Config.Client(context.Background(), oauth2Token)))

	ctx := context.Background()
	ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
	defer cancel()

	selection := objects.Selection{
		SelectionType:   ecobee.String("registered"),
		SelectionMatch:  ecobee.String(""),
		IncludeSettings: ecobee.Bool(true),
	}

	thermostatResponse, err := client.Thermostat(ctx, &selection, nil)
	if err != nil {
		fmt.Println(err)

		return
	}

	fmt.Printf("ThermostatResponse %s\n", thermostatResponse)

	// Get the updated token
	oauth2Token = client.OAuth2Token()

	if err := persistToken(oauth2Token); err != nil {
		fmt.Println(err)

		return
	}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) *bool

Bool is a helper function that returns a pointer to a bool value

func Int

func Int(i int) *int

Int is a helper function that returns a pointer to an int value

func String

func String(s string) *string

String is a helper function that returns a pointer to a string value

func WithAPIBaseURL

func WithAPIBaseURL(apiBaseURL string) func(*Client)

WithAPIBaseURL returns a function that initializes a Client with an API base URL.

func WithAPIVersion

func WithAPIVersion(apiVersion int) func(*Client)

WithAPIVersion returns a function that initializes a Client with an API version.

func WithCustomHTTPHeaders

func WithCustomHTTPHeaders(customHTTPHeaders map[string]string) func(*Client)

WithCustomHTTPHeaders returns a function that initializes a Client with custom HTTP headers.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) func(*Client)

WithHTTPClient returns a function that initializes a Client with an HTTP client.

Types

type APIError

type APIError struct {
	// contains filtered or unexported fields
}

APIError describes errors returned by the ecobee server while making requests

func (*APIError) Error

func (e *APIError) Error() string

Error returns the string representation of an APIError.

type APIStatusResponse

type APIStatusResponse struct {
	// contains filtered or unexported fields
}

APIStatusResponse describes responses returned by the ecobee server that only contain the Status object

func (*APIStatusResponse) Status

func (a *APIStatusResponse) Status() *objects.Status

Status returns the response's status.

func (*APIStatusResponse) String

func (a *APIStatusResponse) String() string

String implements the fmt.Stringer interface. It returns a string representing an indented JSON encoding of the response.

func (*APIStatusResponse) UnmarshalJSON

func (a *APIStatusResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type AckType

type AckType string

An AckType specifies an acknowledgment type.

const (
	AckTypeAccept         AckType = "accept"
	AckTypeDecline        AckType = "decline"
	AckTypeDefer          AckType = "defer"
	AckTypeUnacknowledged AckType = "unacknowledged"
)

Supported AckType values.

type AcknowledgeParameters

type AcknowledgeParameters struct {
	// The thermostat identifier to acknowledge the alert for.
	ThermostatIdentifier *string
	// The acknowledge ref of alert.
	AckRef *string
	// The type of acknowledgement.
	AckType *AckType
	// Whether to remind at a later date, if this is a defer acknowledgement.
	RemindMeLater *bool
}

An AcknowledgeParameters specifies the request parameters of the Acknowledge method.

type AuthorizationError

type AuthorizationError struct {
	// contains filtered or unexported fields
}

AuthorizationError describes errors returned by the ecobee server while authorizing

func (*AuthorizationError) Error

func (e *AuthorizationError) Error() string

Error returns the string representation of an AuthorizationError.

type AuthorizationErrorResponse

type AuthorizationErrorResponse struct {
	// contains filtered or unexported fields
}

AuthorizationErrorResponse describes the error response returned by the ecobee server while authorizing.

func (*AuthorizationErrorResponse) ErrorDescription

func (e *AuthorizationErrorResponse) ErrorDescription() string

ErrorDescription returns the response's error description.

func (*AuthorizationErrorResponse) ErrorType

func (e *AuthorizationErrorResponse) ErrorType() string

ErrorType returns the response's error type.

func (*AuthorizationErrorResponse) ErrorURI

func (e *AuthorizationErrorResponse) ErrorURI() string

ErrorURI returns the response's error URI.

func (*AuthorizationErrorResponse) UnmarshalJSON

func (e *AuthorizationErrorResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client is an ecobee API client. Its zero value is not a usable ecobee client.

func NewClient

func NewClient(optionalParameters ...clientOptionalParameters) *Client

NewClient initializes a new API client with default values. It takes functors to modify values when creating it

func (*Client) APIBaseURL

func (c *Client) APIBaseURL() string

APIBaseURL returns the client's API base URL.

func (*Client) APIVersion

func (c *Client) APIVersion() int

APIVersion returns the client's API version.

func (*Client) Acknowledge

func (c *Client) Acknowledge(ctx context.Context, selection *objects.Selection, parameters *AcknowledgeParameters) (*APIStatusResponse, error)

Acknowledge allows an Alert to be acknowledged.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/Acknowledge.shtml

func (*Client) ControlPlug

func (c *Client) ControlPlug(ctx context.Context, selection *objects.Selection, parameters *ControlPlugParameters) (*APIStatusResponse, error)

ControlPlug sets the on/off state of a plug by setting a hold on the plug.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/ControlPlug.shtml

func (*Client) CreateVacation

func (c *Client) CreateVacation(ctx context.Context, selection *objects.Selection, parameters *CreateVacationParameters) (*APIStatusResponse, error)

CreateVacation creates a vacation event on the thermostat.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/CreateVacation.shtml

func (*Client) CustomHTTPHeaders

func (c *Client) CustomHTTPHeaders() map[string]string

CustomHTTPHeaders returns the client's custom HTTP headers.

func (*Client) DeleteVacation

func (c *Client) DeleteVacation(ctx context.Context, selection *objects.Selection, parameters *DeleteVacationParameters) (*APIStatusResponse, error)

DeleteVacation deletes a vacation event from a thermostat.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/DeleteVacation.shtml

func (*Client) Group

func (c *Client) Group(ctx context.Context, selection *objects.Selection) (*GroupSuccessResponse, error)

Group retrieves the grouping data for the thermostats registered to the particular user.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/operations/get-group.shtml

func (*Client) MeterReport

func (c *Client) MeterReport(ctx context.Context, selection *objects.Selection, parameters *MeterReportParameters) (*MeterReportSuccessResponse, error)

MeterReport retrieves the historical meter reading information for a selection of thermostats.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/operations/get-meter-report.shtml

func (*Client) OAuth2Token

func (c *Client) OAuth2Token() *oauth2.Token

OAuth2Token returns the client's OAuth2 token.

func (*Client) PINAuthorization

func (c *Client) PINAuthorization(ctx context.Context, applicationKey string, scope Scope) (*PINAuthorizationSuccessResponse, error)

PINAuthorization requests an authorization code and a PIN to enable the authorization of an application within the ecobee Web Portal.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/auth/pin-api-authorization.shtml

func (*Client) RequestTokens

func (c *Client) RequestTokens(ctx context.Context, applicationKey string, authorizationToken string) (*TokensSuccessResponse, error)

RequestTokens requests access and refresh tokens once the application is authorized within the ecobee Web Portal.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/auth/pin-api-authorization.shtml

func (*Client) ResetPreferences

func (c *Client) ResetPreferences(ctx context.Context, selection *objects.Selection) (*APIStatusResponse, error)

ResetPreferences sets all of the user configurable settings back to the factory default values.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/ResetPreferences.shtml

func (*Client) ResumeProgram

func (c *Client) ResumeProgram(ctx context.Context, selection *objects.Selection, parameters *ResumeProgramParameters) (*APIStatusResponse, error)

ResumeProgram removes the currently running event providing the event is not a mandatory demand response event.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/ResumeProgram.shtml

func (*Client) RuntimeReport

func (c *Client) RuntimeReport(ctx context.Context, selection *objects.Selection, parameters *RuntimeReportParameters) (*RuntimeReportSuccessResponse, error)

RuntimeReport retrieves the historical runtime report information for a selection of thermostats.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/operations/get-runtime-report.shtml

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, selection *objects.Selection, parameters *SendMessageParameters) (*APIStatusResponse, error)

SendMessage allows an alert message to be sent to the thermostat.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/SendMessage.shtml

func (*Client) SetHold

func (c *Client) SetHold(ctx context.Context, selection *objects.Selection, parameters *SetHoldParameters) (*APIStatusResponse, error)

SetHold sets the thermostat into a hold with the specified temperature.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/SetHold.shtml

func (*Client) String

func (c *Client) String() string

String returns a string representing an indented JSON encoding of the client.

func (*Client) Thermostat

func (c *Client) Thermostat(ctx context.Context, selection *objects.Selection, page *objects.Page) (*ThermostatSuccessResponse, error)

Thermostat retrieves a selection of thermostat data for one or more thermostats.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/operations/get-thermostats.shtml

func (*Client) ThermostatSummary

func (c *Client) ThermostatSummary(ctx context.Context, selection *objects.Selection) (*ThermostatSummarySuccessResponse, error)

ThermostatSummary retrieves a list of thermostat configuration and state revisions.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/operations/get-thermostat-summary.shtml

func (*Client) UnlinkVoiceEngine

func (c *Client) UnlinkVoiceEngine(ctx context.Context, selection *objects.Selection, parameters *UnlinkVoiceEngineParameters) (*APIStatusResponse, error)

UnlinkVoiceEngine disables the voice assistant for the selected thermostat.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/UnlinkVoiceEngine.shtml

func (*Client) UpdateGroup

func (c *Client) UpdateGroup(ctx context.Context, selection *objects.Selection, groups []objects.Group) (*GroupSuccessResponse, error)

UpdateGroup updates the grouping data for the thermostats registered to the particular user.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/operations/post-group-update.shtml

func (*Client) UpdateSensor

func (c *Client) UpdateSensor(ctx context.Context, selection *objects.Selection, parameters *UpdateSensorParameters) (*APIStatusResponse, error)

UpdateSensor allows the caller to update the name of a remote sensor.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/functions/UpdateSensor.shtml

func (*Client) UpdateThermostat

func (c *Client) UpdateThermostat(ctx context.Context, selection *objects.Selection, thermostat *objects.Thermostat, functions []objects.Function) (*APIStatusResponse, error)

UpdateThermostat permits the modification of any writable thermostat or sub-object property.

For more information see: https://www.ecobee.com/home/developer/api/documentation/v1/operations/post-update-thermostats.shtml

type ControlPlugParameters

type ControlPlugParameters struct {
	// The name of the plug.
	PlugName *string
	// The state to put the plug into.
	PlugState *PlugState
	// The start date & time in thermostat time.
	StartDateTime *time.Time
	// The end date & time in thermostat time.
	EndDateTime *time.Time
	// The hold duration type.
	HoldType *HoldType
	// The number of hours to hold for.
	HoldHours *int
}

A ControlPlugParameters specifies the request parameters of the ControlPlug method.

type CreateVacationParameters

type CreateVacationParameters struct {
	// The vacation name to create.
	Name *string
	// The temperature to set the cool vacation hold at.
	CoolHoldTemp *int
	// The temperature to set the heat vacation hold at.
	HeatHoldTemp *int
	// The start date & time in thermostat time.
	StartDateTime *time.Time
	// The end date & time in thermostat time.
	EndDateTime *time.Time
	// The fan mode during the vacation.
	Fan *FanMode
	// The minimum number of minutes to run the fan each hour.
	FanMinOnTime *string
}

A CreateVacationParameters specifies the request parameters of the CreateVacation method.

type DeleteVacationParameters

type DeleteVacationParameters struct {
	// The vacation name to delete.
	Name *string
}

A DeleteVacationParameters specifies the request parameters of the DeleteVacation method.

type FanMode

type FanMode string

A FanMode specifies a fan mode.

const (
	FanModeAuto FanMode = "auto"
	FanModeOn   FanMode = "on"
)

Supported FanMode values.

type GroupSuccessResponse

type GroupSuccessResponse struct {
	// contains filtered or unexported fields
}

GroupSuccessResponse describes the response returned by the ecobee server while retrieving or updating groups.

func (*GroupSuccessResponse) Groups

func (g *GroupSuccessResponse) Groups() []objects.Group

Groups returns the response's groups.

func (*GroupSuccessResponse) Status

func (g *GroupSuccessResponse) Status() *objects.Status

Status returns the response's status.

func (*GroupSuccessResponse) String

func (g *GroupSuccessResponse) String() string

String implements the fmt.Stringer interface. It returns a string representing an indented JSON encoding of the response.

func (*GroupSuccessResponse) UnmarshalJSON

func (g *GroupSuccessResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type HoldType

type HoldType string

A HoldType specifies a hold type.

const (
	HoldTypeDateTime       HoldType = "dateTime"
	HoldTypeHoldHours      HoldType = "holdHours"
	HoldTypeIndefinite     HoldType = "indefinite"
	HoldTypeNextTransition HoldType = "nextTransition"
)

Supported HoldType values.

type MeterReportParameters

type MeterReportParameters struct {
	// The report UTC start date.
	StartDate *time.Time
	// The report start interval.
	StartInterval *int
	// The report UTC end date.
	EndDate *time.Time
	// The report end interval.
	EndInterval *int
	// A CSV string of meter types.
	Meters []MeterType
}

An MeterReportParameters specifies the request parameters of the MeterReport method.

type MeterReportSuccessResponse

type MeterReportSuccessResponse struct {
	// contains filtered or unexported fields
}

MeterReportSuccessResponse describes the success response returned by the ecobee server while retrieving a meter report.

func (*MeterReportSuccessResponse) ReportList

ReportList returns the response's status report list.

func (*MeterReportSuccessResponse) Status

Status returns the response's status.

func (*MeterReportSuccessResponse) String

func (m *MeterReportSuccessResponse) String() string

String implements the fmt.Stringer interface. It returns a string representing an indented JSON encoding of the response.

func (*MeterReportSuccessResponse) UnmarshalJSON

func (m *MeterReportSuccessResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type MeterType

type MeterType string

A MeterType specifies a meter type.

const (
	MeterTypeEnergy MeterType = "energy"
)

Supported MeterType values.

type PINAuthorizationSuccessResponse

type PINAuthorizationSuccessResponse struct {
	// contains filtered or unexported fields
}

PINAuthorizationSuccessResponse describes the success response returned by the ecobee server while requesting the PIN.

func (*PINAuthorizationSuccessResponse) AuthorizationToken

func (a *PINAuthorizationSuccessResponse) AuthorizationToken() string

AuthorizationToken returns the response's authorization token.

func (*PINAuthorizationSuccessResponse) ExpiresIn

func (a *PINAuthorizationSuccessResponse) ExpiresIn() int

ExpiresIn returns the response's expires in.

func (*PINAuthorizationSuccessResponse) PIN

PIN returns the response's PIN.

func (*PINAuthorizationSuccessResponse) PollingInterval

func (a *PINAuthorizationSuccessResponse) PollingInterval() int

PollingInterval returns the response's polling interval.

func (*PINAuthorizationSuccessResponse) Scope

Scope returns the response's scope.

func (*PINAuthorizationSuccessResponse) String

String implements the fmt.Stringer interface. It returns a string representing an indented JSON encoding of the response.

func (*PINAuthorizationSuccessResponse) UnmarshalJSON

func (a *PINAuthorizationSuccessResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type PlugState

type PlugState string

A PlugState specifies a plug state.

const (
	PlugStateOff    PlugState = "off"
	PlugStateOn     PlugState = "on"
	PlugStateResume PlugState = "resume"
)

Supported PlugState values.

type ResumeProgramParameters

type ResumeProgramParameters struct {
	// Specifies whether the thermostat be resumed to next event (false) or to
	// it's program (true).
	ResumeAll *bool
}

A ResumeProgramParameters specifies the request parameters of the ResumeProgram method.

type RuntimeReportParameters

type RuntimeReportParameters struct {
	// The report UTC start date.
	StartDate *time.Time
	// The report start interval.
	StartInterval *int
	// The report UTC end date.
	EndDate *time.Time
	// The report end interval.
	EndInterval *int
	// A CSV string of column names.
	Columns *string
	// Whether to include sensor runtime report data
	IncludeSensor *bool
}

An RuntimeReportParameters specifies the request parameters of the RuntimeReport method.

type RuntimeReportSuccessResponse

type RuntimeReportSuccessResponse struct {
	// contains filtered or unexported fields
}

RuntimeReportSuccessResponse describes the success response returned by the ecobee server while retrieving a runtime report.

func (*RuntimeReportSuccessResponse) ReportList

ReportList returns the response's status report list.

func (*RuntimeReportSuccessResponse) SensorList

SensorList returns the response's status sensor list.

func (*RuntimeReportSuccessResponse) Status

Status returns the response's status.

func (*RuntimeReportSuccessResponse) String

String implements the fmt.Stringer interface. It returns a string representing an indented JSON encoding of the response.

func (*RuntimeReportSuccessResponse) UnmarshalJSON

func (m *RuntimeReportSuccessResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Scope

type Scope string

Scope details the intent of the API application towards the user's account.

const (
	ScopeSmartRead  Scope = "smartRead"
	ScopeSmartWrite Scope = "smartWrite"
	ScopeEMS        Scope = "ems"
)

Supported Scope values.

type SendMessageParameters

type SendMessageParameters struct {
	// The message text to send.
	Text *string
}

A SendMessageParameters specifies the request parameters of the SendMessage method.

type SetHoldParameters

type SetHoldParameters struct {
	// The temperature to set the cool hold at.
	CoolHoldTemp *int
	// The temperature to set the heat hold at.
	HeatHoldTemp *int
	// The Climate to use as reference for setting the coolHoldTemp,
	// heatHoldTemp and fan settings.
	HoldClimateRef *string
	// The start date & time in thermostat time.
	StartDateTime *time.Time
	// The end date & time in thermostat time.
	EndDateTime *time.Time
	// The hold duration type.
	HoldType *HoldType
	// The number of hours to hold for.
	HoldHours *int
}

A SetHoldParameters specifies the request parameters of the SetHold method.

type ThermostatSuccessResponse

type ThermostatSuccessResponse struct {
	// contains filtered or unexported fields
}

ThermostatSuccessResponse describes the success response returned by the ecobee server while retrieving thermostat data.

func (*ThermostatSuccessResponse) Page

Page returns the response's page.

func (*ThermostatSuccessResponse) Status

Status returns the response's status.

func (*ThermostatSuccessResponse) String

func (t *ThermostatSuccessResponse) String() string

String implements the fmt.Stringer interface. It returns a string representing an indented JSON encoding of the response.

func (*ThermostatSuccessResponse) ThermostatList

func (t *ThermostatSuccessResponse) ThermostatList() []objects.Thermostat

ThermostatList returns the response's thermostat list.

func (*ThermostatSuccessResponse) UnmarshalJSON

func (t *ThermostatSuccessResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type ThermostatSummarySuccessResponse

type ThermostatSummarySuccessResponse struct {
	// contains filtered or unexported fields
}

ThermostatSummarySuccessResponse describes the success response returned by the ecobee server while retrieving thermostat configuration and state revisions.

func (*ThermostatSummarySuccessResponse) RevisionList

func (t *ThermostatSummarySuccessResponse) RevisionList() []string

RevisionList returns the response's revision list.

func (*ThermostatSummarySuccessResponse) Status

Status returns the response's status.

func (*ThermostatSummarySuccessResponse) StatusList

func (t *ThermostatSummarySuccessResponse) StatusList() []string

StatusList returns the response's status list.

func (*ThermostatSummarySuccessResponse) String

String implements the fmt.Stringer interface. It returns a string representing an indented JSON encoding of the response.

func (*ThermostatSummarySuccessResponse) ThermostatCount

func (t *ThermostatSummarySuccessResponse) ThermostatCount() int

ThermostatCount returns the response's thermostat count.

func (*ThermostatSummarySuccessResponse) UnmarshalJSON

func (t *ThermostatSummarySuccessResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type TokensSuccessResponse

type TokensSuccessResponse struct {
	// contains filtered or unexported fields
}

TokensSuccessResponse describes the success response returned by the ecobee server while requesting tokens.

func (*TokensSuccessResponse) AccessToken

func (t *TokensSuccessResponse) AccessToken() string

AccessToken returns the response's access token.

func (*TokensSuccessResponse) ExpiresIn

func (t *TokensSuccessResponse) ExpiresIn() int

ExpiresIn returns the response's expires in.

func (*TokensSuccessResponse) RefreshToken

func (t *TokensSuccessResponse) RefreshToken() string

RefreshToken returns the response's refresh token.

func (*TokensSuccessResponse) Scope

func (t *TokensSuccessResponse) Scope() Scope

Scope returns the response's scope.

func (*TokensSuccessResponse) String

func (t *TokensSuccessResponse) String() string

String implements the fmt.Stringer interface. It returns a string representing an indented JSON encoding of the response.

func (*TokensSuccessResponse) TokenType

func (t *TokensSuccessResponse) TokenType() string

TokenType returns the response's token type.

func (*TokensSuccessResponse) UnmarshalJSON

func (t *TokensSuccessResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type UnlinkVoiceEngineParameters

type UnlinkVoiceEngineParameters struct {
	// The name of the engine to unlink.
	EngineName *string
}

An UnlinkVoiceEngineParameters specifies the request parameters of the UnlinkVoiceEngine method.

type UpdateSensorParameters

type UpdateSensorParameters struct {
	// Name specifies the updated name to give the sensor.
	Name *string
	// DeviceID specifies the deviceId for the sensor.
	DeviceID *string
	// SensorID specifies the identifier for the sensor.
	SensorID *string
}

An UpdateSensorParameters specifies the request parameters of the UpdateSensor method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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