Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Sample nest thermostate

John Cocula edited this page Oct 4, 2015 · 1 revision

⚠️ Note: This how-to for Nest integration is superseded by the Nest Binding.

This is a sample implementation of a read-only integration of the Nest into Openhab. Here's the recipe:

  1. get a developer account @ https://developer.nest.com/ and create a client registration:

  2. Copy the authorization URL and open it in a new browser. Use your Nest login to approve the request. Once approved, you will get a "pincode".

  3. I used curl, but there are other tools out there to do an http post. In the "Access Token URL", replace the "AUTHORIZATION_CODE" with the pincode from step 2.

  4. curl --data 'code=AUTH_CODE&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=authorization_code' https://api.home.nest.com/oauth2/access_token

    {"access_token":"[big long random string]","expires_in":315360000}

  5. We're done! The above access_token will give you access to the api for the next 10 years :-)

  6. To test, open the following url in your browser: https://developer-api.nest.com/devices/thermostats?auth=[big long random string from step 4]

  7. A json structure should be returned with all your devices. Get the "device_id" for your thermostat.

now in the openHAB world:

Items:

Number curNestTemp "Nest [%.1f F]" (Weather_Chart,gFF) { http="<[nest:60000:JS(GetNestValue.js)]"}

Number curNestTargetTemp "Nest Target [%.1f F]" (Weather_Chart,gFF) { http="<[nest:60000:JS(GetNestTargetValue.js)]"}

openhab.cfg:

############################### HTTP Binding ##########################################

http:nest.url=https://developer-api.nest.com/devices/thermostats/[DEVICE_ID from step 7]?auth=[big long random string from step 5]

http:nest.updateInterval=60000

GetNestValue.js:

JSON.parse(input).ambient_temperature_f;

GetNestTargetValue.js:

JSON.parse(input).target_temperature_f;

Simple! Now, every minute the current thermostat and target temperatures are refreshed. You can easily read any of the other properties of the thermostat as described here: https://developer.nest.com/documentation/api-reference.

For active control over the thermostat, see this discussion: https://groups.google.com/forum/#!topic/openhab/0u1t3xyZlqk An implementation might be available soon.

Installation


User Interfaces


Community

(link to openHAB forum)

Development



Misc


Samples

A good source of inspiration and tips from users gathered over the years. Be aware that things may have changed since they were written and some examples might not work correctly.

Please update the wiki if you do come across any out of date information.

Use case examples

Collections of Rules on a single page

Single Rules

Scripts


Release Notes

Clone this wiki locally