-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавлен пример работы с wifi-лампами Philips Light Bulb.
- Loading branch information
1 parent
c0e3456
commit 3160e21
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/* | ||
* Управление wifi-лампами Philips Light Bulb по протоколу miIO. | ||
* | ||
* Copyright (C) 2017 Agaphonov Dmitri aka skysilver [mailto:[email protected]] | ||
*/ | ||
|
||
require('philipsbulb.class.php'); | ||
|
||
error_reporting(-1); | ||
ini_set('display_errors', 1); | ||
|
||
$ip = '192.168.1.48'; | ||
$token = 'b35f0af9064e6434d3f571ec05e5acc6'; | ||
$bind_ip = null; | ||
$debug = false; | ||
|
||
$bulb = new philipsBulb($ip, $bind_ip, $token, $debug); | ||
|
||
echo PHP_EOL . date('H:m:s', time()); | ||
if($bulb->getStatus()) echo ' Статус получен.' . PHP_EOL; | ||
echo 'Питание: ' . $bulb->status['power'] . PHP_EOL; | ||
echo 'Яркость: ' . $bulb->status['bright'] . PHP_EOL; | ||
echo 'Цветовая температура: ' . $bulb->status['cct'] . PHP_EOL; | ||
echo 'Сцена: ' . $bulb->status['snm'] . PHP_EOL; | ||
echo 'Таймер выключения: ' . $bulb->status['dv'] . PHP_EOL; | ||
|
||
|
||
sleep(2); | ||
|
||
echo PHP_EOL . date('H:m:s', time()) . PHP_EOL; | ||
echo $bulb->getInfo() . PHP_EOL; | ||
|
||
sleep(2); | ||
|
||
echo PHP_EOL . date('H:m:s', time()); | ||
if($bulb->powerOn()) echo ' Лампа включена.' . PHP_EOL; | ||
else echo "Лампа не включена. Ошибка: $bulb->error" . PHP_EOL; | ||
|
||
sleep(2); | ||
|
||
echo PHP_EOL . date('H:m:s', time()); | ||
if($bulb->powerOff()) echo ' Лампа выключена.' . PHP_EOL; | ||
else echo "Лампа не выключена. Ошибка: $bulb->error" . PHP_EOL; | ||
|
||
sleep(2); | ||
|
||
for ($i = 1; $i < 5; $i++) { | ||
echo PHP_EOL . date('H:m:s', time()); | ||
if($bulb->setScene($i)) echo " Включена сцена $i." . PHP_EOL; | ||
sleep(2); | ||
} |