updated removed
[home-automation.git] / set_isy99i_status.php
1 <?
2 $device=$_GET['device'];
3 $state=$_GET['state'];
4
5 $fields = array(
6   'node'=>$device,
7   'submit'=>$state
8 );
9
10 foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
11 rtrim($fields_string,'&');
12
13 $ch = curl_init();
14
15 if ("nodes"==substr($device,0,5)) {
16   $string="http://isy99/rest/nodes/".rawurlencode(substr($device,-10))."/cmd/$state";
17 } else  {
18   if ($state=="DON") {
19     $state="runThen";
20   } else {
21     $state="runElse";
22   }
23   $string="http://isy99/rest/programs/".rawurlencode(substr($device,-4))."/$state";
24 }
25 curl_setopt($ch, CURLOPT_URL,"$string");
26
27 #echo "-$string-";
28 #exit;
29
30 #echo "http://isy99/rest/nodes/$device/cmd/$state";
31
32 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
33 curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
34 curl_setopt($ch, CURLOPT_USERPWD, 'admin:admin');
35 curl_setopt($ch, CURLOPT_HEADER, 0);
36 #curl_setopt($ch,CURLOPT_POST,count($fields));
37 #curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
38
39
40
41 $output = curl_exec($ch);
42
43 #echo "<pre>";
44
45 #print_r($output);
46
47 #curl_close($ch);
48 ?>