Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
2051 linlun 1
<?php
2
 
3
function GetLastValue($alias2)
4
{
5
  $level2 = 0;
6
  $buffer = "";
7
 
8
  try
9
  {
10
    $socket = atomd_initialize("127.0.0.1", 1202);
11
 
12
    atomd_send_command($socket, "Module_GetLastValue $alias2");
13
 
14
    $buffer = atomd_read_command_response($socket);
15
  }
16
  catch (Exception $e)
17
  {
18
    die($e);
19
  }
20
 
21
  $output = explode("\n", $buffer);
22
 
23
  foreach ($output as $line)
24
  {
25
    if (strpos($line, "Level: ") !== FALSE)
26
    {
27
      list($dummy1, $level2) = explode(" ", $line);
28
 
29
      $start = strpos($level2, "m") + 1;
30
 
31
      $level2 = substr($level2, $start, strpos($level2, "[", $start) - $start);
32
    }
33
  }
34
 
35
  return intval($level2);
36
}
37
 
38
 
39
function GetLastData($alias2)
40
{
41
  $level2 = 0;
42
  $buffer = "";
43
  $result = array();
44
  try
45
  {
46
    $socket = atomd_initialize("127.0.0.1", 1202);
47
    atomd_send_command($socket, "Module_GetLastDataRaw $alias2");
48
 
49
    $buffer = atomd_read_command_response($socket);
50
    $array = json_decode(trim($buffer), true);
51
  echo '<br>';
52
  print_r($array);
53
  echo '<br>';
54
  }
55
  catch (Exception $e)
56
  {
57
    die($e);
58
  }
59
  return $array["results"];
60
}
61
 
62
 
63
 
64
function SetDimmerValue($alias2, $level)
65
{
66
  $level2 = 0;
67
  $buffer = "";
68
 
69
  try
70
  {
71
    $socket = atomd_initialize("127.0.0.1", 1202);
72
 
73
    atomd_send_command($socket, "Dimmer_AbsoluteFade $alias2 255 $level");
74
 
75
    $buffer = atomd_read_command_response($socket);
76
  }
77
  catch (Exception $e)
78
  {
79
    die($e);
80
  }
81
}
82
 
83
?>
84