laulamanapps / nest-api
PHP Nest API 客户端
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-09-12 12:41:30 UTC
README
此包为您的PHP项目提供了对官方Nest Api的简单集成。
安装
使用 composer,添加
$ composer require laulamanapps/nest-api
如果您想使用提供的Guzzle适配器,请在composer中要求guzzlehttp
$ composer require guzzlehttp/guzzle
获取访问令牌
在Nest上注册为开发者并获取自己的 ClientID
和 ClientSecret
在终端中运行 get-oauth-token
并按照说明操作
$ ./bin/get-oauth-token
用法
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);
测试
此包包含2种类型的测试:单元测试和集成测试。要运行它们,您可以使用项目根目录中的make命令。
$ make tests # Runs all tests $ make tests-unit # Runs only unit tests $ make tests-integration # Runs only integration tests
作者
Nest API 由 LauLaman 开发。