An AWS Lambda function that collects data from my thermostats and corresponding outdoor temperatures. It polls two different thermostat technologies, a Honeywell Gateway and a Google Nest, as well as the OpenWeather API. It's used to monitor conditions at The Grey Haven, an Airbnb in Lake Arrowhead, California.
First set up a project in the Google Device Access console. From there you will need the project ID, the client ID, and the client secret; copy them to a safe place.
Then run the following to open the Google login page.
utilities/open-login.py CLIENT_ID PROJECT_IDComplete the login flow, and from the redirected URL, extract the code parameter and
copy it to a safe place. Now run the following:
utilities/get-tokens.py CLIENT_ID CLIENT_SECRET CODETake the resultant refresh token from the above script, and copy it to a safe place.
Deploy the Lambda by running terraform plan from the terraform folder. Once
the infrastructure is deployed, modify the created temperature-collector-config secret
and add the following values:
greyHavenLocation: Comma-separated lat/lon of location of AirbnbsanDiegoLocation: Comma-separated lat/lon of location of homehoneywellLocationId: Unique identifier for Honeywell Gateway (read out of console URL)honeywellLabels: Mapping of Honeywell zone IDs to zone names (formatted askey:value,key:value)honeywellUsername: Honeywell account usernamehoneywellPassword: Honeywell account passwordnestProjectId: Project ID from earlier Google console stepnestClientId: Client ID from earlier Google console stepnestClientSecret: Client Secret from earlier Google console stepnestRefreshToken: Refresh token output from earlierget-tokens.pyscript outputopenWeatherApiKey: OpenWeather API key from account page
Every five minutes the Lambda will be triggered, and write the following metrics to CloudWatch:
Temperatures/SanDiego/Outside/TemperatureTemperatures/SanDiego/Downstairs/TemperatureTemperatures/SanDiego/Downstairs/HeatSetpointTemperatures/SanDiego/Downstairs/CoolSetpointTemperatures/TheGreyHaven/Outside/TemperatureTemperatures/TheGreyHaven/Downstairs/TemperatureTemperatures/TheGreyHaven/Downstairs/HeatSetpointTemperatures/TheGreyHaven/Downstairs/CoolSetpointTemperatures/TheGreyHaven/Upstairs/TemperatureTemperatures/TheGreyHaven/Upstairs/HeatSetpointTemperatures/TheGreyHaven/Upstairs/CoolSetpoint
-
Make the configuration of thermostats more generic, vs being specific to the author's setup.
-
If Google ever gets around to implementing an API for the Nest remote temperature sensor it could be added here.