Created
January 4, 2019 00:12
-
-
Save jasonrdsouza/b71b3ae1e995ee75ec18799314d982b4 to your computer and use it in GitHub Desktop.
Snippet to pull thermostat info from the Nest API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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