elberth90 / yeelight-api-client
Yeelight API的客户端库
1.0.0
2018-07-29 19:13 UTC
Requires
- php: >=7.0.0
- ext-json: *
- clue/socket-raw: ~1.2
- react/promise: ^2.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^1.12
- humbug/humbug: ~1.0@dev
- phpunit/phpunit: ^5.6
This package is auto-updated.
Last update: 2024-09-09 03:20:41 UTC
README
Yeelight-api-client是一个PHP客户端,使得管理和处理Yeelight灯泡变得容易。
安装
可以使用Composer进行安装。
然后安装库
composer require elberth90/yeelight-api-client
入门
创建YeelightClient
实例
use Yeelight\YeelightClient; $client = new \Yeelight\YeelightClient();
在本地网络中搜索灯泡
$bulbList = $client->search();
一旦你有了可用灯泡的列表,你可以对每个灯泡执行一些操作,例如获取每个灯泡的属性
foreach ($bulbList as $bulb) { $promise = $bulb->getProp([\Yeelight\Bulb\BulbProperties::COLOR_TEMPERATURE]); }
对灯泡执行的操作将返回Promise,因此你可以对其进行then()
或done()
操作。
$promise->done(function (\Yeelight\Bulb\Response $response) { // do something with response }, function (\Yeelight\Bulb\Exceptions\Exception $exception) { // log exception or whatever... });
API的完整文档可以在这里找到
贡献
有关贡献和开发yeelight-api-client的更多信息,请参阅CONTRIBUTING.md。