Weather_Item.pm |
Weather_Item - This object can be used to track data stored in the global %Weather array.
$WindSpeed = new Weather_Item 'WindSpeed';
$WindSpeed-> tie_event('print_log "Wind speed is now at $state"');
$freezing = new Weather_Item 'TempOutdoor < 32';
if (state_now $fountain eq ON and state $freezing) {
speak "Sorry fountains don't work too well when frozen";
set $fountain OFF
}
$Windy = new Weather_Item 'WindSpeed > 15';
speak "Wind is gusting at $Weather{WindSpeed} mph" if state $Windy;
# For current state, easiest to use it directly
speak "Outdoor temperature is $Weather{TempOutdoor} degrees";
Generic_Item
new($type)
$type is the name of the %Weather index you want to monitor. $type can also have a =<> comparison operator in it so you can make the object a true/false test.
state
Returns the last state, or 1/0 if $comparition and $limit were used.
tate_now
Returns the state only when the weather data changed.
NONE
UNK
For examples on interface code that stores data into %Weather, see mh/code/bruce/weather_monitor.pl (uses mh/lib/Weather_wx200.pm), mh/code/public/iButton_ws_client.pl, and mh/code/public/weather_com.pl
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Weather_Item.pm |