-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfluebot_disable.php
51 lines (27 loc) · 1.02 KB
/
fluebot_disable.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
<?php
function check_disable($lights) {
// Returns a list of lights not to touch!
global $settings;
$disable=[];
foreach ($settings["disable_on"] as $reason => $check) {
$bulb = $lights[$check["bulb"]];
if ($bulb["state"]["on"]) {
if ($check["check"]=="ct") {
if (($check["check_for"]==$bulb["state"]["ct"])&&($check["check_bri"]==$bulb["state"]["bri"])) {
echo "!! ".$reason." disable rule met.\n";
echo "!! skipping ".implode($check["disable"],",")."\n";
$disable=array_merge($check["disable"], $disable);
}
} elseif ( ($check["check"]=="rgb") ) {
$rgb = XYtoRgb($bulb["state"]["xy"][0], $bulb["state"]["xy"][1], $bulb["state"]["bri"]);
if (rgbMatch($rgb, $check["check_for"])) {
echo "!! ".$reason." disable rule met.\n";
echo "!! skipping ".implode($check["disable"],",")."\n";
$disable=array_merge($check["disable"], $disable);
}
}
}
}
return array_unique($disable);
}
?>