-
Notifications
You must be signed in to change notification settings - Fork 131
Items Weather_Item
ggodart edited this page Jan 6, 2021
·
1 revision
See original
$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";
Method | Description |
---|---|
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 $comparision and $limit were used. |
Method | Description |
---|---|
state_now |
Returns the state only when the weather data changed. |
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