From f98faab11f7800ac4d0fdbf5ab71f91ecf0e062e Mon Sep 17 00:00:00 2001 From: bluesaxman Date: Tue, 21 Jul 2020 10:17:29 -0600 Subject: [PATCH] Added location to output for better troubleshooting --- weather.sh | 4 +++- weatherbug.sh | 3 ++- weathergov.sh | 3 ++- wttrin.sh | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/weather.sh b/weather.sh index d521698..c8de274 100755 --- a/weather.sh +++ b/weather.sh @@ -92,5 +92,7 @@ elsif ($type =~ /Sun/) {$type = "";} elsif ($type =~ /Snow/) {$type = "";} else {$type=$type."...";} -print $type."  ".$temp."  ".$wdir." ".$wind."mph\n\n"; +my $loc = substr(($weather[4] or "?????"), 0, 5); + +print $loc." - ".$type."  ".$temp."  ".$wdir." ".$wind."mph\n\n"; print $color."\n"; diff --git a/weatherbug.sh b/weatherbug.sh index 916b316..c530f2d 100755 --- a/weatherbug.sh +++ b/weatherbug.sh @@ -13,8 +13,9 @@ my $info = `curl -sm 5 https://www.weatherbug.com/api/observation?lat=$URL_lat&l my $json = decode_json $info or die "Error"; +my $loc = %{$json}{"Observation"}->{"Station"}->{"StationName"}; my $temp = %{$json}{"Observation"}->{"Temperature"}; my $windS = %{$json}{"Observation"}->{"WindSpeedAvg"}; my $windD = %{$json}{"Observation"}->{"WindDirectionAvg"}; -print "Unknown:".$temp.":".$windS.":".$windD; +print "Unknown:".$temp.":".$windS.":".$windD.":".$loc; diff --git a/weathergov.sh b/weathergov.sh index fec583b..a4411bb 100755 --- a/weathergov.sh +++ b/weathergov.sh @@ -10,9 +10,10 @@ my $info = `curl -sm 5 "https://forecast.weather.gov/MapClick.php?lat=$URL_lat&l my $json = decode_json $info or die "Error"; +my $loc = %{$json}{"location"}->{"areaDescription"}; my $temp = %{$json}{"currentobservation"}->{"Temp"}; my $windS = %{$json}{"currentobservation"}->{"Winds"}; my $windD = %{$json}{"currentobservation"}->{"Windd"}; my $desc = %{$json}{"currentobservation"}->{"Weather"}; -print $desc.":".$temp.":".$windS.":".$windD; +print $desc.":".$temp.":".$windS.":".$windD.":".$loc; diff --git a/wttrin.sh b/wttrin.sh index 6bfbb23..eab6532 100755 --- a/wttrin.sh +++ b/wttrin.sh @@ -7,9 +7,10 @@ my $info = `curl -sm 5 wttr.in/bluffdale?format=j1` or die "Error"; my $json = decode_json $info or die "Error"; +my $loc = %{$json}{"nearest_area"}->[0]->{"areaName"}->{"value"}; my $temp = %{$json}{"current_condition"}->[0]->{"temp_F"}; my $windS = %{$json}{"current_condition"}->[0]->{"windspeedMiles"}; my $windD = %{$json}{"current_condition"}->[0]->{"winddirDegree"}; my $desc = %{$json}{"current_condition"}->[0]->{"weatherDesc"}->[0]->{"value"}; -print $desc.":".$temp.":".$windS.":".$windD; +print $desc.":".$temp.":".$windS.":".$windD.":".$loc;