52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |

61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 | gui->showGroupsBtnInMenu == "true") require_once('includes/incl_groups.php');
97 | // Räume
98 | if($xml->gui->showRoomsBtnInMenu == "true") require_once('includes/incl_rooms.php');
99 | // Aktionen
100 | if($xml->gui->showActionBtnInMenu == "true") require_once('includes/incl_actions.php');
101 | // Timer
102 | if($xml->gui->showTimerBtnInMenu == "true") require_once('includes/incl_timer.php');
103 | // Geräteeditor
104 | require_once('includes/incl_edit_devs.php');
105 | // Gruppeneditor
106 | if($xml->gui->showGroupsBtnInMenu == "true") require_once('includes/incl_edit_groups.php');
107 | // Timereditor
108 | if($xml->gui->showTimerBtnInMenu == "true") require_once('includes/incl_edit_timer.php');
109 | // Einstellungen
110 | if($ShowSettingsMenue == "true") require_once('includes/incl_settings.php');
111 | // Desing-Einstellungen
112 | if($ShowSettingsMenue == "true") require_once('includes/incl_settings_design.php');
113 | // Benutzerverwaltung
114 | if($ShowSettingsMenue == "true") require_once('includes/incl_settings_user.php');
115 | // Debug
116 | require_once('includes/incl_debug.php');
117 | ?>
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 | POST
15 | if (isset($_POST['action'])) {
16 | $r_action = (string)$_POST['action'];
17 | $r_type = (string)$_POST['type'];
18 | $r_id = (string)$_POST['id'];
19 | }
20 | // Über Linkfunktion -> GET
21 | if (isset($_GET['action'])) {
22 | $r_action = (string)$_GET['action'];
23 | $r_type = (string)$_GET['type'];
24 | $r_id = (string)$_GET['id'];
25 | if (isset($_GET['async'])) {
26 | async_curl('http://localhost'.$_SERVER[PHP_SELF]."?action=".$r_action."&type=".$r_type."&id=".$r_id);
27 | echo "Async-Aufruf registriert: ". $_SERVER[PHP_SELF]."?action=".$r_action."&type=".$r_type."&id=".$r_id;
28 | exit();
29 | }
30 |
31 | if($r_action == "toggle" and $r_type == "device"){
32 | $xpath='//device/id[.="'.$r_id.'"]/parent::*';
33 | $res = $xml->xpath($xpath);
34 | $parent = $res[0];
35 | if($parent[0]->status == "OFF"){
36 | $r_action = "on";
37 | }elseif($parent[0]->status == "ON"){
38 | $r_action = "off";
39 | }
40 | }
41 |
42 | if($r_action == "status" and $r_type == "device"){
43 | $xpath='//device/id[.="'.$r_id.'"]/parent::*';
44 | $res = $xml->xpath($xpath);
45 | $parent = $res[0];
46 | if($parent[0]->status == "OFF"){
47 | echo "0";
48 | }elseif($parent[0]->status == "ON"){
49 | echo "1";
50 | }
51 | exit();
52 | }
53 | }
54 | if (isset($_POST['todo'])) {
55 | if ($_POST['todo'] == "sendmilight" || $_POST['todo'] == "sendmilightrgbcct") {
56 | $r_MLid = (string)$_POST['id'];
57 | $r_MLcmd = (string)$_POST['command'];
58 | $r_MLval = (string)$_POST['value'];
59 | }
60 | }
61 |
62 | // Über Timerfunktion -> GET
63 | if (isset($_GET['timerrun'])) {
64 | require("send_msg.php");
65 | require("timer.php");
66 | include("countdowntimer.php");
67 | if ($xml->global->timerGlobalRun != "false" && $xml->global->AlertState != "red") timer_check();
68 | ping_check();
69 | if ($xml->global->AlertState != "red") countdowntimer_check();
70 | fbdect_check();
71 | exit();
72 | }
73 |
74 | if (isset($r_action)) {
75 | debug("Running in action='".$r_action."'");
76 |
77 | require("send_msg.php");
78 |
79 | if (($r_action)=="alloff") {
80 | foreach($xml->devices->device as $device) {
81 | send_message($device, "OFF");
82 | usleep($multiDeviceSleep);
83 | }
84 | //echo str_replace("\n","
",$errormessage);
85 | echo $errormessage;
86 |
87 | } else if (($r_action)=="allon") {
88 | foreach($xml->devices->device as $device) {
89 | send_message($device, "ON");
90 | usleep($multiDeviceSleep);
91 | }
92 | //echo str_replace("\n","
",$errormessage);
93 | echo $errormessage;
94 |
95 | } else {
96 | if (($r_action)=="on") {
97 | $action="ON";
98 | }else {
99 | $action="OFF";
100 | }
101 |
102 | if (($r_type)=="device") {
103 | send_message_device($r_id, $action);
104 |
105 | } else if (($r_type)=="room") {
106 | send_message_room($r_id, $action);
107 |
108 | } else if (($r_type)=="group") {
109 | send_message_group($r_id, $action);
110 |
111 | } else if (($r_type)=="action") {
112 | $actionsFound = $xml->xpath("//actions/action/id[text()='".$r_id."']/parent::*");
113 | foreach($actionsFound[0]->do as $do) {
114 | debug("Action: type:".$do['type']." id:".$do['id']." action:".$do['action']);
115 | switch ($do['type']) {
116 | case "device":
117 | send_message_device($do['id'], $do['action'], TRUE, $do['mode'], $do['color'], $do['brightness'], $actionsFound[0]->name);
118 | usleep($multiDeviceSleep);
119 | break;
120 | case "room":
121 | send_message_room($do['id'], $do['action'], TRUE, $actionsFound[0]->name);
122 | break;
123 | case "group":
124 | send_message_group($do['id'], strtoupper($do['action']), TRUE, $actionsFound[0]->name);
125 | break;
126 | case "wait":
127 | debug("Action: Schlafe jetzt ".$do['id']." Sekunden");
128 | sleep(intval($do['id']));
129 | debug("Action: Wieder wach!");
130 | break;
131 | }
132 | }
133 | } else if (($r_type)=="timerglobalrun") {
134 | if ($action == "ON") {
135 | if ($xml->global->timerGlobalRun == "true") $errormessage = "FEHLER: Globaler Timer ist bereits aktiviert!";
136 | else { $xml->global->timerGlobalRun = "true"; $errormessage = "Globaler Timer wurde aktiviert!"; LogToBackend('info','Global Timer ENABLED','false',false,false); }
137 | }
138 | else if ($action == "OFF") {
139 | if ($xml->global->timerGlobalRun == "false") $errormessage = "FEHLER: Globaler Timer ist bereits deaktiviert!";
140 | else { $xml->global->timerGlobalRun = "false"; $errormessage = "Globaler Timer wurde deaktiviert!"; LogToBackend('info','Global Timer DISABLED','false',false,false); }
141 | }
142 | } else if (($r_type)=="alertstate") {
143 | if ($action == "ON") {
144 | if ($xml->global->AlertState == "red") $errormessage = "FEHLER: System-Alarm wurde bereits ausgelöst!";
145 | else { $xml->global->AlertState = "red"; $errormessage = "System-Alarm wurde ausgelöst!"; async_curl('http://localhost'.str_replace('index.php', 'redalert.php', $_SERVER[PHP_SELF])); LogToBackend('info','System-Alert TRIGGERED','false',false,false); }
146 | }
147 | else if ($action == "OFF") {
148 | if ($xml->global->AlertState == "green") $errormessage = "FEHLER: System-Alarm wurde bereits aufgehoben!";
149 | else { $xml->global->AlertState = "green"; $errormessage = "System-Alarm wurde aufgehoben!"; LogToBackend('info','System-Alert DISABLED','false',false,false); }
150 | }
151 | }
152 | //echo str_replace("\n","
",$errormessage);
153 | echo $errormessage;
154 | }
155 | config_save();
156 | }
157 | elseif (isset($r_MLcmd)) {
158 | require("send_msg.php");
159 | debug("Executing MiLight-Command '".$r_MLcmd."' for Device-ID '".$r_MLid."'");
160 | if ($_POST['todo'] == "sendmilight" ) {
161 | echo toggle_milight($r_MLid,$r_MLcmd,$r_MLval);
162 | } elseif ($_POST['todo'] == "sendmilightrgbcct") {
163 | echo toggle_fbmilighthub($r_MLid,$r_MLcmd,$r_MLval,"rgb_cct");
164 | }
165 | config_save();
166 | }
167 | else {
168 | debug("Sending HTML Site");
169 | require("gui.php");
170 | }
171 | //debug("END");
172 | ?>
173 |
--------------------------------------------------------------------------------
/includes/incl_functions.php:
--------------------------------------------------------------------------------
1 | 100) return $MilightRgbcctMinKelvin;
7 | global $MilightRgbcctMinKelvin,$MilightRgbcctMaxKelvin;
8 | $Diff = $MilightRgbcctMaxKelvin - $MilightRgbcctMinKelvin;
9 | $KelvinPerPercent = $Diff / 100;
10 | $val = $KelvinPerPercent * $percent;
11 | return $MilightRgbcctMaxKelvin - $val;
12 | }
13 | function colorHEXtoRGB($hex) {
14 | list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
15 | return array("R"=>$r, "G"=>$g, "B"=>$b);
16 | }
17 | function compareDevicesByName($a, $b) {
18 | return strcmp($a->name,$b->name);
19 | }
20 | function compareDevicesByID($a, $b) {
21 | return strcmp($a->id,$b->id);
22 | }
23 | function compareDevicesByRoom($a, $b) {
24 | return strcmp($a->room,$b->room);
25 | }
26 | function compareGroupsByName($a, $b) {
27 | return strcmp($a->name,$b->name);
28 | }
29 | function compareGroupsByID($a, $b) {
30 | return strcmp($a->id,$b->id);
31 | }
32 | function compareTimersByTypeAndName($a, $b) {
33 | global $xml;
34 | switch($a->type) {
35 | case "device":
36 | $devicesFound = $xml->xpath("//devices/device/id[text()='".$a->typeid."']/parent::*");
37 | $deviceA = $devicesFound[0];
38 | $nameA = $deviceA->name;
39 | break;
40 | case "group":
41 | $groupsFound = $xml->xpath("//groups/group/id[text()='".$a->typeid."']/parent::*");
42 | $groupA = $groupsFound[0];
43 | $nameA = $groupA->name;
44 | break;
45 | case "room":
46 | $nameA = $a->typeid;
47 | break;
48 | default:
49 | $nameA = $a->id;
50 | break;
51 | }
52 | switch($b->type) {
53 | case "device":
54 | $devicesFound = $xml->xpath("//devices/device/id[text()='".$b->typeid."']/parent::*");
55 | $deviceB = $devicesFound[0];
56 | $nameB = $deviceB->name;
57 | break;
58 | case "group":
59 | $groupsFound = $xml->xpath("//groups/group/id[text()='".$b->typeid."']/parent::*");
60 | $groupB = $groupsFound[0];
61 | $nameB = $groupB->name;
62 | break;
63 | case "room":
64 | $nameB = $b->typeid;
65 | break;
66 | default:
67 | $nameB = $b->id;
68 | break;
69 | }
70 | return strcmp($nameA,$nameB);
71 | }
72 | function compareTimersByID($a, $b) {
73 | return strcmp($a->id,$b->id);
74 | }
75 | function compareTimersByType($a, $b) {
76 | $cmp = strcmp($a->type,$b->type);
77 | if($cmp == 0) {
78 | $cmp = compareTimersByName($a, $b);
79 | }
80 | return $cmp;
81 | }
82 | function compareTimersByName($a, $b) {
83 | return strcmp($a->name,$b->name);
84 | }
85 |
86 | function send_message_device($deviceid, $action, $ViaTimer = FALSE, $MLMode = "", $MLColor = "", $MLBrightness = "", $ViaAction = FALSE) {
87 | global $xml;
88 | $devicesFound = $xml->xpath("//devices/device/id[text()='".$deviceid."']/parent::*");
89 | $device = $devicesFound[0];
90 | send_message($device, strtoupper($action), $ViaTimer, $MLMode, $MLColor, $MLBrightness, $ViaAction);
91 | }
92 |
93 | function send_message_room($room, $action, $ViaTimer = FALSE, $ViaAction = FALSE) {
94 | global $xml;
95 | global $multiDeviceSleep;
96 | $devicesFound = $xml->xpath("//devices/device/room[text()='".$room."']/parent::*");
97 | foreach($devicesFound as $device) {
98 | send_message($device, strtoupper($action), $ViaTimer, "", "", "", $ViaAction);
99 | usleep($multiDeviceSleep);
100 | }
101 | }
102 |
103 | function send_message_group($groupid, $action, $ViaTimer = FALSE, $ViaAction = FALSE) {
104 | global $xml;
105 | global $multiDeviceSleep;
106 | $groupsFound = $xml->xpath("//groups/group/id[text()='".$groupid."']/parent::*");
107 | foreach($groupsFound[0]->deviceid as $deviceid) {
108 | $devicesFound = $xml->xpath("//devices/device/id[text()='".$deviceid."']/parent::*");
109 | $device = $devicesFound[0];
110 | if($action == "ON") {
111 | if(empty($deviceid['onaction'])) {
112 | send_message($device, strtoupper($action), $ViaTimer, "", "", "", $ViaAction);
113 | } else {
114 | switch ($deviceid['onaction']) {
115 | case "on":
116 | send_message($device, "ON", $ViaTimer, "", "", "", $ViaAction);
117 | break;
118 | case "off":
119 | send_message($device, "OFF", $ViaTimer, "", "", "", $ViaAction);
120 | break;
121 | case "none":
122 | break;
123 | }
124 | }
125 | } else if($action == "OFF") {
126 | if(empty($deviceid['offaction'])) {
127 | send_message($device, strtoupper($action), $ViaTimer, "", "", "", $ViaAction);
128 | } else {
129 | switch ($deviceid['offaction']) {
130 | case "on":
131 | send_message($device, "ON", $ViaTimer, "", "", "", $ViaAction);
132 | break;
133 | case "off":
134 | send_message($device, "OFF", $ViaTimer, "", "", "", $ViaAction);
135 | break;
136 | case "none":
137 | break;
138 | }
139 | }
140 | }
141 | usleep($multiDeviceSleep);
142 | }
143 | }
144 |
145 | function LogToBackend($type,$logtext,$WAnotify,$ViaTimer,$ViaAction) {
146 | global $xml,$active_user;
147 | $FBnet_BEurl = $xml->backend->url;
148 | $FBnet_SIDsource = $xml->backend->sidsource;
149 |
150 | if ($FBnet_BEurl != "" && $FBnet_SIDsource != "" && $xml->backend->logging == "true") {
151 | $SID = file_get_contents($FBnet_SIDsource);
152 | $TextToLog = $logtext;
153 | if ($ViaTimer == TRUE && $ViaAction == FALSE) {
154 | $TextToLog .= " from TIMER";
155 | }
156 | elseif ($ViaTimer == TRUE && $ViaAction == TRUE) {
157 | $TextToLog .= " from ACTION ".$ViaAction."@";
158 | if ($active_user != "false") $TextToLog .= $active_user->name;
159 | else $TextToLog .= $xml->persons->person->name;
160 | }
161 | else {
162 | if ($active_user != "false") $TextToLog .= " from ".$active_user->name;
163 | else $TextToLog .= " from ".$xml->persons->person->name;
164 | }
165 | $task="LogAction";$params=$xml->global->FBnetDeviceID."|".$type."|".urlencode($TextToLog)."|".$WAnotify;
166 |
167 | $ret = file_get_contents($FBnet_BEurl."?task=".$task."&sid=".$SID."¶ms=".$params);
168 | if ($ret === FALSE) $ret = "Backend unreachable!";
169 | if (strpos($ret,'#OK#') !== FALSE) return(TRUE);
170 | else return($ret);
171 | }
172 | else return('Disabled');
173 | }
174 |
175 | function async_curl($background_process=''){
176 | $ch = curl_init($background_process);
177 | curl_setopt_array($ch, array(
178 | CURLOPT_HEADER => 0,
179 | CURLOPT_RETURNTRANSFER =>true,
180 | CURLOPT_NOSIGNAL => 1, //to timeout immediately if the value is < 1000 ms
181 | CURLOPT_TIMEOUT_MS => 50, //The maximum number of mseconds to allow cURL functions to execute
182 | CURLOPT_VERBOSE => 1,
183 | CURLOPT_HEADER => 1
184 | ));
185 | $out = curl_exec($ch);
186 | curl_close($ch);
187 | return true;
188 | }
189 | ?>
--------------------------------------------------------------------------------
/edit_timer.php:
--------------------------------------------------------------------------------
1 | 23) {
72 | echo "Falsche Stunden";
73 | exit;
74 | }
75 | $onMM=$_POST['OnTimerMM'];
76 | if($onHH<0 && $onHH>59) {
77 | echo "Falsche Minuten";
78 | exit;
79 | }
80 | $timerOn = $onHH.':'.$onMM;
81 | break;
82 |
83 | case "SU":
84 | case "SD":
85 | $timerOn = (string)$_POST['OnTimerType'];
86 | break;
87 |
88 | default:
89 | case "M":
90 | $timerOn = "";
91 | break;
92 | }
93 | $r_timeronoffset=intval($_POST['timeronoffset']);
94 | switch($_POST['OffTimerType']) {
95 | case "A":
96 | $offHH=$_POST['OffTimerHH'];
97 | if($offHH<0 && $offHH>23) {
98 | echo "Falsche Stunden";
99 | exit;
100 | }
101 | $offMM=$_POST['OffTimerMM'];
102 | if($offHH<0 && $offHH>59) {
103 | echo "Falsche Minuten";
104 | exit;
105 | }
106 | $timerOff = $offHH.':'.$offMM;
107 | break;
108 |
109 | case "SU":
110 | case "SD":
111 | $timerOff = (string)$_POST['OffTimerType'];
112 | break;
113 |
114 | default:
115 | case "M":
116 | $timerOff = "";
117 | break;
118 | }
119 | $r_timeroffoffset=intval($_POST['timeroffoffset']);
120 |
121 | $newid=1;
122 | foreach($xml->timers->timer as $timer) {
123 | $oldid=(integer)$timer->id;
124 | if($oldid >= $newid) {
125 | $newid = $oldid + 1;
126 | }
127 | }
128 | $newtimer = $xml->timers->addChild('timer');
129 | $newtimer->addChild('id', $newid);
130 | $newtimer->addChild('active', $r_active);
131 | $newtimer->addChild('type', $r_type);
132 | $newtimer->addChild('typeid', $typeid);
133 | $newtimer->addChild('day', $day);
134 | $newtimer->addChild('pingstatus', $r_pingstatus);
135 | $newtimer->addChild('invertSwitchOnNoPing', $r_invertSwitchOnNoPing);
136 | $newtimer->addChild('usage', $r_usage);
137 | $newtimer->addChild('pingto', $r_pingto);
138 |
139 | $timerOnXml=$newtimer->addChild('timerOn', $timerOn);
140 | if(!empty($r_timeronoffset)) {
141 | $timerOnXml->addAttribute('offset', $r_timeronoffset);
142 | }
143 | $timerOffXml=$newtimer->addChild('timerOff', $timerOff);
144 | if(!empty($r_timeroffoffset)) {
145 | $timerOffXml->addAttribute('offset', $r_timeroffoffset);
146 | }
147 |
148 | if(check_timer($newtimer)) {
149 | echo "ok";
150 | config_save();
151 | }
152 |
153 | break;
154 |
155 | case "edit":
156 |
157 | $r_active = (string)$_POST['active'];
158 | $r_type = (string)$_POST['timertype'];
159 | $r_pingstatus = (string)$_POST['pingstatus'];
160 | $r_invertSwitchOnNoPing = (string)$_POST['invertSwitchOnNoPing'];
161 | $r_usage = (string)$_POST['usage'];
162 | $r_pingto = (string)$_POST['pingto'];
163 |
164 | switch($_POST['timertype']) {
165 | case "device":
166 | $typeid = (string)$_POST['typeiddevice'];
167 | break;
168 |
169 | case "group":
170 | $typeid = (string)$_POST['typeidgroup'];
171 | break;
172 |
173 | case "room":
174 | $typeid = (string)$_POST['typeidroom'];
175 | break;
176 |
177 | default:
178 | echo "Ungültiger Typer Typ!";
179 | exit;
180 | }
181 |
182 | $day = '_______';
183 | foreach ($_POST['timerday'] as $keyday) {
184 | switch($keyday) {
185 | case 0:
186 | $day[$keyday]='M';
187 | break;
188 | case 1:
189 | $day[$keyday]='D';
190 | break;
191 | case 2:
192 | $day[$keyday]='M';
193 | break;
194 | case 3:
195 | $day[$keyday]='D';
196 | break;
197 | case 4:
198 | $day[$keyday]='F';
199 | break;
200 | case 5:
201 | $day[$keyday]='S';
202 | break;
203 | case 6:
204 | $day[$keyday]='S';
205 | break;
206 | }
207 | }
208 |
209 | switch($_POST['OnTimerType']) {
210 | case "A":
211 | $onHH=$_POST['OnTimerHH'];
212 | if($onHH<0 && $onHH>23) {
213 | echo "Falsche Stunden";
214 | exit;
215 | }
216 | $onMM=$_POST['OnTimerMM'];
217 | if($onHH<0 && $onHH>59) {
218 | echo "Falsche Minuten";
219 | exit;
220 | }
221 | $timerOn = $onHH.':'.$onMM;
222 | break;
223 |
224 | case "SU":
225 | case "SD":
226 | $timerOn = (string)$_POST['OnTimerType'];
227 | break;
228 |
229 | default:
230 | case "M":
231 | $timerOn = "";
232 | break;
233 | }
234 | $r_timeronoffset=intval($_POST['timeronoffset']);
235 | switch($_POST['OffTimerType']) {
236 | case "A":
237 | $offHH=$_POST['OffTimerHH'];
238 | if($offHH<0 && $offHH>23) {
239 | echo "Falsche Stunden";
240 | exit;
241 | }
242 | $offMM=$_POST['OffTimerMM'];
243 | if($offHH<0 && $offHH>59) {
244 | echo "Falsche Minuten";
245 | exit;
246 | }
247 | $timerOff = $offHH.':'.$offMM;
248 | break;
249 |
250 | case "SU":
251 | case "SD":
252 | $timerOff = (string)$_POST['OffTimerType'];
253 | break;
254 |
255 | default:
256 | case "M":
257 | $timerOff = "";
258 | break;
259 | }
260 | $r_timeroffoffset=intval($_POST['timeroffoffset']);
261 |
262 |
263 | $xpath='//timer/id[.="'.$r_id.'"]/parent::*';
264 | $res = $xml->xpath($xpath);
265 | $parent = $res[0];
266 | $parent[0]->active = $r_active;
267 | $parent[0]->type = $r_type;
268 | $parent[0]->typeid = $typeid;
269 | $parent[0]->day = $day;
270 | $parent[0]->pingstatus = $r_pingstatus;
271 | $parent[0]->invertSwitchOnNoPing = $r_invertSwitchOnNoPing;
272 | $parent[0]->usage = $r_usage;
273 | $parent[0]->pingto = $r_pingto;
274 | $parent[0]->timerOn = $timerOn;
275 | if(!empty($r_timeronoffset)) {
276 | //$timerOnXml->addAttribute('offset', $r_timeronoffset);
277 | $parent[0]->timerOn['offset'] = $r_timeronoffset;
278 | }else{
279 | unset($parent[0]->timerOn['offset']);
280 | }
281 | $parent[0]->timerOff = $timerOff;
282 | if(!empty($r_timeroffoffset)) {
283 | $parent[0]->timerOff['offset'] = $r_timeroffoffset;
284 | }else{
285 | unset($parent[0]->timerOff['offset']);
286 | }
287 |
288 | echo "ok";
289 | $dom = new DOMDocument('1.0');
290 | $dom->preserveWhiteSpace = false;
291 | $dom->formatOutput = true;
292 | $dom->loadXML($xml->asXML());
293 | $dom->save($CONFIG_FILENAME);
294 |
295 | break;
296 |
297 | case "on":
298 | $xpath='//timer/id[.="'.$r_id.'"]/parent::*';
299 | $res = $xml->xpath($xpath);
300 | $parent = $res[0];
301 | $parent[0]->active="on";
302 | echo "ok";
303 | config_save();
304 | break;
305 |
306 | case "off":
307 | $xpath='//timer/id[.="'.$r_id.'"]/parent::*';
308 | $res = $xml->xpath($xpath);
309 | $parent = $res[0];
310 | $parent[0]->active="off";
311 | echo "ok";
312 | config_save();
313 | break;
314 |
315 | case "delete":
316 | $xpath='//timer/id[.="'.$r_id.'"]/parent::*';
317 | $res = $xml->xpath($xpath);
318 | $parent = $res[0];
319 | unset($parent[0]);
320 | echo "ok";
321 | config_save();
322 | break;
323 |
324 | default:
325 | echo "unsupported";
326 | break;
327 | }
328 | ?>
329 |
--------------------------------------------------------------------------------
/includes/incl_groups.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Favoriten
6 |
7 | Geräte
8 | gui->showGroupsBtnInMenu == "true") { ?> Gruppen
9 | gui->showRoomsBtnInMenu == "true") { ?> Räume
10 | gui->showTimerBtnInMenu == "true") { ?> Timer
11 | gui->showActionBtnInMenu == "true") { ?> Aktionen
12 | Einstellungen
13 |
14 | gui->showAllOnOffBtnInMenu == "true") { ?>
15 |
16 |
17 |
18 |
19 |
20 |
21 | Schliessen
22 |
23 |
24 |
25 |
26 |
27 |
Gruppen
28 |
33 |
34 |
35 |
36 |
37 | - Favoriten
38 | - Geräte
39 | gui->showGroupsBtnInMenu == "true") { ?> - Gruppen
40 | gui->showRoomsBtnInMenu == "true") { ?> - Räume
41 | gui->showTimerBtnInMenu == "true") { ?> - Timer
42 | gui->showActionBtnInMenu == "true") { ?> - Aktionen
43 | - Konfig
44 |
45 |
46 |
47 |
48 |
49 |
50 | -
51 |
56 |
57 | - background-color:#B63737;-moz-border-radius:.5em;-webkit-border-radius:.5em;border-radius:.5em;">
58 |
63 |
64 | -
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | groups->group as $group) {
77 | $groups[] = $group;
78 | }
79 | switch ($xml->gui->sortOrderGroups){
80 | case "SORT_BY_NAME":
81 | usort($groups, "compareGroupsByName");
82 | break;
83 | case "SORT_BY_ID":
84 | usort($groups, "compareGroupsByID");
85 | break;
86 | default:
87 | break;
88 | }
89 | foreach($groups as $group) {
90 | ?>
91 |
92 | -
93 |
94 |
95 |
name; ?>
96 | deviceid as $deviceid) {
98 | $devicesFound = $xml->xpath("//devices/device/id[text()='".$deviceid."']/parent::*");
99 | $device = $devicesFound[0];
100 | $text = $device->name;
101 | if(!empty($deviceid['onaction'])) {
102 | if($deviceid['onaction'] == "on") {
103 | $text = $text."
[ on ]";
104 | } else if($deviceid['onaction'] == "off") {
105 | $text = $text."
[ off ]";
106 | } else if($deviceid['onaction'] == "none") {
107 | $text = $text."
[ none ]";
108 | }
109 | }
110 | if(!empty($deviceid['offaction'])) {
111 | if($deviceid['offaction'] == "on") {
112 | $text = $text."
[ on ]";
113 | } else if($deviceid['offaction'] == "off") {
114 | $text = $text."
[ off ]";
115 | } else if($deviceid['offaction'] == "none") {
116 | $text = $text."
[ none ]";
117 | }
118 | }
119 | echo "
".$text."
";
120 | }
121 | ?>
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
139 |
140 |
141 |
142 |
143 |
--------------------------------------------------------------------------------
/includes/incl_settings_design.php:
--------------------------------------------------------------------------------
1 |
126 |
--------------------------------------------------------------------------------
/fritzbox.inc.php:
--------------------------------------------------------------------------------
1 | backend->url;
11 | if ($FBnet_BEurl != "") {
12 | if ($wert == 1) $SV = 0;
13 | elseif ($wert == 0) $SV = 1;
14 | $task="ToggleActor";$params=$deviceain."|".$SV."|".$xml->global->FBnetDeviceID."|FALSE";
15 | debug("Fritzbox_DECT200 (via BE-Call): ".$params);
16 |
17 | $ret = file_get_contents($FBnet_BEurl."?task=".$task."&sid=".$SID."¶ms=".$params);
18 | if ($ret === FALSE) $ret = "Backend unreachable!";
19 | if (strpos($ret,'#OK#') !== FALSE) return($wert);
20 | else return($ret);
21 | }
22 | else {
23 | $fritzbox_address = $xml->fritzbox->address;
24 | $SwitchCMD="";
25 | if ($wert == 1) $SwitchCMD="setswitchon";
26 | elseif ($wert == 0) $SwitchCMD="setswitchoff";
27 |
28 | debug("Fritzbox_DECT200 (via Direct-Call): ".$SID);
29 | if($SID <> "Fehler: Login fehlgeschlagen" && $SID != "") {
30 | $Value=Fritzbox_GetSetHAactor($fritzbox_address,$SwitchCMD,$SID,$deviceain);
31 | } else {
32 | $Value=$SID;
33 | }
34 | return($Value);
35 | }
36 | }
37 |
38 | /* function Fritzbox_DECT200_Energie($deviceid, $Zeit) {
39 | global $xml;
40 | $fritzbox_address = $xml->fritzbox->address;
41 | $Daten="";
42 | $SID=Fritzbox_login();
43 | if ($SID <> "Fehler: Login fehlgeschlagen") {
44 | switch($Zeit) {
45 | case 1: // Abfrage der Messwerte der letzten 10 min
46 | $Daten= file("http://".$fritzbox_address."/net/home_auto_query.lua?sid=". $SID. "&command=EnergyStats_10&id=". $deviceid. "&xhr=1");
47 | break;
48 | case 2: // Abfrage der Messwerte der letzten 24h
49 | $Daten= file("http://".$fritzbox_address."/net/home_auto_query.lua?sid=". $SID. "&command=EnergyStats_24h&id=". $deviceid. "&xhr=1");
50 | break;
51 | }
52 | if($Daten <>"") {
53 | $Daten=explode('" , "', $Daten[1]);
54 | $x=count($Daten)-1;
55 | $temp=explode('" ,"', $Daten[$x]);
56 | foreach ($temp as $tem) {
57 | $Daten[$x]=$tem;
58 | $x++;
59 | }
60 | } else {
61 | $Daten[0]="Keine Werte vorhanden";
62 | }
63 | return ($Daten);
64 | }
65 | } */
66 |
67 | function Fritzbox_GetHAactorsInfoXML()
68 | {
69 | global $xml;
70 | $SID=Fritzbox_login();
71 | $fritzbox_address = $xml->fritzbox->address;
72 |
73 | $URL = "http://".$fritzbox_address."/webservices/homeautoswitch.lua?switchcmd=".urlencode('getdevicelistinfos')."&sid=".urlencode($SID);
74 | $ret = file_get_contents($URL);
75 | if (trim($ret) == "inval" || $ret === FALSE || $ret == "") $ret = "-1";
76 | return trim($ret);
77 | }
78 |
79 | function Fritzbox_GetHAactorDataFromXML($XML,$ain,$mode)
80 | {
81 | $FBdectVal=-1000;
82 | if ($XML == -1) return $FBdectVal;
83 |
84 | $FBdevices = new SimpleXMLElement($XML);
85 | if ($mode == "id") {
86 | foreach ($FBdevices->device as $devices) {
87 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
88 | $FBdectVal=(int)$devices['id'][0];
89 | }
90 | }
91 | } elseif ($mode == "fwversion") {
92 | foreach ($FBdevices->device as $devices) {
93 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
94 | $FBdectVal=$devices['fwversion'][0];
95 | }
96 | }
97 | } elseif ($mode == "manufacturer") {
98 | foreach ($FBdevices->device as $devices) {
99 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
100 | $FBdectVal=$devices['manufacturer'][0];
101 | }
102 | }
103 | } elseif ($mode == "productname") {
104 | foreach ($FBdevices->device as $devices) {
105 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
106 | $FBdectVal=$devices['productname'][0];
107 | }
108 | }
109 | } elseif ($mode == "present") {
110 | foreach ($FBdevices->device as $devices) {
111 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
112 | $FBdectVal=(int)$devices->present[0];
113 | }
114 | }
115 | } elseif ($mode == "name") {
116 | foreach ($FBdevices->device as $devices) {
117 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
118 | $FBdectVal=$devices->name[0];
119 | }
120 | }
121 | } elseif ($mode == "state") {
122 | foreach ($FBdevices->device as $devices) {
123 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
124 | $FBdectVal=(int)$devices->switch->state[0];
125 | }
126 | }
127 | } elseif ($mode == "lock") {
128 | foreach ($FBdevices->device as $devices) {
129 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
130 | $FBdectVal=(int)$devices->switch->lock[0];
131 | }
132 | }
133 | } elseif ($mode == "power") {
134 | foreach ($FBdevices->device as $devices) {
135 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
136 | $FBdectVal=(int)$devices->powermeter->power[0];
137 | }
138 | }
139 | } elseif ($mode == "energy") {
140 | foreach ($FBdevices->device as $devices) {
141 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
142 | $FBdectVal=(int)$devices->powermeter->energy[0];
143 | }
144 | }
145 | } elseif ($mode == "temperature") {
146 | foreach ($FBdevices->device as $devices) {
147 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
148 | $FBdectVal=(int)$devices->temperature->celsius[0];
149 | }
150 | }
151 | } elseif ($mode == "tempoffset") {
152 | foreach ($FBdevices->device as $devices) {
153 | if (str_replace(" ", "", $devices['identifier'][0]) == $ain) {
154 | $FBdectVal=(int)$devices->temperature->offset[0];
155 | }
156 | }
157 | }
158 |
159 | unset($FBdevices);
160 | return trim($FBdectVal);
161 | }
162 |
163 | function Fritzbox_DECT200_Energie($deviceAIN) {
164 | global $xml;
165 | $SID=Fritzbox_login();
166 | $fritzbox_address = $xml->fritzbox->address;
167 | $SwitchCMD="getswitchenergy";
168 |
169 | if($SID <> "Fehler: Login fehlgeschlagen" && $SID != "") {
170 | $Value=Fritzbox_GetSetHAactor($fritzbox_address,$SwitchCMD,$SID,$deviceAIN);
171 | } else {
172 | $Value=$SID;
173 | }
174 | return($Value);
175 | }
176 |
177 | function Fritzbox_DECT200_Power($deviceAIN) {
178 | global $xml;
179 | $SID=Fritzbox_login();
180 | $fritzbox_address = $xml->fritzbox->address;
181 | $SwitchCMD="getswitchpower";
182 |
183 | if($SID <> "Fehler: Login fehlgeschlagen" && $SID != "") {
184 | $Value=Fritzbox_GetSetHAactor($fritzbox_address,$SwitchCMD,$SID,$deviceAIN);
185 | } else {
186 | $Value=$SID;
187 | }
188 | return($Value);
189 | }
190 |
191 | function Fritzbox_DECT200_SwitchState($deviceAIN) {
192 | global $xml;
193 | $SID=Fritzbox_login();
194 | $fritzbox_address = $xml->fritzbox->address;
195 | $SwitchCMD="getswitchstate";
196 |
197 | if($SID <> "Fehler: Login fehlgeschlagen" && $SID != "") {
198 | $Value=Fritzbox_GetSetHAactor($fritzbox_address,$SwitchCMD,$SID,$deviceAIN);
199 | } else {
200 | $Value=$SID;
201 | }
202 | return($Value);
203 | }
204 |
205 | function Fritzbox_login() {
206 | global $xml;
207 | $FBnet_SIDsource = $xml->backend->sidsource;
208 |
209 | if ($FBnet_SIDsource != "") {
210 | $SID = file_get_contents($FBnet_SIDsource);
211 | return $SID;
212 | }
213 | else {
214 | $fritzbox_address = $xml->fritzbox->address;
215 | $fritzbox_username = $xml->fritzbox->username;
216 | $fritzbox_password = $xml->fritzbox->password;
217 |
218 | $ch = curl_init('http://'.$fritzbox_address.'/login_sid.lua');
219 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
220 | $login = curl_exec($ch);
221 | $session_status_simplexml = simplexml_load_string($login);
222 | if ($session_status_simplexml->SID != '0000000000000000') {
223 | $SID = $session_status_simplexml->SID;
224 | } else {
225 | $challenge = $session_status_simplexml->Challenge;
226 | $response = $challenge . '-' . md5(mb_convert_encoding($challenge . '-' . $fritzbox_password, "UCS-2LE", "UTF-8"));
227 | curl_setopt($ch, CURLOPT_POSTFIELDS, "response={$response}&page=/login_sid.lua&username={$fritzbox_username}");
228 | $sendlogin = curl_exec($ch);
229 | $session_status_simplexml = simplexml_load_string($sendlogin);
230 |
231 | if ($session_status_simplexml->SID != '0000000000000000') {
232 | $SID = $session_status_simplexml->SID;
233 | } else {
234 | $SID= "Fehler: Login fehlgeschlagen";
235 | }
236 | }
237 | curl_close($ch);
238 | return $SID;
239 | }
240 | }
241 |
242 | function Fritzbox_GetSetHAactor($host,$cmd,$sid,$ain)
243 | {
244 | $URL = "http://".$host."/webservices/homeautoswitch.lua?switchcmd=".urlencode($cmd)."&sid=".urlencode($sid);
245 | if ($ain != "") $URL .= "&ain=".urlencode($ain);
246 | $ret = file_get_contents($URL);
247 | if (trim($ret) == "inval") $ret = "-1";
248 | return trim($ret);
249 | }
250 | ?>
--------------------------------------------------------------------------------
/redalert_thread.php:
--------------------------------------------------------------------------------
1 | message;
28 | }
29 | exit(4);
30 | }
31 |
32 | // Abbrechen wenn AlertState NICHT red ist
33 | if ($xml->global->AlertState != "red") exit();
34 |
35 | // Bridge aus Config anhand der ID ermitteln
36 | $MiLightBridge = $xml->xpath("//milightwifis/milightwifi/id[text()='".$bid."']/parent::*");
37 | $MiLightBridge = $MiLightBridge[0];
38 |
39 | // IP der Bridge ermitteln
40 | $milightIP = trim((string)$MiLightBridge->address);
41 | if(!filter_var($milightIP, FILTER_VALIDATE_IP)) {
42 | $milightIPCheck = @gethostbyname(trim((string)$MiLightBridge->address));
43 | if($milightIP == $milightIPCheck) {
44 | //$msg="MiLight-Bridge ".$milightIP." is not availible. Check IP or Hostname. \n";
45 | //echo $msg;
46 | return;
47 | } else {
48 | $milightIP = $milightIPCheck;
49 | }
50 | }
51 |
52 | // Connect zur Bridge und alle Lampen der Bridge auf ROT:DUNKEL setzen
53 | $milight = new Milight($milightIP,(integer)$MiLightBridge->port);
54 | $milight->setRgbwActiveGroup(0);
55 | $milight->rgbwSetColorHexString("#FF0000");
56 | $milight->rgbwBrightnessPercent(40,0);
57 | sleep(1);
58 |
59 | // Zwischen hell und dunkel wechseln solange AlertState RED ist
60 | do {
61 | set_time_limit(30);
62 | //config.xml einlesen
63 | unset($xml);
64 | libxml_use_internal_errors(true);
65 | $xml = simplexml_load_file($CONFIG_FILENAME);
66 | if (!$xml) {
67 | //echo "Kann die Konfiguration (".$CONFIG_FILENAME.") nicht laden!\n";
68 | foreach(libxml_get_errors() as $error) {
69 | //echo "\t", $error->message;
70 | }
71 | exit(4);
72 | }
73 |
74 | $milight->setRgbwActiveGroup(0);
75 | $milight->rgbwBrightnessPercent(100,0);
76 | sleep(1);
77 |
78 | $milight->setRgbwActiveGroup(0);
79 | $milight->rgbwBrightnessPercent(40,0);
80 | sleep(2.5);
81 | } while ($xml->global->AlertState == "red");
82 | unset($milight);
83 |
84 |
85 | function switch_milight($device, $action) {
86 | global $xml;
87 |
88 | if($device->address->masterdip == "") {
89 | //echo "ERROR: masterdip (MiLight WiFi-Bridge-ID) ist ungültig für device id ".$device->id."\n";
90 | return;
91 | }
92 | if($device->address->slavedip == "") {
93 | //echo "ERROR: slavedip (Gruppe auf MiLight WiFi-Bridge) ist ungültig für device id ".$device->id."\n";
94 | return;
95 | }
96 | if($device->address->tx433version == "") {
97 | //echo "ERROR: tx433version (MiLight Lampentyp) ist ungültig für device id ".$device->id."\n";
98 | return;
99 | }
100 | if($device->address->slavedip < 0 || $device->address->slavedip > 4) {
101 | //echo "ERROR: slavedip (Gruppe auf MiLight WiFi-Bridge) muss zwischen 0-4 liegen für device id ".$device->id."\n";
102 | return;
103 | }
104 | if($device->address->tx433version < 1 || $device->address->tx433version > 2) {
105 | //echo "ERROR: tx433version (MiLight Lampentyp) muss zwischen 1-2 liegen für device id ".$device->id."\n";
106 | return;
107 | }
108 |
109 | $MiLightBridge = $xml->xpath("//milightwifis/milightwifi/id[text()='".$device->address->masterdip."']/parent::*");
110 | $MiLightBridge = $MiLightBridge[0];
111 |
112 | $milightIP = trim((string)$MiLightBridge->address);
113 | if(!filter_var($milightIP, FILTER_VALIDATE_IP)) {
114 | $milightIPCheck = @gethostbyname(trim((string)$MiLightBridge->address));
115 | if($milightIP == $milightIPCheck) {
116 | $msg="MiLight-Bridge ".$milightIP." is not availible. Check IP or Hostname. \n";
117 | //echo $msg;
118 | return;
119 | } else {
120 | $milightIP = $milightIPCheck;
121 | }
122 | }
123 |
124 | $BulbType="";$BulbCmd="";
125 | if ($device->address->tx433version == "1") $BulbType="WHITE";
126 | elseif ($device->address->tx433version == "2") $BulbType="RGBW";
127 |
128 | $milight = new Milight($milightIP,(integer)$MiLightBridge->port);
129 |
130 | if($action == "ON") {
131 | switch($BulbType){
132 | case "WHITE":
133 | $milight->whiteSendOnToGroup((integer)$device->address->slavedip);
134 | break;
135 | case "RGBW":
136 | if ($device->milight->mode != "Farbe" && $device->milight->mode != "Weiß" && $device->milight->mode != "Nacht") {
137 | $milight->rgbwSendOnToGroup((integer)$device->address->slavedip);
138 | }
139 | break;
140 | }
141 | }
142 | elseif($action == "OFF") {
143 | switch($BulbType){
144 | case "WHITE":
145 | $milight->whiteSendOffToGroup((integer)$device->address->slavedip);
146 | break;
147 | case "RGBW":
148 | $milight->rgbwSendOffToGroup((integer)$device->address->slavedip);
149 | break;
150 | }
151 | }
152 | unset($milight);
153 |
154 | //echo $device->name . " wurde geschaltet: ".$action."\n";
155 | return($action);
156 | }
157 |
158 | function toggle_milight($id, $cmd, $value) {
159 | global $xml;
160 | $DryMode = false;
161 |
162 | $device = $xml->xpath("//devices/device/id[text()='".$id."']/parent::*");
163 | $device = $device[0];
164 |
165 | if($device->address->masterdip == "") {
166 | //echo "ERROR: masterdip (MiLight WiFi-Bridge-ID) ist ungültig für device id ".$device->id."\n";
167 | return;
168 | }
169 | if($device->address->slavedip == "") {
170 | //echo "ERROR: slavedip (Gruppe auf MiLight WiFi-Bridge) ist ungültig für device id ".$device->id."\n";
171 | return;
172 | }
173 | if($device->address->tx433version == "") {
174 | //echo "ERROR: tx433version (MiLight Lampentyp) ist ungültig für device id ".$device->id."\n";
175 | return;
176 | }
177 | if($device->address->slavedip < 0 || $device->address->slavedip > 4) {
178 | //echo "ERROR: slavedip (Gruppe auf MiLight WiFi-Bridge) muss zwischen 0-4 liegen für device id ".$device->id."\n";
179 | return;
180 | }
181 | if($device->address->tx433version < 1 || $device->address->tx433version > 2) {
182 | //echo "ERROR: tx433version (MiLight Lampentyp) muss zwischen 1-2 liegen für device id ".$device->id."\n";
183 | return;
184 | }
185 |
186 | $MiLightBridge = $xml->xpath("//milightwifis/milightwifi/id[text()='".$device->address->masterdip."']/parent::*");
187 | $MiLightBridge = $MiLightBridge[0];
188 |
189 | $milightIP = trim((string)$MiLightBridge->address);
190 | if(!filter_var($milightIP, FILTER_VALIDATE_IP)) {
191 | $milightIPCheck = @gethostbyname(trim((string)$MiLightBridge->address));
192 | if($milightIP == $milightIPCheck) {
193 | $msg="MiLight-Bridge ".$milightIP." is not availible. Check IP or Hostname. \n";
194 | //echo $msg;
195 | return;
196 | } else {
197 | $milightIP = $milightIPCheck;
198 | }
199 | }
200 |
201 | $BulbType="";
202 | if ($device->address->tx433version == "1") $BulbType="WHITE";
203 | elseif ($device->address->tx433version == "2") $BulbType="RGBW";
204 |
205 | $milight = new Milight($milightIP,(integer)$MiLightBridge->port);
206 |
207 | switch($BulbType){
208 | case "WHITE":
209 | // NOCH NICHT IMPLEMENTIERT
210 | break;
211 | case "RGBW":
212 | if (!$DryMode) {
213 | $milight->setRgbwActiveGroup((integer)$device->address->slavedip);
214 |
215 | if ($cmd == "SetColor") {
216 | $milight->rgbwSetColorHexString(trim($value));
217 | $milight->rgbwBrightnessPercent((integer)$device->milight->brightnesscolor,(integer)$device->address->slavedip);
218 | }
219 | elseif ($cmd == "SetBrightness") {
220 | $milight->rgbwBrightnessPercent((integer)$value,(integer)$device->address->slavedip);
221 | }
222 | elseif ($cmd == "SetToWhite") {
223 | $milight->rgbwSetGroupToWhite((integer)$device->address->slavedip);
224 | $milight->rgbwBrightnessPercent((integer)$device->milight->brightnesswhite,(integer)$device->address->slavedip);
225 | }
226 | elseif ($cmd == "SetToNightMode") {
227 | $milight->rgbwSendOffToGroup((integer)$device->address->slavedip);
228 | $milight->command("rgbwGroup".(integer)$device->address->slavedip."NightMode");
229 | }
230 | elseif ($cmd == "rgbwDiscoMode" || $cmd == "rgbwDiscoSlower" || $cmd == "rgbwDiscoFaster") {
231 | if ($cmd == "rgbwDiscoMode" || $device->milight->mode == "Programm") {
232 | $milight->rgbwSendOnToActiveGroup();
233 | $milight->command(trim($cmd));
234 |
235 | if ($cmd == "rgbwDiscoMode") {
236 | sleep(1);
237 | $milight->setRgbwActiveGroup((integer)$device->address->slavedip);
238 | $milight->rgbwBrightnessPercent((integer)$device->milight->brightnessdisco,(integer)$device->address->slavedip);
239 | }
240 | }
241 | }
242 | }
243 | break;
244 | }
245 | unset($milight);
246 |
247 | //echo $device->name . " wurde geschaltet: ".$action." ";
248 | if (!$DryMode) return("#OK#");
249 | else return("#".$id."#".$cmd."#".$value."#");
250 | }
251 |
252 | sleep(0.25);
253 | foreach($xml->devices->device as $device) {
254 | if ($device->vendor == "milight" && (integer)$device->address->masterdip == (integer)$bid) {
255 | if ($device->status == "OFF") switch_milight($device,"OFF");
256 | elseif ($device->status == "ON") {
257 | switch_milight($device,"ON");
258 | sleep(0.2);
259 | if ($device->milight->mode == "Weiß") {
260 | $MR = toggle_milight($device->id,"SetToWhite",'');
261 | } elseif ($device->milight->mode == "Farbe") {
262 | $MR = toggle_milight($device->id,"SetColor",$device->milight->color);
263 | } elseif ($device->milight->mode == "Nacht") {
264 | $MR = toggle_milight($device->id,"SetToNightMode",'');
265 | } elseif ($device->milight->mode == "Programm") {
266 | switch_milight($device,"OFF");
267 | }
268 | }
269 |
270 | sleep(0.25);
271 | }
272 | }
273 | ?>
--------------------------------------------------------------------------------
/css/fbswitch.css:
--------------------------------------------------------------------------------
1 | #ms{
2 | position: fixed;
3 | left:-5%;
4 | top: 200px;
5 | -moz-transform:rotate(-90deg); /* Firefox 3.6 Firefox 4 */
6 | -webkit-transform:rotate(-90deg); /* Safari */
7 | -o-transform:rotate(-90deg); /* Opera */
8 | -ms-transform:rotate(-90deg); /* IE9 */
9 | transform:rotate(-90deg); /* W3C */
10 | }
11 | /* icon größe von der liste */
12 | .ui-li-thumb, .ui-li-icon {
13 | left: 1px;
14 | max-height: 32px;
15 | max-width: 32px;
16 | position: absolute;
17 | top: 0;
18 | }
19 |
20 | .ui-icon-on {
21 | background-image: url("app-icon-on.png");
22 | }
23 | .ui-icon-off {
24 | background-image: url("app-icon-off.png");
25 | }
26 |
27 | .hide {
28 | visibility:hidden;
29 | display:none;
30 | }
31 | .show {
32 | visibility:visible;
33 | display:inline;
34 | }
35 |
36 | @media (min-width:35em) {
37 |
38 | /* wrap on wide viewports once open */
39 |
40 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-display-push.ui-panel-content-fixed-toolbar-position-left,
41 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-display-reveal.ui-panel-content-fixed-toolbar-position-left,
42 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-left,
43 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-left {
44 | margin-right: 17em;
45 | }
46 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-display-push.ui-panel-content-fixed-toolbar-position-right,
47 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-display-reveal.ui-panel-content-fixed-toolbar-position-right,
48 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-right,
49 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-right {
50 | margin-left: 17em;
51 | }
52 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-display-push,
53 | .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-display-reveal {
54 | width: auto;
55 | }
56 |
57 | /* disable "dismiss" on wide viewports */
58 | .ui-responsive-panel .ui-panel-dismiss-display-push {
59 | display: none;
60 | }
61 |
62 | }
63 |
64 | .box-btn-switch .ui-btn, .box-btn-edit .ui-btn {
65 | height: 45px;
66 | min-width: 55px;
67 | max-width: 116px;
68 | margin: 0 auto;
69 | }
70 | .box-btn-edit .ui-btn-icon-notext .ui-btn-inner .ui-icon {
71 | position: absolute;
72 | left: 16px;
73 | right: 16px;
74 | top: 7px;
75 | }
76 |
77 | .box-btn-switch .ui-btn-corner-all, .box-btn-edit .ui-btn-corner-all, [data-role="header"] .ui-btn-corner-all, [data-role="panel"] .ui-btn-corner-all {
78 | -moz-border-radius: .5em;
79 | -webkit-border-radius: .5em;
80 | border-radius: .5em;
81 | }?
82 | .box-btn-hide {
83 | visibility:hidden;
84 | display:none;
85 | }
86 | .box-btn-show {
87 | visibility:visible;
88 | display:inline;
89 | }
90 |
91 | .box-btn-switch {
92 | /*display: block;
93 | white-space: nowrap;*/
94 | }
95 | .box-btn-edit {
96 | /*display: none;
97 | white-space: nowrap;*/
98 | }
99 |
100 | /*
101 | Zeilenumbruch in der Listview
102 | */
103 | .ui-page .ui-content .ui-listview .ui-li-heading {
104 | white-space: normal;
105 | }
106 | .ui-page .ui-content .ui-listview .ui-li-desc {
107 | white-space: normal;
108 | }
109 |
110 | @media (min-width:1100px) {
111 | #menubutton{
112 | display:none;
113 | }
114 | }
115 |
116 | #favoriteslinks {
117 | color: ffffff;
118 | display: block;
119 | text-decoration: none;
120 | }
121 |
122 | .user{
123 | position:fixed;
124 | top:78px;
125 | z-index:401;
126 | width: 1100px;
127 | display:block;
128 | }
129 | #countdown {
130 | color: ffffff;
131 | display: block;
132 | text-decoration: none;
133 | }
134 | select{
135 | // color: #f00;
136 | }
137 | // #minutes{
138 | // color: #00f;
139 | // }
140 | // #action{
141 | // color: #00f;
142 | // }
143 | // #device{
144 | // color: #00f;
145 | // }
146 |
147 | .loading-splash-div {
148 | position: fixed;
149 | left: 0px;
150 | top: 0px;
151 | width: 100%;
152 | height: 100%;
153 | z-index: 8999;
154 | background: center no-repeat #000000;
155 | overflow: hidden;
156 | }
157 |
158 | .loading-splash-container {
159 | position: absolute;
160 | top: 50%;
161 | margin-top: -170px;/* half of #content height*/
162 | left: 0;
163 | width: 100%;
164 | }
165 |
166 | .loading-splash {
167 | margin-right: auto;
168 | margin-left: auto;
169 | display: block;
170 | width: 250px;
171 | height: 340px;
172 | text-align: center
173 | }
174 |
175 | .ball {
176 | background-color: rgba(0,0,0,0);
177 | border:5px solid rgba(0,183,229,0.9);
178 | opacity:.9;
179 | border-top:5px solid rgba(0,0,0,0);
180 | border-left:5px solid rgba(0,0,0,0);
181 | border-radius:50px;
182 | box-shadow: 0 0 35px #2187e7;
183 | width:50px;
184 | height:50px;
185 | margin:0 auto;
186 | }
187 |
188 | .play-ball {
189 | -moz-animation:spin .8s infinite linear;
190 | -webkit-animation:spin .8s infinite linear;
191 | }
192 |
193 | .ball1 {
194 | background-color: rgba(0,0,0,0);
195 | border:5px solid rgba(0,183,229,0.9);
196 | opacity:.9;
197 | border-top:5px solid rgba(0,0,0,0);
198 | border-left:5px solid rgba(0,0,0,0);
199 | border-radius:50px;
200 | box-shadow: 0 0 15px #2187e7;
201 | width:30px;
202 | height:30px;
203 | margin:0 auto;
204 | position:relative;
205 | top:-50px;
206 | }
207 |
208 | .play-ball1 {
209 | -moz-animation:spinoff .8s infinite linear;
210 | -webkit-animation:spinoff .8s infinite linear;
211 | }
212 |
213 | @-moz-keyframes spin {
214 | 0% { -moz-transform:rotate(0deg); }
215 | 100% { -moz-transform:rotate(360deg); }
216 | }
217 | @-moz-keyframes spinoff {
218 | 0% { -moz-transform:rotate(0deg); }
219 | 100% { -moz-transform:rotate(-360deg); }
220 | }
221 | @-webkit-keyframes spin {
222 | 0% { -webkit-transform:rotate(0deg); }
223 | 100% { -webkit-transform:rotate(360deg); }
224 | }
225 | @-webkit-keyframes spinoff {
226 | 0% { -webkit-transform:rotate(0deg); }
227 | 100% { -webkit-transform:rotate(-360deg); }
228 | }
229 |
230 | .circle {
231 | background-color: rgba(0,0,0,0);
232 | border:5px solid rgba(234,224,156,0.9);
233 | opacity:.9;
234 | border-right:5px solid rgba(0,0,0,0);
235 | border-left:5px solid rgba(0,0,0,0);
236 | border-radius:50px;
237 | box-shadow: 0 0 35px #eae09c;
238 | width:50px;
239 | height:50px;
240 | margin:0 auto;
241 | }
242 |
243 | .play-circle {
244 | -moz-animation:spinPulse 1.2s infinite ease-in-out;
245 | -webkit-animation:spinPulse 1.2s infinite linear;
246 | }
247 |
248 | .circle1 {
249 | background-color: rgba(0,0,0,0);
250 | border:5px solid rgba(234,224,156,0.9);
251 | opacity:.9;
252 | border-left:5px solid rgba(0,0,0,0);
253 | border-right:5px solid rgba(0,0,0,0);
254 | border-radius:50px;
255 | box-shadow: 0 0 15px #eae09c;
256 | width:30px;
257 | height:30px;
258 | margin:0 auto;
259 | position:relative;
260 | top:-50px;
261 | }
262 |
263 | .play-circle1 {
264 | -moz-animation:spinoffPulse 1.2s infinite linear;
265 | -webkit-animation:spinoffPulse 1.2s infinite linear;
266 | }
267 |
268 | @-moz-keyframes spinPulse {
269 | 0% { -moz-transform:rotate(160deg); opacity:0; box-shadow:0 0 1px #eae09c;}
270 | 50% { -moz-transform:rotate(145deg); opacity:1; }
271 | 100% { -moz-transform:rotate(-320deg); opacity:0; }
272 | }
273 | @-moz-keyframes spinoffPulse {
274 | 0% { -moz-transform:rotate(0deg); }
275 | 100% { -moz-transform:rotate(360deg); }
276 | }
277 | @-webkit-keyframes spinPulse {
278 | 0% { -webkit-transform:rotate(160deg); opacity:0; box-shadow:0 0 1px #eae09c; }
279 | 50% { -webkit-transform:rotate(145deg); opacity:1;}
280 | 100% { -webkit-transform:rotate(-320deg); opacity:0; }
281 | }
282 | @-webkit-keyframes spinoffPulse {
283 | 0% { -webkit-transform:rotate(0deg); }
284 | 100% { -webkit-transform:rotate(360deg); }
285 | }
286 |
287 | #loader-wrapper {
288 | position: fixed;
289 | top: 0;
290 | left: 0;
291 | width: 100%;
292 | height: 100%;
293 | z-index: 9900;
294 | }
295 | #loader {
296 | display: block;
297 | position: fixed;
298 | left: 0;
299 | top: 0;
300 | width: 100%;
301 | height: 100%;
302 | z-index: 9999;
303 | }
304 |
305 | #loader-wrapper .loader-section {
306 | position: fixed;
307 | top: 0;
308 | width: 51%;
309 | height: 100%;
310 | background: #000000;
311 | z-index: 9900;
312 | }
313 |
314 | #loader-wrapper .loader-section.section-left {
315 | left: 0;
316 | }
317 |
318 | #loader-wrapper .loader-section.section-right {
319 | right: 0;
320 | }
321 |
322 | /* Loaded */
323 | .loaded #loader-wrapper .loader-section.section-left {
324 | -webkit-transform: translateX(-100%); /* Chrome, Opera 15+, Safari 3.1+ */
325 | -ms-transform: translateX(-100%); /* IE 9 */
326 | transform: translateX(-100%); /* Firefox 16+, IE 10+, Opera */
327 |
328 | -webkit-transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
329 | transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
330 | }
331 |
332 | .loaded #loader-wrapper .loader-section.section-right {
333 | -webkit-transform: translateX(100%); /* Chrome, Opera 15+, Safari 3.1+ */
334 | -ms-transform: translateX(100%); /* IE 9 */
335 | transform: translateX(100%); /* Firefox 16+, IE 10+, Opera */
336 |
337 | -webkit-transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
338 | transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
339 | }
340 |
341 | .loaded #loader {
342 | opacity: 0;
343 | -webkit-transition: all 0.3s ease-out;
344 | transition: all 0.3s ease-out;
345 | }
346 | .loaded #loader-wrapper {
347 | visibility: hidden;
348 |
349 | -webkit-transform: translateY(-100%); /* Chrome, Opera 15+, Safari 3.1+ */
350 | -ms-transform: translateY(-100%); /* IE 9 */
351 | transform: translateY(-100%); /* Firefox 16+, IE 10+, Opera */
352 |
353 | -webkit-transition: all 0.3s 1s ease-out;
354 | transition: all 0.3s 1s ease-out;
355 | }
356 |
357 | .red-alert {
358 | position: fixed;
359 | top: 0;
360 | left: 0;
361 | width: 100%;
362 | height: 100%;
363 | z-index: 8000;
364 | background-color: rgba(0,0,0,0.8); /*dim the background*/
365 | }
366 |
367 | .red-alert iframe {
368 | position: absolute;
369 | top: 0;
370 | bottom: 0;
371 | left: 0;
372 | right: 0;
373 | margin: auto;
374 | height: 100%;
375 | width: 100%;
376 | background-color: rgba(0,0,0,1); /*dim the background*/
377 | border-style:none;
378 | }
--------------------------------------------------------------------------------
/redalert.php:
--------------------------------------------------------------------------------
1 | message;
28 | }
29 | exit(4);
30 | }
31 |
32 | // Abbrechen wenn AlertState NICHT red ist
33 | if ($xml->global->AlertState != "red") exit();
34 |
35 | foreach($xml->milightwifis->milightwifi as $milightwifi) {
36 | if ($milightwifi->UseForAlertMode == "true") {
37 | $MLbridges[] = $milightwifi->address;
38 | $MLports[] = $milightwifi->port;
39 | }
40 | }
41 |
42 | for ($y=0; $y < count($MLbridges); $y++) {
43 | $milight = new Milight($MLbridges[$y],(integer)$MLports[$y]);
44 | $milight->rgbwSendOnToGroup(1);
45 | $milight->setRgbwActiveGroup(1);
46 | $milight->rgbwSetColorHexString("#FF0000");
47 | $milight->rgbwBrightnessPercent(90,1);
48 | $milight->rgbwSendOnToGroup(2);
49 | $milight->setRgbwActiveGroup(2);
50 | $milight->rgbwSetColorHexString("#FF0000");
51 | $milight->rgbwBrightnessPercent(90,2);
52 | $milight->rgbwSendOnToGroup(3);
53 | $milight->setRgbwActiveGroup(3);
54 | $milight->rgbwSetColorHexString("#FF0000");
55 | $milight->rgbwBrightnessPercent(90,3);
56 | $milight->rgbwSendOnToGroup(4);
57 | $milight->setRgbwActiveGroup(4);
58 | $milight->rgbwSetColorHexString("#FF0000");
59 | $milight->rgbwBrightnessPercent(90,4);
60 |
61 | unset($milight);
62 | }
63 | sleep(0.075);
64 |
65 | //for ($x=0; $x < 30;$x++) {
66 | do {
67 | set_time_limit(30);
68 | //config.xml einlesen
69 | unset($xml);
70 | libxml_use_internal_errors(true);
71 | $xml = simplexml_load_file($CONFIG_FILENAME);
72 | if (!$xml) {
73 | //echo "Kann die Konfiguration (".$CONFIG_FILENAME.") nicht laden!\n";
74 | foreach(libxml_get_errors() as $error) {
75 | //echo "\t", $error->message;
76 | }
77 | exit(4);
78 | }
79 |
80 | for ($y=0; $y < count($MLbridges); $y++) {
81 | $milight = new Milight($MLbridges[$y],(integer)$MLports[$y]);
82 | $milight->rgbwBrightnessPercent(30,1);
83 | $milight->rgbwBrightnessPercent(30,2);
84 | $milight->rgbwBrightnessPercent(30,3);
85 | $milight->rgbwBrightnessPercent(30,4);
86 | unset($milight);
87 | }
88 | sleep(0.2);
89 | for ($y=0; $y < count($MLbridges); $y++) {
90 | $milight = new Milight($MLbridges[$y],(integer)$MLports[$y]);
91 | $milight->rgbwBrightnessPercent(90,1);
92 | $milight->rgbwBrightnessPercent(90,2);
93 | $milight->rgbwBrightnessPercent(90,3);
94 | $milight->rgbwBrightnessPercent(90,4);
95 | unset($milight);
96 | }
97 | sleep(0.075);
98 |
99 | //$ret=file_put_contents("alert.log", "ALERT\n", FILE_APPEND);
100 | //sleep(1);
101 | } while ($xml->global->AlertState == "red");
102 |
103 |
104 |
105 | function switch_milight($device, $action) {
106 | global $xml;
107 |
108 | if($device->address->masterdip == "") {
109 | //echo "ERROR: masterdip (MiLight WiFi-Bridge-ID) ist ungültig für device id ".$device->id."\n";
110 | return;
111 | }
112 | if($device->address->slavedip == "") {
113 | //echo "ERROR: slavedip (Gruppe auf MiLight WiFi-Bridge) ist ungültig für device id ".$device->id."\n";
114 | return;
115 | }
116 | if($device->address->tx433version == "") {
117 | //echo "ERROR: tx433version (MiLight Lampentyp) ist ungültig für device id ".$device->id."\n";
118 | return;
119 | }
120 | if($device->address->slavedip < 0 || $device->address->slavedip > 4) {
121 | //echo "ERROR: slavedip (Gruppe auf MiLight WiFi-Bridge) muss zwischen 0-4 liegen für device id ".$device->id."\n";
122 | return;
123 | }
124 | if($device->address->tx433version < 1 || $device->address->tx433version > 2) {
125 | //echo "ERROR: tx433version (MiLight Lampentyp) muss zwischen 1-2 liegen für device id ".$device->id."\n";
126 | return;
127 | }
128 |
129 | $MiLightBridge = $xml->xpath("//milightwifis/milightwifi/id[text()='".$device->address->masterdip."']/parent::*");
130 | $MiLightBridge = $MiLightBridge[0];
131 |
132 | $milightIP = trim((string)$MiLightBridge->address);
133 | if(!filter_var($milightIP, FILTER_VALIDATE_IP)) {
134 | $milightIPCheck = @gethostbyname(trim((string)$MiLightBridge->address));
135 | if($milightIP == $milightIPCheck) {
136 | $msg="MiLight-Bridge ".$milightIP." is not availible. Check IP or Hostname. \n";
137 | //echo $msg;
138 | return;
139 | } else {
140 | $milightIP = $milightIPCheck;
141 | }
142 | }
143 |
144 | $BulbType="";$BulbCmd="";
145 | if ($device->address->tx433version == "1") $BulbType="WHITE";
146 | elseif ($device->address->tx433version == "2") $BulbType="RGBW";
147 |
148 | $milight = new Milight($milightIP,(integer)$MiLightBridge->port);
149 |
150 | if($action == "ON") {
151 | switch($BulbType){
152 | case "WHITE":
153 | $milight->whiteSendOnToGroup((integer)$device->address->slavedip);
154 | break;
155 | case "RGBW":
156 | if ($device->milight->mode != "Farbe" && $device->milight->mode != "Weiß" && $device->milight->mode != "Nacht") {
157 | $milight->rgbwSendOnToGroup((integer)$device->address->slavedip);
158 | }
159 | break;
160 | }
161 | }
162 | elseif($action == "OFF") {
163 | switch($BulbType){
164 | case "WHITE":
165 | $milight->whiteSendOffToGroup((integer)$device->address->slavedip);
166 | break;
167 | case "RGBW":
168 | $milight->rgbwSendOffToGroup((integer)$device->address->slavedip);
169 | break;
170 | }
171 | }
172 | unset($milight);
173 |
174 | //echo $device->name . " wurde geschaltet: ".$action."\n";
175 | return($action);
176 | }
177 |
178 | function toggle_milight($id, $cmd, $value) {
179 | global $xml;
180 | $DryMode = false;
181 |
182 | $device = $xml->xpath("//devices/device/id[text()='".$id."']/parent::*");
183 | $device = $device[0];
184 |
185 | if($device->address->masterdip == "") {
186 | //echo "ERROR: masterdip (MiLight WiFi-Bridge-ID) ist ungültig für device id ".$device->id."\n";
187 | return;
188 | }
189 | if($device->address->slavedip == "") {
190 | //echo "ERROR: slavedip (Gruppe auf MiLight WiFi-Bridge) ist ungültig für device id ".$device->id."\n";
191 | return;
192 | }
193 | if($device->address->tx433version == "") {
194 | //echo "ERROR: tx433version (MiLight Lampentyp) ist ungültig für device id ".$device->id."\n";
195 | return;
196 | }
197 | if($device->address->slavedip < 0 || $device->address->slavedip > 4) {
198 | //echo "ERROR: slavedip (Gruppe auf MiLight WiFi-Bridge) muss zwischen 0-4 liegen für device id ".$device->id."\n";
199 | return;
200 | }
201 | if($device->address->tx433version < 1 || $device->address->tx433version > 2) {
202 | //echo "ERROR: tx433version (MiLight Lampentyp) muss zwischen 1-2 liegen für device id ".$device->id."\n";
203 | return;
204 | }
205 |
206 | $MiLightBridge = $xml->xpath("//milightwifis/milightwifi/id[text()='".$device->address->masterdip."']/parent::*");
207 | $MiLightBridge = $MiLightBridge[0];
208 |
209 | $milightIP = trim((string)$MiLightBridge->address);
210 | if(!filter_var($milightIP, FILTER_VALIDATE_IP)) {
211 | $milightIPCheck = @gethostbyname(trim((string)$MiLightBridge->address));
212 | if($milightIP == $milightIPCheck) {
213 | $msg="MiLight-Bridge ".$milightIP." is not availible. Check IP or Hostname. \n";
214 | //echo $msg;
215 | return;
216 | } else {
217 | $milightIP = $milightIPCheck;
218 | }
219 | }
220 |
221 | $BulbType="";
222 | if ($device->address->tx433version == "1") $BulbType="WHITE";
223 | elseif ($device->address->tx433version == "2") $BulbType="RGBW";
224 |
225 | $milight = new Milight($milightIP,(integer)$MiLightBridge->port);
226 |
227 | switch($BulbType){
228 | case "WHITE":
229 | // NOCH NICHT IMPLEMENTIERT
230 | break;
231 | case "RGBW":
232 | if (!$DryMode) {
233 | $milight->setRgbwActiveGroup((integer)$device->address->slavedip);
234 |
235 | if ($cmd == "SetColor") {
236 | $milight->rgbwSetColorHexString(trim($value));
237 | $milight->rgbwBrightnessPercent((integer)$device->milight->brightnesscolor,(integer)$device->address->slavedip);
238 | }
239 | elseif ($cmd == "SetBrightness") {
240 | $milight->rgbwBrightnessPercent((integer)$value,(integer)$device->address->slavedip);
241 | }
242 | elseif ($cmd == "SetToWhite") {
243 | $milight->rgbwSetGroupToWhite((integer)$device->address->slavedip);
244 | $milight->rgbwBrightnessPercent((integer)$device->milight->brightnesswhite,(integer)$device->address->slavedip);
245 | }
246 | elseif ($cmd == "SetToNightMode") {
247 | $milight->rgbwSendOffToGroup((integer)$device->address->slavedip);
248 | $milight->command("rgbwGroup".(integer)$device->address->slavedip."NightMode");
249 | }
250 | elseif ($cmd == "rgbwDiscoMode" || $cmd == "rgbwDiscoSlower" || $cmd == "rgbwDiscoFaster") {
251 | if ($cmd == "rgbwDiscoMode" || $device->milight->mode == "Programm") {
252 | $milight->rgbwSendOnToActiveGroup();
253 | $milight->command(trim($cmd));
254 |
255 | if ($cmd == "rgbwDiscoMode") {
256 | sleep(1);
257 | $milight->setRgbwActiveGroup((integer)$device->address->slavedip);
258 | $milight->rgbwBrightnessPercent((integer)$device->milight->brightnessdisco,(integer)$device->address->slavedip);
259 | }
260 | }
261 | }
262 | }
263 | break;
264 | }
265 | unset($milight);
266 |
267 | //echo $device->name . " wurde geschaltet: ".$action." ";
268 | if (!$DryMode) return("#OK#");
269 | else return("#".$id."#".$cmd."#".$value."#");
270 | }
271 |
272 | sleep(0.2);
273 | foreach($xml->devices->device as $device) {
274 | if ($device->vendor == "milight" && $device->room != "Garten") {
275 | if ($device->status == "OFF") switch_milight($device,"OFF");
276 | elseif ($device->status == "ON") {
277 | switch_milight($device,"ON");
278 | sleep(0.2);
279 | if ($device->milight->mode == "Weiß") {
280 | $MR = toggle_milight($device->id,"SetToWhite",'');
281 | } elseif ($device->milight->mode == "Farbe") {
282 | $MR = toggle_milight($device->id,"SetColor",$device->milight->color);
283 | } elseif ($device->milight->mode == "Nacht") {
284 | $MR = toggle_milight($device->id,"SetToNightMode",'');
285 | } elseif ($device->milight->mode == "Programm") {
286 | switch_milight($device,"OFF");
287 | }
288 | }
289 |
290 | sleep(0.2);
291 | }
292 | }
293 | ?>
--------------------------------------------------------------------------------
/includes/incl_actions.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Favoriten
6 |
7 | Geräte
8 | gui->showGroupsBtnInMenu == "true") { ?> Gruppen
9 | gui->showRoomsBtnInMenu == "true") { ?> Räume
10 | gui->showTimerBtnInMenu == "true") { ?> Timer
11 | gui->showActionBtnInMenu == "true") { ?> Aktionen
12 | Einstellungen
13 |
14 | gui->showAllOnOffBtnInMenu == "true") { ?>
15 |
16 |
17 |
18 |
19 |
20 |
21 | Schliessen
22 |
23 |
24 |
25 |
26 |
27 |
Aktionen
28 |
33 |
34 |
35 |
36 |
37 | - Favoriten
38 | - Geräte
39 | gui->showGroupsBtnInMenu == "true") { ?> - Gruppen
40 | gui->showRoomsBtnInMenu == "true") { ?> - Räume
41 | gui->showTimerBtnInMenu == "true") { ?> - Timer
42 | gui->showActionBtnInMenu == "true") { ?> - Aktionen
43 | - Konfig
44 |
45 |
46 |
47 |
48 |
49 |
50 | -
51 |
56 |
57 | - background-color:#B63737;-moz-border-radius:.5em;-webkit-border-radius:.5em;border-radius:.5em;">
58 |
63 |
64 | -
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | actions->action as $action) {
77 | $actionsFound[] = $action;
78 | }
79 | switch ($xml->gui->sortOrderGroups){
80 | case "SORT_BY_NAME":
81 | usort($actionsFound, "compareGroupsByName");
82 | break;
83 | case "SORT_BY_ID":
84 | usort($actionsFound, "compareGroupsByID");
85 | break;
86 | default:
87 | break;
88 | }
89 | foreach($actionsFound as $action) {
90 | ?>
91 |
92 | -
93 |
94 |
95 |
name; ?>
96 | do as $do) {
98 | $tmpNameAction="";
99 | switch ($do['type']) {
100 | case "device":
101 | $devicesFound = $xml->xpath("//devices/device/id[text()='".$do['id']."']/parent::*");
102 | $tmpNameAction = "Gerät: ".$devicesFound[0]->name." (".$devicesFound[0]->room.")";
103 | break;
104 | case "group":
105 | $groupsFound = $xml->xpath("//groups/group/id[text()='".$do['id']."']/parent::*");
106 | $tmpNameAction = "Gruppe: ".$groupsFound[0]->name;
107 | break;
108 | case "room":
109 | $tmpNameAction = "Raum: ".$do['id'];
110 | break;
111 | case "wait":
112 | $tmpNameAction = "Warte: ".$do['id']." Sekunden";
113 | break;
114 | }
115 | echo "
".$tmpNameAction." ";
116 | if ($do['action'] == "on") echo "AN";
117 | if ($do['action'] == "off") echo "AUS";
118 | if ($do['type'] == "device") {
119 | if ( ($devicesFound[0]->vendor == "milight" || $devicesFound[0]->vendor == "milight_rgbcct") && $do['action'] == "on") {
120 | if ($do['mode'] != "") {
121 | echo " (vA) @ ";
122 | echo $do['mode'];
123 |
124 | if ($do['mode'] == "Farbe") {
125 | if ($do['color'] != "") echo " ● ";
126 | else echo " milight->color."\">● ";
127 | if ($do['brightness'] != "") echo $do['brightness']."%";
128 | else echo $devicesFound[0]->milight->brightnesscolor."%";
129 |
130 | if ($devicesFound[0]->vendor == "milight_rgbcct") {
131 | if ($do['saturation'] != "") echo " (Sat.: ".$do['saturation']."%)";
132 | else echo " (Sat.: ".$devicesFound[0]->milight->saturation."%)";
133 | }
134 | }
135 | elseif ($do['mode'] == "Weiß") {
136 | if ($do['brightness'] != "") echo " ● ".$do['brightness']."%";
137 | else echo " ● ".$devicesFound[0]->milight->brightnesswhite."%";
138 |
139 | if ($devicesFound[0]->vendor == "milight_rgbcct") {
140 | if ($do['temperature'] != "") echo " (".TemperaturePercentToKelvin($do['temperature'])."K)";
141 | else echo " (".TemperaturePercentToKelvin($devicesFound[0]->milight->temperature)."K)";
142 | }
143 | }
144 | }
145 |
146 | elseif ($do['mode'] == "") {
147 | echo " @ ";
148 | echo $devicesFound[0]->milight->mode;
149 |
150 | if ($devicesFound[0]->milight->mode == "Farbe") {
151 | echo " milight->color."\">● ";
152 | echo $devicesFound[0]->milight->brightnesscolor."%";
153 |
154 | if ($devicesFound[0]->vendor == "milight_rgbcct") {
155 | echo " (Sat.: ".$devicesFound[0]->milight->saturation."%)";
156 | }
157 | }
158 | elseif ($devicesFound[0]->milight->mode == "Weiß") {
159 | echo " ● ".$devicesFound[0]->milight->brightnesswhite."%";
160 |
161 | if ($devicesFound[0]->vendor == "milight_rgbcct") {
162 | echo " (".TemperaturePercentToKelvin($devicesFound[0]->milight->temperature)."K)";
163 | }
164 | }
165 | }
166 | }
167 | }
168 | echo "
";
169 | }
170 | ?>
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
187 |
188 |
189 |
190 |
191 |
--------------------------------------------------------------------------------