Subversion Repositories HomeAutomation

Rev

Rev 2051 | Go to most recent revision | Details | Compare with Previous | 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
  }
52
  catch (Exception $e)
53
  {
54
    die($e);
55
  }
56
  return $array["results"];
57
}
58
 
59
 
60
 
61
function SetDimmerValue($alias2, $level)
62
{
63
  $level2 = 0;
64
  $buffer = "";
65
 
66
  try
67
  {
68
    $socket = atomd_initialize("127.0.0.1", 1202);
69
 
70
    atomd_send_command($socket, "Dimmer_AbsoluteFade $alias2 255 $level");
71
 
72
    $buffer = atomd_read_command_response($socket);
73
  }
74
  catch (Exception $e)
75
  {
76
    die($e);
77
  }
78
}
79
 
80
?>
81