#!/path/to/perl use strict; use warnings; use CGI qw(:cgi); use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; print $cgi->header('text/plain'); ### ### CPAN Module: Google Latiude ### ### Get your current position from Google Latitude ### use Geo::Google::Latitude; my $gl=Geo::Google::Latitude->new; my $id="-4344773375959268341"; my $badge=$gl->get($id); print "Google Latitude Info\n"; printf "\@ %s\nCurrent Latitude: %s\nCurrent Longitude: %s", $badge->point->datetime, $badge->point->latlon; ### ### CPAN Module: Geo Distance ### ### Calculate distance between current position and the trigger position ### use Geo::Distance; my $geo = new Geo::Distance; ### Trigger Position my $lon1 = "-79.76408958435059"; my $lat1 = "39.98034285770052"; ### Current Position my ($lat2, $lon2) = $badge->point->latlon; ### Calculated Distance my $distance = $geo->distance( 'mile', $lon1, $lat1 => $lon2, $lat2 ); # Use 'meter' to calculate distance in meters print "\n\nDistance Away from Trigger Point\n"; print "$distance"; if ($distance > 5) {exit;} # Stop script here if you are not near home ### ### CPAN Module: Weather Google ### ### Calculate current temperature based on location ### use Weather::Google; my $gw = new Weather::Google(15401); # Zipcode my $current_outside = $gw->current->{temp_f}; #Use temp_c for celsius print "\n\nGoogle Weather Temperature Outside\n"; print "Current Outside Temp: $current_outside"; ### ### ioBridge Widget API ### ### Controls Air Conditioner / Heater via the ioBridge web service ### Get temperature reading from a temperature sensor in the house ### use LWP::Simple; my $Air_Conditioner_widgetID = "Gb2Q1FUKPmzZ"; my $Heater_widgetID = "9c3WEGHKemnzJ"; my $Inside_Temp_widgetID = "D32SDghy98iOu"; my $ioBridgeAPI = ""; $ioBridgeAPI = "http://www.iobridge.com/widgets/static/id=" . $Inside_Temp_widgetID . "&value=1&format=text"; my $current_inside = get($ioBridgeAPI); print "\n\nioBridge Temperature Sensor Inside\n"; print "Current Inside Temp: $current_inside"; ### Test if the heater or the air condition should be turned on if ($current_outside >= 78 && $current_inside >= 72) { $ioBridgeAPI = "http://www.iobridge.com/widgets/static/id=" . $Air_Conditioner_widgetID . "&value=1&format=text"; get($ioBridgeAPI); print "\n\nAction: Turned On AC"; } elsif ($current_outside <= 60 && $current_inside <= 68 ) { $ioBridgeAPI = "http://www.iobridge.com/widgets/static/id=" . $Heater_widgetID . "&value=1&format=text"; get("$ioBridgeAPI"); print "\n\nAction: Turned On Heater"; } exit;