Skip to content

Commit

Permalink
v1.3.1 - minor formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hplato committed Aug 22, 2018
1 parent 6207fc7 commit 672f17b
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions code/common/calc_eto.pl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
use Date::Calc qw(Day_of_Year);
my $debug = 0;
my $msg_string;
my $rrd = 0;
my $rrd = "";

$p_wu_forecast = new Process_Item
qq[get_url --quiet "http://api.wunderground.com/api/$config_parms{wu_key}/astronomy/yesterday/conditions/forecast/q/$config_parms{eto_location}.json" "$config_parms{data_dir}/wuData/wu_data.json"];
Expand All @@ -120,7 +120,7 @@

if ( $Startup or $Reload ) {
$eto_ready = 1;
print_log "[calc_eto] v1.3 Startup. Checking Configuration...";
print_log "[calc_eto] v1.3.1 Startup. Checking Configuration...";
mkdir "$eto_data_dir" unless ( -d "$eto_data_dir" );
mkdir "$eto_data_dir/ET" unless ( -d "$eto_data_dir/ET" );
mkdir "$eto_data_dir/logs" unless ( -d "$eto_data_dir/logs" );
Expand Down Expand Up @@ -157,12 +157,12 @@
print_log "[calc_eto] Will write daily rain to RRD (mms)";
$rrd = "m";
} elsif ($config_parms{eto_rrd} eq "in") {
print_log "[calc_eto] Will write daily rain to RRD (inches)";
$rrd = "i";
print_log "[calc_eto] Inches to RRD not supported yet";
$rrd = "";
} else {
print_log "[calc_eto] Unknown RRD option $config_parms{eto_rrd}";
$rrd = 0;
}
$rrd = "";
}
}
if ( defined $config_parms{eto_irrigation} ) {
print_log "[calc_eto] $config_parms{eto_irrigation} set as programmable irrigation system";
Expand Down Expand Up @@ -956,6 +956,7 @@ sub detailSchedule {
my $station_id = 1;
$time = $time * 60; #add in seconds
foreach my $station (split /,/, $lengths) {
next if ($station == 0);
my $run_hour = 0;
if ($station > 3600) {
$run_hour = int($station / 3600);
Expand Down Expand Up @@ -1169,6 +1170,15 @@ sub main_calc_eto {
print_log $msg;
$msg_string .= $msg . "\n";

#write to the RRD if it's enabled
if ($rrd ne "") {
$msg = '[calc_eto] Writing fallen and forecast rain to RRD: ' . round( $todayRain, 4 ) . " mm";
$Weather{RainTotal} = round( $todayRain, 4 );
print_log $msg;
$msg_string .= $msg . "\n";

}

# Binary watering determination based on 3 criteria: 1)Currently raining 2)Wind>8kph~5mph 3)Temp<4.5C ~ 40F
if ($noWater) {
$msg = "[calc_eto] RESULTS We will not water because: $whyNot";
Expand Down Expand Up @@ -1223,30 +1233,14 @@ sub main_calc_eto {
#Write the WU data to a file. This can be used for the MH weather data and save an api call
writewuData( $wuData, $noWater, $wuDataPath );

#write to the RRD if it's enabled
if ($rrd != 0) {
$msg = '[calc_eto] Writing predicted rain to RRD :';

if ($rrd eq "m") {
$msg .= $wuData->{current_observation}->{precip_today_metric} . " mm";
$Weather{RainTotal} = $wuData->{current_observation}->{precip_today_metric};
} else {
$msg .= $wuData->{current_observation}->{precip_today_in} . " in";
$Weather{RainTotal} = $wuData->{current_observation}->{precip_today_in};
}
print_log $msg;
$msg_string .= $msg . "\n";

}

#$msg = "[calc_eto] RESULTS Calculated Schedule: $rtime";
#print_log $msg;
#$msg_string .= $msg . "\n";
my ($rtime2) = detailSchedule($rtime);
foreach my $detail (split /\n/,$rtime2) {
print_log $detail;
}
$msg_string .= $msg . $rtime2;
$msg_string .= $msg . "\n" . $rtime2;
if ( defined $config_parms{eto_email} ) {
print_log "[calc_eto] Emailing results";
net_mail_send( to => $config_parms{eto_email}, subject => "EvapoTranspiration Results for $Time_Now", text => $msg_string );
Expand Down

0 comments on commit 672f17b

Please sign in to comment.