-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_devices.php
56 lines (52 loc) · 2.09 KB
/
get_devices.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
<?php
$CONFIG_FILENAME = 'data/config.xml';
//config.xml dateisystem rechte überprüfen
if(!file_exists($CONFIG_FILENAME)) {
echo "Kann die Konfiguration (".$CONFIG_FILENAME.") nicht finden!\n";
exit(1);
}
if(!is_readable($CONFIG_FILENAME)) {
echo "Kann die Konfiguration (".$CONFIG_FILENAME.") nicht lesen!\n";
exit(2);
}
//config.xml einlesen
libxml_use_internal_errors(true);
$xml = simplexml_load_file($CONFIG_FILENAME);
if (!$xml) {
echo "Kann die Konfiguration (".$CONFIG_FILENAME.") nicht laden!\n";
foreach(libxml_get_errors() as $error) {
echo "\t", $error->message;
}
exit(4);
}
$ResStr="";
$NoFBdect=FALSE;
if (isset($_GET['nofbdect'])) {
if ($_GET['nofbdect'] == "true") $NoFBdect=TRUE;
}
foreach($xml->devices->device as $device) {
if ($NoFBdect == TRUE && $device->vendor == "fbdect200" || $device->vendor == "computer") { }
else {
$ResStr .= $device->id.":".$device->name.":".$device->room.":".$device->status.":".$device->showDeviceStatus.":".$device->vendor.":";
if ($device->milight->color != "") $ResStr .= $device->milight->color.":";
else $ResStr .= "UNDEF:";
if ($device->milight->brightnesscolor != "") $ResStr .= $device->milight->brightnesscolor.":";
else $ResStr .= "0:";
if ($device->milight->brightnesswhite != "") $ResStr .= $device->milight->brightnesswhite.":";
else $ResStr .= "0:";
if ($device->milight->mode != "") $ResStr .= $device->milight->mode.":";
else $ResStr .= "UNDEF:";
if ($device->address->tx433version != "") $ResStr .= $device->address->tx433version.":";
else $ResStr .= "UNDEF:";
$ResStr .= $xml->global->timerGlobalRun .":";
if ($device->milight->brightnessdisco != "") $ResStr .= $device->milight->brightnessdisco.":";
else $ResStr .= "0:";
$ResStr .= $xml->global->AlertState .":";
if ($device->milight->temperature != "") $ResStr .= $device->milight->temperature.":";
else $ResStr .= "0:";
if ($device->milight->saturation != "") $ResStr .= $device->milight->saturation."|";
else $ResStr .= "100|";
}
}
echo substr($ResStr, 0, strlen($ResStr)-1);
?>