Skip to main content

Python3 async library for interacting with the ecobee API

Project description

aioecobee

Python3 async library for interacting with the ecobee API

Requirements: aiofiles, aiohttp, asyncio

Install aioecobee with python3 -m pip install aioecobee.

Usage

aioecobee's main class is EcobeeAPI; create an API object like this:

from aiohttp import ClientSession
from aioecobee import EcobeeAPI

session = ClientSession()
api_key = xxxxxxxxxxxxxxxxxxxxx
config_file = "/path/to/ecobee.conf"

ecobee = EcobeeAPI(session, api_key=api_key, config_file=config_file)

Where:

  • session is an instance of aiohttp.ClientSession();
  • api_key is the API key obtained from ecobee.com (optional); and,
  • config_file is the name of a config file for use with aioecobee (optional).

If config_file is not specified, api_key is required.

Obtain a PIN for authorizing on ecobee.com:

await ecobee.request_pin()

After authorizing your app on ecobee.com, request tokens:

await ecobee.request_tokens()

After obtaining tokens, populate (or update) ecobee.thermostats and ecobee.sensors:

await ecobee.update()

Calls to the API will raise an ExpiredTokensError if tokens are expired and need refreshing:

from aioecobee import ExpiredTokensError
try:
    await ecobee.update()
except ExpiredTokensError:
    await ecobee.refresh_tokens()

example.py

An example script is provided to demonstrate the usage of aioecobee.

python example.py api_key

Caveats

aioecobee does not implement timeouts; use asyncio_timeout in your client code to wrap calls to the API as needed.

Contributing

Please open issues or pull requests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioecobee-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file aioecobee-0.1.0.tar.gz.

File metadata

  • Download URL: aioecobee-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for aioecobee-0.1.0.tar.gz
Algorithm Hash digest
SHA256 435cf78040f1c5f8229ec93e869f379dc830d876c389a9ca0cf4db6719237a9a
MD5 527db99c0c4345eb018a7897577127f3
BLAKE2b-256 f8757f21abfce7fb5b33acd2434d56aeb6993f4a7295f8eecb7312f72800286e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page