Sample iOS app demonstrating Nest Developer OAuth, REST read/write calls, and simple thermostat controls.
The app provides the following functionality:
- Display thermostat name
- Display HVAC mode
- Display current temperature in F
- Display target temperature in F
- Change target temperature in F
- Display fan timer on/off
- Turn fan timer on/off
- Display API errors
This app does not update state changes from the Nest API in real-time. It polls the API every 30 seconds and only updates the app after a successful polling call.
The target temperatures used in this app correspond to those used for Heat and Cool modes only. If the thermostat is in Eco, Heat-Cool, or Off modes, an error will be thrown when attempting to write the temperature. See the Thermostat Guide for more information.
You need a Nest Developer account to run this app.
- Create a developer account at https://developer.nest.com
- Register a new product and specify its Redirect URI as
http://localhost:8080/auth/nest/callback
- Select the Thermostat read/write v6 permission for the product.
See Register a Product for more information.
You also need a Nest Learning Thermostat in order to use the app functionality. The Thermostat can be physical or virtual.
- Create a user account at https://home.nest.com
- Add a Nest Learning Thermostat
- If using a physical device, go through the new device setup detailed in the instructions included with the device
- If using a virtual device, create it in the Nest Home Simulator Chrome Extension
- Sign in with your user account (from home.nest.com)
- On the Structure screen, select ADD [DEVICE]
Note: When using a virtual device in the Nest Home Simulator, updates to the fan_timer_active
endpoint may not be accurately reflected in the Nest API, compared to a physical device. See the Thermostat Guide for more information.
- Clone this repository:
git clone https://github.com/nestlabs/iOS-NestDK.git
- Open the project file (
iOS-NestDK.xcodeproj
) in Xcode. - In
Constants.m
, replace the placeholder strings forNestClientID
andNestClientSecret
with your Nest Developer credentials from the Overview tab on the products page: https://console.developers.nest.com/products.
To change the GET polling frequency, modify the
POLL_INTERVAL
value inNestThermostatManager.m
. Do not set thePOLL_INTERVAL
to less than 25 seconds, or you may hit the GET request rate limit.
This app is targeted for iOS 9.0 or later. It will not run properly on prior versions of iOS.
In Xcode:
- Select Product > Build.
- Select Product > Run.
Contributions are always welcome and highly encouraged.
See CONTRIBUTING for more information on how to get started.
Apache 2.0 - See LICENSE for more information.