User Tools

Site Tools


nest_tutorial

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
nest_tutorial [2017/01/03 22:57] dwallacenest_tutorial [2017/02/09 13:46] (current) dwallace
Line 7: Line 7:
 **Keywords:** Smart Home, Nest, API, SDK, Android, Java **Keywords:** Smart Home, Nest, API, SDK, Android, Java
 \\ \\
 +\\ \\ 
 +{{ youtube>nphZtBLi910?large }}
 +\\ \\ 
  
-{{ VIDEO }} +This tutorial is the first part of a series of tutorials on Smart Home development. This tutorial serves as a starting point for Nest development using Android. Nest development can also be done with iOS and Web, but we will not cover these in this tutorial. For more info on those, see the [[https://developers.nest.com/documentation/cloud/get-started|Nest developers website]].
- +
-This tutorial serves as a starting point for Nest development using Android. Nest development can also be done with iOS and Web, but we will not cover these in this tutorial. For more info on those, see the [[https://developers.nest.com/documentation/cloud/get-started|Nest developers website]].+
  
 ===== Overview ===== ===== Overview =====
  
-The Nest API utilizes a single JSON document to store all of the data about one "structure" or home that a user has associated with their account. This structure then includes all of the devices, and all of the parameters for the devices, as well as user data such as location.+The [[https://developers.nest.com/documentation/api-reference|Nest API]] utilizes a single JSON document to store all of the data about one "structure" or home that a user has associated with their account. This structure then includes all of the devices, and all of the parameters for the devices, as well as user data such as location.
  
 In order to interface with the Nest API, we need to utilize the [[https://firebase.google.com|Firebase platform]], which is an application infrastructure that handles authentication, hosting, and more. Thankfully, Firebase is built into the Nest API, allowing us to use it with ease. In order to interface with the Nest API, we need to utilize the [[https://firebase.google.com|Firebase platform]], which is an application infrastructure that handles authentication, hosting, and more. Thankfully, Firebase is built into the Nest API, allowing us to use it with ease.
Line 30: Line 31:
 Once you have downloaded the necessary tools and SDKs, we will need to set-up a Nest client for our app to use for authentication and permissions. To do this, first make a [[https://developers.nest.com/|Nest developers account]]. If you already have a Nest account associated with physical devices, make a different account for development, as we will be using a web simulator that interferes with physical devices on the same account. Once you have downloaded the necessary tools and SDKs, we will need to set-up a Nest client for our app to use for authentication and permissions. To do this, first make a [[https://developers.nest.com/|Nest developers account]]. If you already have a Nest account associated with physical devices, make a different account for development, as we will be using a web simulator that interferes with physical devices on the same account.
  
-Now, we will create our Nest client. To do this, we will head to the [[https://developers.nest.com/products|prodcuts page]] of the Nest website. This page allows us to create custom clients for our app. Your screen should end up looking like this: +Now, we will create our Nest client. To do this, we will head to the [[https://developers.nest.com/products|products page]] of the Nest website. This page allows us to create custom clients for our app. Your screen should end up looking like this: 
-\\  +\\ \\  
-{{ dylanw:nestproductpage.jpg?600 }}+{{ dylanw:nestproductpage.jpg?800 }}
 \\  \\ 
  
Line 38: Line 39:
  
 Next, we will need to provide the permissions for our app to use. To do this, we will simply add the necessary permissions on the product page. For testing purposes, it is best to give all permissions to ensure that everything is working. Your permissions section should end up looking like this: Next, we will need to provide the permissions for our app to use. To do this, we will simply add the necessary permissions on the product page. For testing purposes, it is best to give all permissions to ensure that everything is working. Your permissions section should end up looking like this:
-\\  +\\ \\  
-{{ dylanw:nestpermissions.jpg?600 }}+{{ dylanw:nestpermissions.jpg?800 }}
 \\  \\ 
  
Line 51: Line 52:
  
 Once, you have successfully imported the project, we need to make some changes to the Constants file. This can be found under java/com.nestlabs.sdk.sample/Constants.java . Here, we will modify the fields according the the data that our Nest client provides. Copy the Product ID from the Nest client to the CLIENT_ID field, the Product Secret to the CLIENT_SECRET field, and the Redirect URI (http://localhost/) to the REDIRECT_URL field. Your file should look something like this: Once, you have successfully imported the project, we need to make some changes to the Constants file. This can be found under java/com.nestlabs.sdk.sample/Constants.java . Here, we will modify the fields according the the data that our Nest client provides. Copy the Product ID from the Nest client to the CLIENT_ID field, the Product Secret to the CLIENT_SECRET field, and the Redirect URI (http://localhost/) to the REDIRECT_URL field. Your file should look something like this:
-\\  +\\ \\  
-{{ dylanw:nestconstants.jpg?600 }}+{{ dylanw:nestconstants.jpg?800 }}
 \\  \\ 
  
Line 63: Line 64:
 In order to deploy to a physical device, we have to ensure that both Developer Mode is turned-on, and that USB Debugging is turned-on. To enable Developer Mode, go to Settings > About device and tap the Build Number field 7 times. This will ensure that Developer Mode is turned on. To enable USB debugging, plug in your device to your computer, and Media Device Options card in the Notifications bar. Disable and re-enable the device as a Media Device, and then it will prompt you to enable USB Debugging. Check to "Always enable on this PC", and continue. In order to deploy to a physical device, we have to ensure that both Developer Mode is turned-on, and that USB Debugging is turned-on. To enable Developer Mode, go to Settings > About device and tap the Build Number field 7 times. This will ensure that Developer Mode is turned on. To enable USB debugging, plug in your device to your computer, and Media Device Options card in the Notifications bar. Disable and re-enable the device as a Media Device, and then it will prompt you to enable USB Debugging. Check to "Always enable on this PC", and continue.
  
-Now we can deploy the app to our device. To do this simply press the Run button. It will ask you to choose which device to run on, so choose the device you just enabled. It may prompt you to install the same version of Android as your device to enable Instant Run. Do this, and wait for the install to finish. Once, you have done this, press run again, and Android Studio will build the project and deploy it onto your device for you to use.+Now we can deploy the app to our device. To do this simply press the Run button. It will ask you to choose which device to run on, so choose the device you just enabled. It may prompt you to install the same version of Android as your device to enable Instant Run. Do this, and wait for the install to finish. Once, you have done this, press Run, and Android Studio will build the project and deploy it onto your device for you to use. 
 + 
 +===== Testing ===== 
 + 
 +In order to test our app that we have created, we need some Nest devices to interface with. If you already have Nest devices, then you are welcome to use those for testing. However, for most it is easier to utilize the Nest Home Simulator to emulate virtual Nest devices for testing. 
 + 
 +To do this, we must first install the [[https://developers.nest.com/documentation/cloud/home-simulator/|Nest Home Simulator]] onto a Chrome browser. Currently this application only supports Chrome. Once you have installed this, open it up, log-in, and you should see a screen similar to this: 
 +\\ \\  
 +{{ dylanw:nestsimulator.jpg?800 }} 
 +\\  
 + 
 +Here, we can add virtual Nest devices and even virtual "structures" to our developer account. This will allow us to test how a user's Nest products interface with our app. For this tutorials purposes, we will only need to add the thermostat. Simply click Add Thermostat, and it will be added to your account. If we click our new thermostat, we can monitor the changes to it, and even make changes ourselves. This is very useful for testing. 
 + 
 +Once you have setup the Nest Home Simulator, and your app is deployed, you should be ready to start testing the app!  
 + 
 +Now that you know the process, go through the [[https://nestlabs.github.io/android-sdk/index.html?com/nestlabs/sdk/CameraSetter.html|Nest Java documentation]] to learn more about how you can create custom apps for your Nest products. 
 + 
 + 
 +For questions, clarifications, etc, Email: <[email protected]>
nest_tutorial.1483513079.txt.gz · Last modified: 2017/01/03 22:57 by dwallace