-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshow-status.php
99 lines (99 loc) · 3.47 KB
/
show-status.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<meta http-equiv="refresh" content="30">
<form method="POST">
<table class="status">
<?php
$day = date( "N" ); ?>
<tr>
<td><font color='grey'><b> Appliance</td>
<td><font color='grey'><b>Status</td>
<td><b><font color='grey'>Auto</td>
<td><font color='grey'><b>Pwr</td>
<td><font color='grey'><b>Manual </td>
<td><font color='grey'><b> Manual Time </td>
<th><font color='grey'>Schedule 1</th>
<th><font color='grey'>Schedule 2</th>
<th><font color='grey'>Schedule 3</th>
<th><font color='grey'>Schedule 4</th>
<th><font color='grey'>Schedule 5</font></th>
<?php
foreach ( $devices as $deviceName => $devicePin ) {
if ( $deviceName <> "Cntl Off-Peak" ) { // we don't want to print Off-Peak its only used for graphics
$deviceStatus = exec( "/usr/local/bin/gpio read $devicePin[0]" ); // runGpio( "read", $devicePin[0] ); ?>
<tr>
<td><b><?php
print( $deviceName ); ?></b></td>
<td>
<?php
print( $deviceStatus ? "<font color='red'>On</font>" : "<font color='blue'>Off</font>" ); ?>
</td>
<td>
<?
if ( !$devicePin[1] ) {
print "<font color='blue'>Off</font>";
} else
print "<b><font color='purple'>" . $devicePin[1] . "</font>"; // Auto Power priority ?>
</td>
<td>
<?
print $devicePin[3]; // power requirement ?>
</td>
<td>
<input type="submit" name="<?php
print( $deviceName ); ?>Action" value="<?php
print( $deviceStatus ? "Turn off" : "Turn on" ); ?>"/>
</td>
<td>
<?php
if ( !$deviceStatus ) { ?>
for
<select name="<?php
print( $deviceName ); ?>Duration">
<option value="0" selected="selected">Manual</option>
<option value="1">1 min</option>
<option value="5">5 min</option>
<option value="15">15 min</option>
<option value="30">30 min</option>
<option value="60">1 hour</option>
<option value="120">2 hours</option>
<option value="240">4 hours</option>
<option value="600">6 hours</option>
<option value="480">8 hours</option>
</select>
<?php
}
?>
</td>
<?
$offset = 0;
foreach ( $schedules as $scheduleNums => $scheduleKey ) {
$offset++; ?>
<td><?php
foreach ( $scheduleKey as $deviceNames => $devicePins ) {
if ( $deviceName == $deviceNames ) {
if ( $devicePins[2] != 0 ) {
if ( $devicePin[5 + $day + ( ( $offset - 1 ) * 10 )] && !$devicePin[4] ) {
print "<font color='blue'>";
} else {
print "<font color='black'>";
}
printf( "%02d:%02d for %02d:%02d", $devicePins[3], $devicePins[4], $devicePins[5], $devicePins[6] );
print "</font>";
} else {
print "<font color='black'>";
print "not scheduled";
print "</font>";
}
?>
</td>
<?php
}
}
}
?>
</tr>
<?php
}
}
?>
</table>
</form>