laulamanapps / nest-api
PHP Nest API client
0.9
2018-10-08 21:32 UTC
Requires
- php: >=7.1
- werkspot/enum: ^2.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.10
- guzzlehttp/guzzle: ^6.3
- mockery/mockery: ^1.0
- phpunit/phpunit: ^6.5
Suggests
- guzzlehttp/guzzle: ^6.3
This package is auto-updated.
Last update: 2024-11-12 13:01:43 UTC
README
This package provides a simple integration of the Official Nest Api for your PHP project.
Installation
With composer, add:
$ composer require laulamanapps/nest-api
if you want to make use of the provided Guzzle adapter, require guzzlehttp in your composer:
$ composer require guzzlehttp/guzzle
Get Access Token
Sign up at Nest as a Developer and get yourself an ClientID
and ClientSecret
Run the get-oauth-token
in the terminal and follow the instructions
$ ./bin/get-oauth-token
Usage
use LauLamanApps\NestApi\NestClientFactory; use LauLamanApps\NestApi\Client\Device\Thermostat\Temperature; $client = NestClientFactory::create('<AccessToken>'); $thermostat = $client->getThermostat('<DeviceId>'); // Get current Temperature echo 'The current temperature is:'; echo $thermostat->getAmbientTemperature(); // Set Target Temperature $newTemperature = Temperature::celsius(21.5); $thermostat->setTargetTemperature($newTemperature);
Tests
This package comes with 2 types of tests: Unit and Integration. To run them you can use the make commands in the projects root.
$ make tests # Runs all tests $ make tests-unit # Runs only unit tests $ make tests-integration # Runs only integration tests
Author
Nest API has been developed by LauLaman.