-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.php
58 lines (37 loc) · 1.34 KB
/
status.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
if (!file_exists("bridge.json")) { echo "bridge.json not found. Run register.php.\n"; exit; }
$bridge=json_decode(file_get_contents("bridge.json"),true);
if (!$bridge["username"]) { echo "Run register.php. Username not found.\n"; exit; }
include "functions.php";
include "settings.php";
// Return an output a list of all lights.
$lights = get($bridge["ip"], $bridge["username"], "lights");
foreach ($lights as $id => $light) {
if ($settings["lights"][$id]["nickname"]) {
$nickname = $settings["lights"][$id]["nickname"]." (id: ".$id.")";
} else {
$nickname = $light["name"]." (not controlled by Flue, id: ".$id.")";
}
echo "# ".$nickname."\n";
echo " state: ";
if ($light["state"]["on"]) {
echo "on";
} else {
echo "off";
}
if (!$light["state"]["reachable"]) echo " (unreachable!)";
echo "\n";
echo " type: ".$light["type"]."\n";
echo " mode: ".$light["state"]["colormode"]."\n";
if ($light["state"]["colormode"]=="ct") {
echo " temperature: ".$light["state"]["ct"]."\n";
} elseif ($light["state"]["colormode"]=="xy") {
$rgb = XYtoRgb($light["state"]["xy"][0], $light["state"]["xy"][1], $light["state"]["bri"]);
echo " r: ".$rgb["r"]."\n";
echo " g: ".$rgb["g"]."\n";
echo " b: ".$rgb["b"]."\n";
}
echo " brightness: ".$light["state"]["bri"]."\n";
echo "\n";
}
?>