Skip to content

Instantly share code, notes, and snippets.

@jasonrdsouza
Created January 4, 2019 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonrdsouza/b71b3ae1e995ee75ec18799314d982b4 to your computer and use it in GitHub Desktop.
Save jasonrdsouza/b71b3ae1e995ee75ec18799314d982b4 to your computer and use it in GitHub Desktop.
Snippet to pull thermostat info from the Nest API
import nest # https://pypi.org/project/python-nest/
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
napi = nest.Nest(client_id=config['NEST']['client_id'], client_secret=config['NEST']['client_secret'], access_token_cache_file='token_cache')
if napi.authorization_required:
print('Go to ' + napi.authorize_url + ' to authorize, then enter PIN below')
pin = input("PIN: ")
napi.request_token(pin)
# Fetch thermostat info
for structure in napi.structures:
# should only be 1 structure, since I only have 1 "house" setup
for thermostat in structure.thermostats:
print(json.dumps(t.__repr__()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment