GithubHelp home page GithubHelp logo

ecobee's Introduction

ecobee

Tests

A module to work with the Ecobee API.

This is a work in progress. Right now, it can handle:

  • Retrieving and storing access and refresh tokens

  • Refreshing tokens

  • Retrieving a list of thermostats and their runtime information (which includes temperature)

  • Optionally writing information to InfluxDB

Using

You can go get this module:

go get github.com/mitchya1/ecobee/pkg/ecobee

Follow the steps in the Ecobee Setup section for steps on how to set up Ecobee. This involves some manual work.

Important Note: After completing the steps in Ecobee Setup, you have 900 seconds to retrieve your access and refresh tokens.

At this point, you should have information to retrieve your tokens.

The initial code to retrieve tokens could look like this:

package main

import (
  "net/http"
  "os"
  "github.com/mitchya1/ecobee/pkg/ecobee"
)
func main() {

  client := &http.Client{}

  ecobeeClient := ecobee.EBClient{
		Client:    client,
		APIKey:    "YOUR API KEY",
		AuthCode:  "YOUR AUTH CODE",
		TokenFile: "PATH TO TOKEN FILE",
  }
  
  // This will automatically store the tokens wherever you specify in
  // ecobee.EBClient.TokenFile
  oauth, err = ecobeeClient.GetOAuthTokens()

	if err != nil {
		os.Exit(1)
	}
}

Configuration File

If you plan on borrowing from /example/main.go, here are some notes about the configuration file:

The configuration file must be named ecobee.yml and must exist in either:

  • The directory that you call the binary from (If the binary exists in /opt/ecobee/ecobee and you run it from /var/tmp/, the config file should be /var/tmp/ecobee.yml)

  • $HOME/.ecobee/

  • /etc/ecobee/

A yaml file with these keys:

api_token: "API token from the application - found under 'Developer'"
auth_code: "Authorization code from Step 1: https://www.ecobee.com/home/developer/api/examples/ex1.shtml"
token_file: "Path to store access and refresh tokens"
influxdb_token: "InfluxDB API token"
influxdb_bucket: "bucket name to store data in"
influxdb_org: "org name"
influxdb_uri: "URI to influxdb, including protocol and port"
owm_zip_code: 11111
owm_api_key: "Your ecobee API key"

Ecobee Setup

Create an ecobee developer account here

  • 2FA must be disabled on your ecobee account

Log into ecobee

Go to the developer tab

Create an app

Authorize the app under "My Apps" in the Ecobee web app

Retrieve the API key from the app you created

Go through the first step here to retrieve your authorization code

  • This code can only be used once, otherwise you'll have to redo these steps and re-add the app under "My Apps" in the Ecobee web app

TODO

Rework refresh token flow to make it automatic

  • This should happen in ecobee.GetOAuth

Make thermostat retrieval more variabalized

ecobee's People

Contributors

chilledornaments avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.