GithubHelp home page GithubHelp logo

nestsharp's Introduction

NestSharp

This is a feeble attempt at creating a C#/.NET Portable Library to consume data from and interact with NEST devices.

This is a work in progress! Currently some of the basics work, you can get information about devices, and you can adjust the temperature of a thermostat. The groundwork is there, and the rest just needs to be added.

Authorization

NEST uses OAUTH to authorize. Currently only the PIN (no Callback URI specified in your client) is supported. When you create a NEST Client in the developer portal, be sure to specify no callback URI.

To authorize using the API, first get the authorization URI:

var authUrl = nest.GetAuthorizationUrl ();

You'll need to display this to the user in a web browser of some sort, they will accept the permissions they are authorizing, login, and finally be shown a PIN which they'll need to enter back in the application.

When you have the PIN, get an access token:

await nest.GetAccessToken (pin);

NOTE: Obtaining an access token will return an expiry time for the token, however NEST states that the expiry time is so long-lived that it can be considered indefinite, and as such, there is no refresh-token API to keep the access token current. You should probably check for HTTP 401 errors on API calls just to be safe.

NEST APIs

Once you have received your access token, you can start to make requests to the API methods.

// Fetch devices 
var devices = await nest.GetDevicesAsync ();

// Loop through the devices
foreach (var t in devices.Thermostats) {

	// Set the temperature on our thermostats
	await nest.AdjustTemperatureAsync (
			t.DeviceId,
			21.5f,
			TemperatureScale.C);                
}

// TODO:

  • More object data models (ahem Company)
  • OAuth with a non-empty callback url
  • Actually write some tests for that nice little NUNit project
  • Moar API coverage
  • Sample app!

nestsharp's People

Contributors

horndev avatar redth avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.