Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/redth/nestsharp
A Portable NEST API Client for C#/.NET
https://github.com/redth/nestsharp
Last synced: 23 days ago
JSON representation
A Portable NEST API Client for C#/.NET
- Host: GitHub
- URL: https://github.com/redth/nestsharp
- Owner: Redth
- License: apache-2.0
- Created: 2015-04-25T15:24:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-10-09T17:49:50.000Z (about 6 years ago)
- Last Synced: 2024-10-13T15:08:11.222Z (25 days ago)
- Language: C#
- Homepage:
- Size: 233 KB
- Stars: 7
- Watchers: 6
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```csharp
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:
```csharp
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.
```csharp
// 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!