Skip to content

Commit

Permalink
Merge pull request #15 from hplato/ia7
Browse files Browse the repository at this point in the history
Ia7 Merge
  • Loading branch information
Wayne Gatlin authored Oct 3, 2017
2 parents d9bd75b + 84ba847 commit 41d1558
Show file tree
Hide file tree
Showing 12 changed files with 830 additions and 156 deletions.
8 changes: 7 additions & 1 deletion code/common/internet_weather.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# $Date$
# $Revision$

#@ Retrieves current weather conditions and forecasts using bin/get_weather (US only).
#@ Retrieves current weather conditions and forecasts using bin/get_weather (US only). (MH5 Updated)
#@ You will need to set the city, zone, and state parms in your ini file.
#@ To verify your city, click <a href="http://iwin.nws.noaa.gov/iwin/iwdspg1.html">here</a>,
#@ then click on your state, then click on "Hourly Reports". If your city
Expand Down Expand Up @@ -49,6 +49,7 @@
$p_weather_data = new Process_Item;
$p_weather_conditions = new Process_Item;
$p_weather_forecast = new Process_Item;
$Weather_Common::weather_module_enabled = 1;

#noloop=stop

Expand Down Expand Up @@ -190,6 +191,11 @@ sub normalize_conditions {
if ( $conditions =~ /conditions were (clear|cloudy|partly cloudy|mostly cloudy|sunny|mostly sunny|partly sunny)/ ) {
$w{Clouds} = lc($1);
}

#be nice to have a full date, but GEO::WeatherNOAA only puts $in->{TIME} in the conditions output
if ( $conditions =~ /^At\s(\d\d:\d\d\s\S\S)/ ) {
$w{LastUpdated} = lc($1);
}

$w{WindAvgDir} =
&Weather_Common::convert_wind_dir_text_to_num( $w{WindAvgDir} );
Expand Down
4 changes: 2 additions & 2 deletions code/common/weather_metar.pl
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ sub process_metar {
$weather = '';
$clouds = '';
my $notCurrent = 0;
$metar{IsRaining} = 0;
$metar{IsSnowing} = 0;
$metar{IsRaining} = 0 unless (defined $metar{IsRaining} and $metar{IsRaining} == 1);
$metar{IsSnowing} = 0 unless (defined $metar{IsSnowing} and $metar{IsSnowing} == 1);


( $metar{WindAvgDir}, $metar{WindAvgSpeed}, $metar{WindGustSpeed} ) =
Expand Down
7 changes: 5 additions & 2 deletions lib/http_server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,11 @@ sub http_process_request {
print "http POST in loop\n" if $main::Debug{http};
$get_arg .= "&" if ( $get_arg ne '' );
$get_arg .= $buf;
}
else {

} elsif ( ( lc($Http{'Content-Type'}) eq lc('application/json') ) && ( $HTTP_BODY =~ /^\{/ ) ) {
print "[http_server.pl]: posting json data\n" if $main::Debug{http};

} else {
&main::print_log("[http_server.pl]: Warning, invalid argument string detected ($buf)\n");
}
print "http POST get_arg=$get_arg\n" if $main::Debug{http};
Expand Down
33 changes: 0 additions & 33 deletions lib/ia7_utilities.pl
Original file line number Diff line number Diff line change
@@ -1,44 +1,11 @@
package ia7_utilities;
use strict;
use JSON qw(decode_json to_json);
our $ia7_count_session;

$ia7_count_session = 0; #noloop
$main::Save{"ia7_count_total"} = 0 if (not defined $main::Save{"ia7_count_total"}); #noloop

&::Reload_post_add_hook( \&ia7_utilities::speech_startup, 1 ); #noloop

sub main::ia7_update_schedule {
my ( $object, @schedules ) = @_;

&main::print_log( "Updating Schedule for object $object, schedule size is " . scalar(@schedules) );

my $obj = &main::get_object_by_name($object);
my $s = 0;
my $index;
my @curr_schedule = $obj->get_schedule;
$obj->reset_schedule();
for ( my $i = 1; $i <= ( scalar(@schedules) / 3 ); $i++ ) {
my $jqCron = $schedules[ $i * 3 - 2 ];

#jqCron uses 1-7 for Sat - Sunday, MH uses 0-6, so shift all the numbers
&main::print_log(
"Adding Schedule (id=" . $schedules[ $i * 3 - 3 ] . " cron=" . $schedules[ $i * 3 - 2 ] . " label=" . $schedules[ $i * 3 - 1 ] . ")" );
$obj->set_schedule( $schedules[ $i * 3 - 3 ], $schedules[ $i * 3 - 2 ], $schedules[ $i * 3 - 1 ] );
}
return ""; #needed to prevent an action from being executed
}

sub main::ia7_update_counter {

$ia7_count_session++;
$main::Save{"ia7_count_total"}++;

# &main::print_log( "Updating Counter [" . $ia7_count_session . "/" . $main::Save{"ia7_count_total"} . "]");
return "";

}

sub speech_startup {
if ( !defined $main::Info{IPAddress_local} ) {
&::print_log("WARNING \$Info{IPAddress_local} not defined. Json speech disabled");
Expand Down
Loading

0 comments on commit 41d1558

Please sign in to comment.