Subversion Repositories HomeAutomation

Rev

Rev 2051 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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