iot-home / philips-hue-api
1.3.3
2022-03-06 19:50 UTC
Requires
- php: >=8.0
- ext-curl: *
Requires (Dev)
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
This package is not auto-updated.
Last update: 2024-09-30 07:19:36 UTC
README
用于控制飞利浦 Hue 照明系统的简单客户端。
使用
- 注册应用程序并获取密钥(您需要知道 HUB IP 地址)
$client = new \IoTHome\PhilipsHueApi\Hue\Client('10.0.0.5', null);
// register application
$key = $client->registerApplication('app-name');
// save key to your database and use it in a new instance of Client
- 使用提供的密钥创建客户端,现在您可以控制您的灯光
$client = new \IoTHome\PhilipsHueApi\Hue\Client('10.0.0.5', 'key');
// get all available lights
$lights = $client->getLights();
// Get light by id and turn it on
$light = $client->getLightById('abcd');
$light->setOn(true);
$client->updateLight($light);
// Get all available Rooms
$rooms = $client->getRooms();
// Get all available Zones
$rooms = $client->getZones();
将场景应用于灯光
$client = new \IoTHome\PhilipsHueApi\Hue\Client('10.0.0.5', 'key');
$scene = $client->getSceneById('abcdef12-abcd-1234-93bb-da3e0ea601d1');
$service = new \IoTHome\PhilipsHueApi\Scenes\SceneService($client);
// Method applies scene to all lights in group
$service->applyScene($scene);