Skip to content
Michael Hallock edited this page Apr 13, 2018 · 6 revisions

Ecobee

This library provides basic wrapping functionality for communicating with the Ecobee API. That includes:

  1. Strongly typed protocol library for all supported requests.
  2. A client that handles authentication token handshakes and simple messaging.

Note that due to the nature of Ecobee's authentication protocol, any calling code of this library is responsible for caching access tokens / refresh tokens. These tokens have expirations of 1 hour, and 1 year respectfully (subject to change at Ecobee's will). As such, and app using their API has to facilitate long term token storage.

In the event that a refresh token is not utilized within a year, reauthorization of the application will be necessary in Ecobee's interface.

For more information about auth, and the structure of the API calls that this library facilitates, please see Ecobee's API documentation.

Usage

The test application will show the basics of usage. Callers will need to implement async methods for storing and retrieving tokens as management of these tokens needs to be application specific.

  1. One could store them in a database and call every time to get the current token, especially useful for multi-tenant situations.
  2. Or can implement a static variable to store the current token while running plus a write / read to filesystem (like the test app).
  3. Or any other number of scenarios.

Custom Timeouts

A custom timeout value for HttpClient calls can be passed in the constructor as a TimeSpan if desired. Default is the same as HttpClient, 100 seconds.

ServicePointManager

Ecobees servers seem to not handle Expect: 100-continue headers correctly. Microsoft's HttpClient conveniently always puts this on requests and there's no way to change this per request.

As such, any app that uses this will likely need to put the following in its app.config or web.config in order to turn this HttpClient feature off globally:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  ...
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <system.net>
    <settings>
      <servicePointManager expect100Continue="false" />
    </settings>
  </system.net>
  ...
</configuration>
Clone this wiki locally