-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcron.php
More file actions
80 lines (63 loc) · 2.13 KB
/
cron.php
File metadata and controls
80 lines (63 loc) · 2.13 KB
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
<?php
header('Content-type: text/plain');
include 'config.php';
date_default_timezone_set($timezone);
include 'app/device.php';
include 'app/scheduler.php';
include 'app/weather.php';
$device = new Device($ipaddress, $port, $simulated, $amount_per_min, $num_zones);
$scheduler = new Scheduler();
$weather = new Weather($location,$api_key);
echo date("m/d H:i");
echo "\t";
$status = $device->getStatus();
echo $status[0];
//only print details and update weather every hour
if (date("i") < 5 || $_GET['update_weather']) {
echo "\t";
if ($scheduler->getNextRunTime()) {
echo date("m/d H:i",$scheduler->getNextRunTime());
echo " (";
echo (int)(($scheduler->getNextRunTime() - time())/60);
echo "m)\t";
}
else echo "No water scheduled \t";
if ($weather->updateWeatherSource()) echo "Update OK\t";
else echo "Unavailable\t";
if ($scheduler->getSetting('past_rain')) {
echo "1-";
echo $weather->didRainAmount($scheduler->getSetting('past_num_days'), $scheduler->getSetting('past_max_amount'));
echo "\t";
}
else echo "0-\t";
if ($scheduler->getSetting('present_rain')) {
echo "1-";
echo $weather->isRaining();
echo "\t";
}
else echo "0-\t";
if ($scheduler->getSetting('future_rain')) {
echo "1-";
echo $weather->willRain($scheduler->getSetting('future_num_days'));
}
else echo "0-";
}
//Call runCycle if within 15 mins and weather contraints are met
if ($scheduler->getNextRunTime() && ($scheduler->getNextRunTime() - time()) <= (60*15)) {
if (!$scheduler->getSetting('past_rain') || !$weather->didRainAmount($scheduler->getSetting('past_num_days'), $scheduler->getSetting('past_max_amount'))) {
if (!$scheduler->getSetting('present_rain') || !$weather->isRaining()) {
if (!$scheduler->getSetting('future_rain') || !$weather->willRain($scheduler->getSetting('future_num_days'))) {
if ($device->isReady()) {
echo "\trunCycle(";
echo $scheduler->getSetting('duration');
echo ",";
echo (int)(($scheduler->getNextRunTime() - time())/60);
echo ")";
$device->runCycle($scheduler->getSetting('duration'), (int)(($scheduler->getNextRunTime() - time()) / 60));
}
}
}
}
}
echo "\n";
?>