Using Weatherman with Indigo

Posted on
Sun Nov 23, 2003 2:24 pm
pablo offline

(No subject)

Ok now I see the script actually working. I had to take a few lines out to make it work. I kept getting thses errors

Error script error: WeatherManX got an error: Can't get Conditions of City "Hartford,".
Error script error: WeatherManX got an error: Can't get Conditions of City "Hartford,".
Time/Date Action Getweather


Error script error: WeatherManX got an error: Can't get Wind Direction of City "Hartford, CT".
Error script error: WeatherManX got an error: Can't get Wind Direction of City "Hartford, CT".
Time/Date Action Getweather

Now that I removed those lines in the script I get a new error message.

Error script error: The handler some object is not defined.
Time/Date Action Getweather

What does that mean now? No, I'm still not getting variables loaded into indigo.

Posted on
Sun Nov 23, 2003 4:14 pm
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

Whatever you called your city in WeathermanX is what you need to have in there for the city name. Should have specified that.

Posted on
Sun Nov 23, 2003 4:53 pm
Guest offline

(No subject)

Yes, the city name in weathermanx is the same as the name in Getweather. What is this: The handler some object is not defined?

Posted on
Sun Nov 23, 2003 6:26 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

(No subject)

Anonymous wrote:
Yes, the city name in weathermanx is the same as the name in Getweather. What is this: The handler some object is not defined?

Hard to tell for sure. The AppleScript error messages can be pretty cryptic, and in some cases not very accurate. I suspect there might be a syntax error in your script somewhere that is causing the problem. Maybe from when you copied over the original script from the forum? Did you copy and paste from the post? It probably didn't copy over well out of the forum post. Note that at the top of the script in Greg's post there is a link you can click that will automatically open the Script Editor with the script source in it. I'd recommend using that technique.

Regards,
Matt

Posted on
Mon Nov 24, 2003 6:37 am
pablo offline

(No subject)

I get an error whenever I try to open the scripteditor from that link. Here is my script as I have it now.



using terms from application "Indigo"
on GetWeather()
-- get the values from weatherman
tell application "WeatherManX"
set the temp to the Current Temperature of City "Hartford"
set the wind_speed to the Wind Speed of City "Hartford" as real
set the dew to the Dewpoint of City "Hartford"
set the baro to the Current Pressure of City "Hartford"
set the humid to the Humidity of City "Hartford"
set the vis to the (Visibility of City "Hartford") as integer
set the ptrend to the Pressure Trend of City "Hartford"
set the wether to the Weather of City "Hartford"
end tell
-- create variable if they don't exsit
if not (variable "wind_dir" exists) then make new variable with properties {name:"wind_dir", value:"unknown"}
if not (variable "temp" exists) then make new variable with properties {name:"temp", value:"unknown"}
if not (variable "wind_speed" exists) then make new variable with properties {name:"wind_speed", value:"unknown"}
if not (variable "cond" exists) then make new variable with properties {name:"cond", value:"unknown"}
if not (variable "dew" exists) then make new variable with properties {name:"dew", value:"unknown"}
if not (variable "baro" exists) then make new variable with properties {name:"baro", value:"unknown"}
if not (variable "humid" exists) then make new variable with properties {name:"humid", value:"unknown"}
if not (variable "vis" exists) then make new variable with properties {name:"vis", value:"unknown"}
if not (variable "ptrend" exists) then make new variable with properties {name:"ptrend", value:"unknown"}
if not (variable "wether" exists) then make new variable with properties {name:"wether", value:"unknown"}
-- set the values of these variables in indigo
set the (value of variable "wind_dir") to wind_dir
set the (value of variable "temp") to temp
set the (value of variable "wind_speed") to wind_speed
set the (value of variable "cond") to cond
set the (value of variable "dew") to dew
set the (value of variable "baro") to baro
set the (value of variable "humid") to humid
set the (value of variable "vis") to vis
set the (value of variable "ptrend") to ptrend
set the (value of variable "wether") to wether
end GetWeather
end using terms from

Posted on
Mon Nov 24, 2003 10:05 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

(No subject)

I think the problem is because of the lines you removed from the script. Those lines defined the AppleScript (not Indigo) variables: wind_dir, cond, wether. Those variables are then used later in the script, but now they are not defined which is causing an error.

I got the script to work by also removing the following lines towards the bottom of the script:

set the (value of variable "wind_dir") to wind_dir
set the (value of variable "cond") to cond
set the (value of variable "wether") to wether

Alternatively, you could put back in the 3 lines at the top of the script that define these variables based on the objects returned from WeatherManX. It is a bit confusing, because there are the AppleScript variables and there are Indigo variables. They do not have to have the same names, but in this case they all do. The Indigo variables are all still being defined. It is just the AppleScript variables that get set at the top from the WeatherManX objects that don't exist in 3 cases in the script you posted (wind_dir, cond, wether).

Regards,
Matt

Posted on
Mon Nov 24, 2003 6:35 pm
pablo offline

(No subject)

Yes!!! It works. Well, I had to remove all but two lines to get it work. I just left the temp and the wind_speed in the script, but now it works perfectly. Thank you for your help... you guys are too kind :)

Posted on
Sun Nov 30, 2003 9:08 am
morps offline
Posts: 122
Joined: Nov 01, 2003

Re: Using Weatherman with Indigo

gregjsmith wrote:
I can then use it to plan irrigation scheduling.

Greg, can you expand a bit more on how you plan your irrigation with your script? Right now, I have a script that checks humidity and determines if I should even have the sprinklers go on that day or not. I would like to be able to look at the previous day's high and do something based on that. As I understand it, there isn't any way to get via Applescript forecast temps yet in Weatherman.

Thanks in advance for your input...

Posted on
Sun Nov 30, 2003 12:54 pm
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

My irrigation script is not complete and I probably wont work on it again till spring. Basically I need to determine when to water and how long to water. So I have variables in Indigo to keep track of the last 5 days of temp. I use the average of that to determine how long to water. I then look at the highs and other parameters to determine when to water (early morning, etc). I also keep track of when it last rained so I can adjust my scheduling based on that.

I'm hoping the improvements to Indigo for the rain8 will allow me not to have to worry about dealing with the different zones so I can just say "water at this time" and indigo takes care of the rest.

Posted on
Sat Dec 06, 2003 10:46 am
morps offline
Posts: 122
Joined: Nov 01, 2003

(No subject)

gregjsmith wrote:
I'm hoping the improvements to Indigo for the rain8 will allow me not to have to worry about dealing with the different zones so I can just say "water at this time" and indigo takes care of the rest.

Thanks for the feedback. I too hope that there will be some nice additions in a future release of Indigo. In the mean time, I have created a script that checks the humidity in my area and if it is greater than 97%, I disable a time/date action associated with my sprinklers. However, here is my challenge: My condition returns true (in this case, humidity greater than 97), yet the if statement doesn't seem to be working. Instead the else portion continues. Anyone have an idea of where I am going wrong here? I have double, even triple checked that the time/date action values are named the same as in my script, etc. I'm stumped. Thanks in advance...

Code: Select all
tell application "WeatherManX"
   set the lastMod to Update Time
   set the ConTime to Conditions Time
   -- This loop holds the script until WeathermanX does its update
   repeat until Update Time is greater than lastMod
      UpdateNow
   end repeat
   set the wet to the Humidity of City "Trabuco Canyon, CA"
end tell
using terms from application "Indigo"
   try
      if wet is greater than "97" then
         disable time date action "Sprinklers Lawns" for "86280"
         log "Sprinklers Lawns action disabled for 24 hours.¬
         Humidity is " & wet & "%.Will check again tomorrow."
         disable time date action "Sprinklers Flower Beds" for "86280"
         log "Sprinklers Flower Beds action disabled for 24 hours. ¬
          Humidity is " & wet & "%.Will check again tomorrow."
      else
         log "Weather check OK. Humidity is " & wet & "%. ¬
            Will continue with sprinklers as scheduled ¬
            based on conditions checked at " & ConTime
      end if
   end try
end using terms from

Posted on
Sat Dec 06, 2003 11:11 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

(No subject)

I think the problem is you are trying to use compare the variable wet to a string, not an number. I'm not sure if wet is a string or an integer, so I would recommend you be explicit and try this:

if (wet as integer) is greater than 97 then

Notice I dropped the quotes around 97, so it won't be treated as a string.

Regards,
Matt

Posted on
Sat Dec 06, 2003 5:09 pm
morps offline
Posts: 122
Joined: Nov 01, 2003

(No subject)

support wrote:
Notice I dropped the quotes around 97, so it won't be treated as a string.

As always, thanks for your constant support. And yup, you're suggestion did the trick! Thanks again...

Posted on
Thu May 20, 2004 8:19 pm
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

Here's my final weatherman script. I use it within WeathermanX, not within Indigo. Weatherman has the option to run a script based on certain situations. However there's no reason you couldn't set up a time date trigger to fire this off ever so often.

The variable names have changed because I may get my weather data from another source in the future. It also creates variable for the forecast. Every script I write that needs weather information refers to these variables.

The only missing last observation time which I hope the developer will add to weatherman in the future.

There is another script I use which runs at midnight that tracks the min and max temps for the last x days. I'll post that later.

edit: Here's another slight update. It gets every piece of possible data from weathermanx and puts min/max temp data in a list. The last observation time is available and the script has been modified for that.

--[url=applescript://com.apple.scripteditor/?action=new&script=property%20WMcityname%20%3A%20%22Albuquerque,%20NM%22%0A%0Atell%20application%20%22WeatherManX%22%0A%09--get%20values%20from%20weatherman%0A%09try%0A%09%09set%20the%20updatetime%20to%20the%20Update%20Time%20of%20City%20WMcityname%0A%09%09set%20the%20condtime%20to%20the%20Conditions%20Time%20of%20City%20WMcityname%0A%09%09set%20the%20temp%20to%20the%20Current%20Temperature%20of%20City%20WMcityname%0A%09%09set%20the%20baro%20to%20the%20Current%20Pressure%20of%20City%20WMcityname%0A%09%09set%20the%20ptrend%20to%20the%20Pressure%20Trend%20of%20City%20WMcityname%0A%09%09set%20the%20wind_speed%20to%20the%20Wind%20Speed%20of%20City%20WMcityname%20as%20real%0A%09%09set%20the%20winggust%20to%20the%20Wind%20Gust%20of%20City%20WMcityname%0A%09%09set%20the%20wind_dir%20to%20the%20Wind%20Direction%20of%20City%20WMcityname%0A%09%09set%20the%20humid%20to%20the%20Humidity%20of%20City%20WMcityname%0A%09%09set%20the%20windchill%20to%20the%20Wind%20Chill%20of%20City%20WMcityname%0A%09%09set%20the%20heatindex%20to%20the%20Heat%20Index%20of%20City%20WMcityname%0A%09%09set%20the%20dew%20to%20the%20Dewpoint%20of%20City%20WMcityname%0A%09%09set%20the%20cond%20to%20the%20Conditions%20of%20City%20WMcityname%0A%09%09set%20the%20wether%20to%20the%20Weather%20of%20City%20WMcityname%0A%09%09set%20the%20vis%20to%20the%20(Visibility%20of%20City%20WMcityname)%20as%20integer%0A%09%09set%20the%20windlongdir%20to%20the%20Long%20Compass%20Wind%20Direction%20of%20City%20WMcityname%0A%09%09set%20the%20windshortdir%20to%20the%20Short%20Compass%20Wind%20Direction%20of%20City%20WMcityname%0A%09%09set%20the%20forecastlist%20to%20Forecast%20of%20City%20WMcityname%0A%09end%20try%0Aend%20tell%0A%0Atell%20application%20%22Indigo%22%0A%09--create%20variables%20if%20they%20don't%20exsit%0A%09if%20not%20(variable%20%22weather_last_update%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_last_update%22,%20value%3A%22%20%22%7D%0A%09if%20not%20(variable%20%22weather_temperature%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_temperature%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_barometer%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_barometer%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_pressure_trend%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_pressure_trend%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_wind_speed%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_wind_speed%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_wind_gust%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_wind_gust%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_wind_direction%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_wind_direction%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_humidity%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_humidity%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_wind_chill%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_wind_chill%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_heat_index%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_heat_index%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_dewpoint%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_dewpoint%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_current_conditions%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_current_conditions%22,%20value%3A%22%20%22%7D%0A%09if%20not%20(variable%20%22weather_visibility%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_visibility%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_long_compass_wind_direction%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_long_compass_wind_direction%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_short_compass_wind_direction%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_short_compass_wind_direction%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_last_rain%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_last_rain%22,%20value%3A%220%22%7D%0A%09if%20not%20(variable%20%22weather_max_temps%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_max_temps%22,%20value%3A%220,0,0,0,0,0%22%7D%0A%09if%20not%20(variable%20%22weather_min_temps%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22weather_min_temps%22,%20value%3A%22800,800,800,800,800,800%22%7D%0A%09%0A%09--set%20the%20weather%20variables%0A%09set%20value%20of%20variable%20%22weather_last_update%22%20to%20condtime%0A%09set%20value%20of%20variable%20%22weather_temperature%22%20to%20temp%0A%09set%20value%20of%20variable%20%22weather_barometer%22%20to%20baro%0A%09set%20value%20of%20variable%20%22weather_pressure_trend%22%20to%20ptrend%0A%09set%20value%20of%20variable%20%22weather_wind_speed%22%20to%20wind_speed%0A%09set%20value%20of%20variable%20%22weather_wind_gust%22%20to%20winggust%0A%09set%20value%20of%20variable%20%22weather_wind_direction%22%20to%20wind_dir%0A%09set%20value%20of%20variable%20%22weather_humidity%22%20to%20humid%0A%09set%20value%20of%20variable%20%22weather_wind_chill%22%20to%20windchill%0A%09set%20value%20of%20variable%20%22weather_heat_index%22%20to%20heatindex%0A%09set%20value%20of%20variable%20%22weather_dewpoint%22%20to%20dew%0A%09if%20(wether%20%3D%20%22%22)%20then%0A%09%09set%20wmCond%20to%20cond%0A%09else%0A%09%09set%20wmCond%20to%20cond%20%26%20%22%20skies%20with%20%22%20%26%20wether%0A%09end%20if%0A%09set%20value%20of%20variable%20%22weather_current_conditions%22%20to%20wmCond%0A%09set%20value%20of%20variable%20%22weather_visibility%22%20to%20vis%0A%09set%20value%20of%20variable%20%22weather_long_compass_wind_direction%22%20to%20windlongdir%0A%09set%20value%20of%20variable%20%22weather_short_compass_wind_direction%22%20to%20windshortdir%0A%09--check%20to%20see%20if%20it's%20raining%20and%20log%20date%2Ftime%0A%09if%20((cond%20contains%20%22Rain%22)%20or%20(cond%20contains%20%22Mist%22)%20or%20(cond%20contains%20%22Drizzle%22)%20or%20(cond%20contains%20%22Snow%22)%20or%20(cond%20contains%20%22Sleet%22)%20or%20(cond%20contains%20%22Thunderstorm%22)%20or%20(wether%20contains%20%22Rain%22)%20or%20(wether%20contains%20%22Mist%22)%20or%20(wether%20contains%20%22Drizzle%22)%20or%20(wether%20contains%20%22Snow%22)%20or%20(wether%20contains%20%22Sleet%22)%20or%20(wether%20contains%20%22Thunderstorm%22))%20and%20(cond%20does%20not%20contain%20%22Clear%22)%20then%20set%20value%20of%20variable%20%22weather_last_rain%22%20to%20(current%20date)%20as%20string%0A%09--Set%20max%20and%20min%20temp%20of%20day%0A%09set%20VarVal%20to%20value%20of%20variable%20%22weather_max_temps%22%0A%09set%20OldDelims%20to%20AppleScript's%20text%20item%20delimiters%0A%09set%20AppleScript's%20text%20item%20delimiters%20to%20%22,%22%0A%09set%20theText%20to%20the%20text%20items%20of%20VarVal%0A%09set%20AppleScript's%20text%20item%20delimiters%20to%20OldDelims%0A%09if%20the%20temp%20%3E%20item%201%20of%20theText%20then%0A%09%09set%20item%201%20of%20theText%20to%20the%20temp%0A%09%09repeat%20with%20i%20from%201%20to%20(length%20of%20theText)%0A%09%09%09if%20i%20is%201%20then%0A%09%09%09%09set%20VarVal%20to%20item%20i%20of%20theText%0A%09%09%09else%0A%09%09%09%09set%20VarVal%20to%20VarVal%20%26%20%22,%22%20%26%20item%20i%20of%20theText%0A%09%09%09end%20if%0A%09%09end%20repeat%0A%09%09set%20value%20of%20variable%20%22weather_max_temps%22%20to%20VarVal%0A%09end%20if%0A%09set%20VarVal%20to%20value%20of%20variable%20%22weather_min_temps%22%0A%09set%20OldDelims%20to%20AppleScript's%20text%20item%20delimiters%0A%09set%20AppleScript's%20text%20item%20delimiters%20to%20%22,%22%0A%09set%20theText%20to%20the%20text%20items%20of%20VarVal%0A%09set%20AppleScript's%20text%20item%20delimiters%20to%20OldDelims%0A%09if%20the%20temp%20%3C%20item%201%20of%20theText%20then%0A%09%09set%20item%201%20of%20theText%20to%20the%20temp%0A%09%09repeat%20with%20i%20from%201%20to%20(length%20of%20theText)%0A%09%09%09if%20i%20is%201%20then%0A%09%09%09%09set%20VarVal%20to%20item%20i%20of%20theText%0A%09%09%09else%0A%09%09%09%09set%20VarVal%20to%20VarVal%20%26%20%22,%22%20%26%20item%20i%20of%20theText%0A%09%09%09end%20if%0A%09%09end%20repeat%0A%09%09set%20value%20of%20variable%20%22weather_min_temps%22%20to%20VarVal%0A%09end%20if%0A%09if%20temp%20%3E%20value%20of%20variable%20%22WMMaxTempToday%22%20then%0A%09%09set%20value%20of%20variable%20%22WMMaxTempToday%22%20to%20temp%0A%09end%20if%0A%09if%20temp%20%3C%20value%20of%20variable%20%22WMMinTempToday%22%20then%0A%09%09set%20value%20of%20variable%20%22WMMinTempToday%22%20to%20temp%0A%09end%20if%0A%09%0A%09--go%20through%20all%20variable%20and%20delete%20variables%20related%20to%20forecast%0A%09set%20i%20to%201%0A%09repeat%20(count%20of%20variables)%20times%0A%09%09if%20name%20of%20variable%20i%20contains%20%22weather_forecast%22%20then%0A%09%09%09delete%20variable%20i%0A%09%09else%0A%09%09%09set%20i%20to%20i%20+%201%0A%09%09end%20if%0A%09end%20repeat%0A%09--create%20variable%20for%20the%20forecast%0A%09repeat%20with%20dayforecast%20in%20forecastlist%0A%09%09set%20dayStr%20to%20item%201%20of%20dayforecast%0A%09%09set%20forecastStr%20to%20item%202%20of%20dayforecast%0A%09%09set%20varname%20to%20searchReplace(%22weather%20forecast%20%22%20%26%20dayStr,%20%22%20%22,%20%22_%22)%0A%09%09if%20not%20(variable%20varname%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3Avarname,%20value%3AforecastStr%7D%0A%09end%20repeat%0Aend%20tell%0A%0Aon%20settemp(var,%20temp)%0A%09tell%20application%20%22Indigo%22%0A%09%09%0A%09end%20tell%0Aend%20settemp%0A%0Aon%20searchReplace(theText,%20SearchString,%20ReplaceString)%0A%09set%20OldDelims%20to%20AppleScript's%20text%20item%20delimiters%0A%09set%20AppleScript's%20text%20item%20delimiters%20to%20SearchString%0A%09set%20newText%20to%20text%20items%20of%20theText%0A%09set%20AppleScript's%20text%20item%20delimiters%20to%20ReplaceString%0A%09set%20newText%20to%20newText%20as%20text%0A%09set%20AppleScript's%20text%20item%20delimiters%20to%20OldDelims%0A%09return%20newText%0Aend%20searchReplace]Click here to open this script in a new Script Editor window[/url].

property WMcityname : "Albuquerque, NM"

tell application "WeatherManX"
     --get values from weatherman
     try
          set the updatetime to the Update Time of City WMcityname
          set the condtime to the Conditions Time of City WMcityname
          set the temp to the Current Temperature of City WMcityname
          set the baro to the Current Pressure of City WMcityname
          set the ptrend to the Pressure Trend of City WMcityname
          set the wind_speed to the Wind Speed of City WMcityname as real
          set the winggust to the Wind Gust of City WMcityname
          set the wind_dir to the Wind Direction of City WMcityname
          set the humid to the Humidity of City WMcityname
          set the windchill to the Wind Chill of City WMcityname
          set the heatindex to the Heat Index of City WMcityname
          set the dew to the Dewpoint of City WMcityname
          set the cond to the Conditions of City WMcityname
          set the wether to the Weather of City WMcityname
          set the vis to the (Visibility of City WMcityname) as integer
          set the windlongdir to the Long Compass Wind Direction of City WMcityname
          set the windshortdir to the Short Compass Wind Direction of City WMcityname
          set the forecastlist to Forecast of City WMcityname
     end try
end tell

tell application "Indigo"
     --create variables if they don't exsit
     if not (variable "weather_last_update" exists) then make new variable with properties {name:"weather_last_update", value:" "}
     if not (variable "weather_temperature" exists) then make new variable with properties {name:"weather_temperature", value:"0"}
     if not (variable "weather_barometer" exists) then make new variable with properties {name:"weather_barometer", value:"0"}
     if not (variable "weather_pressure_trend" exists) then make new variable with properties {name:"weather_pressure_trend", value:"0"}
     if not (variable "weather_wind_speed" exists) then make new variable with properties {name:"weather_wind_speed", value:"0"}
     if not (variable "weather_wind_gust" exists) then make new variable with properties {name:"weather_wind_gust", value:"0"}
     if not (variable "weather_wind_direction" exists) then make new variable with properties {name:"weather_wind_direction", value:"0"}
     if not (variable "weather_humidity" exists) then make new variable with properties {name:"weather_humidity", value:"0"}
     if not (variable "weather_wind_chill" exists) then make new variable with properties {name:"weather_wind_chill", value:"0"}
     if not (variable "weather_heat_index" exists) then make new variable with properties {name:"weather_heat_index", value:"0"}
     if not (variable "weather_dewpoint" exists) then make new variable with properties {name:"weather_dewpoint", value:"0"}
     if not (variable "weather_current_conditions" exists) then make new variable with properties {name:"weather_current_conditions", value:" "}
     if not (variable "weather_visibility" exists) then make new variable with properties {name:"weather_visibility", value:"0"}
     if not (variable "weather_long_compass_wind_direction" exists) then make new variable with properties {name:"weather_long_compass_wind_direction", value:"0"}
     if not (variable "weather_short_compass_wind_direction" exists) then make new variable with properties {name:"weather_short_compass_wind_direction", value:"0"}
     if not (variable "weather_last_rain" exists) then make new variable with properties {name:"weather_last_rain", value:"0"}
     if not (variable "weather_max_temps" exists) then make new variable with properties {name:"weather_max_temps", value:"0,0,0,0,0,0"}
     if not (variable "weather_min_temps" exists) then make new variable with properties {name:"weather_min_temps", value:"800,800,800,800,800,800"}
     
     --set the weather variables
     set value of variable "weather_last_update" to condtime
     set value of variable "weather_temperature" to temp
     set value of variable "weather_barometer" to baro
     set value of variable "weather_pressure_trend" to ptrend
     set value of variable "weather_wind_speed" to wind_speed
     set value of variable "weather_wind_gust" to winggust
     set value of variable "weather_wind_direction" to wind_dir
     set value of variable "weather_humidity" to humid
     set value of variable "weather_wind_chill" to windchill
     set value of variable "weather_heat_index" to heatindex
     set value of variable "weather_dewpoint" to dew
     if (wether = "") then
          set wmCond to cond
     else
          set wmCond to cond & " skies with " & wether
     end if
     set value of variable "weather_current_conditions" to wmCond
     set value of variable "weather_visibility" to vis
     set value of variable "weather_long_compass_wind_direction" to windlongdir
     set value of variable "weather_short_compass_wind_direction" to windshortdir
     --check to see if it's raining and log date/time
     if ((cond contains "Rain") or (cond contains "Mist") or (cond contains "Drizzle") or (cond contains "Snow") or (cond contains "Sleet") or (cond contains "Thunderstorm") or (wether contains "Rain") or (wether contains "Mist") or (wether contains "Drizzle") or (wether contains "Snow") or (wether contains "Sleet") or (wether contains "Thunderstorm")) and (cond does not contain "Clear") then set value of variable "weather_last_rain" to (current date) as string
     --Set max and min temp of day
     set VarVal to value of variable "weather_max_temps"
     set OldDelims to AppleScript's text item delimiters
     set AppleScript's text item delimiters to ","
     set theText to the text items of VarVal
     set AppleScript's text item delimiters to OldDelims
     if the temp > item 1 of theText then
          set item 1 of theText to the temp
          repeat with i from 1 to (length of theText)
               if i is 1 then
                    set VarVal to item i of theText
               else
                    set VarVal to VarVal & "," & item i of theText
               end if
          end repeat
          set value of variable "weather_max_temps" to VarVal
     end if
     set VarVal to value of variable "weather_min_temps"
     set OldDelims to AppleScript's text item delimiters
     set AppleScript's text item delimiters to ","
     set theText to the text items of VarVal
     set AppleScript's text item delimiters to OldDelims
     if the temp < item 1 of theText then
          set item 1 of theText to the temp
          repeat with i from 1 to (length of theText)
               if i is 1 then
                    set VarVal to item i of theText
               else
                    set VarVal to VarVal & "," & item i of theText
               end if
          end repeat
          set value of variable "weather_min_temps" to VarVal
     end if
     if temp > value of variable "WMMaxTempToday" then
          set value of variable "WMMaxTempToday" to temp
     end if
     if temp < value of variable "WMMinTempToday" then
          set value of variable "WMMinTempToday" to temp
     end if
     
     --go through all variable and delete variables related to forecast
     set i to 1
     repeat (count of variables) times
          if name of variable i contains "weather_forecast" then
               delete variable i
          else
               set i to i + 1
          end if
     end repeat
     --create variable for the forecast
     repeat with dayforecast in forecastlist
          set dayStr to item 1 of dayforecast
          set forecastStr to item 2 of dayforecast
          set varname to searchReplace("weather forecast " & dayStr, " ", "_")
          if not (variable varname exists) then make new variable with properties {name:varname, value:forecastStr}
     end repeat
end tell

on settemp(var, temp)
     tell application "Indigo"
          
     end tell
end settemp

on searchReplace(theText, SearchString, ReplaceString)
     set OldDelims to AppleScript's text item delimiters
     set AppleScript's text item delimiters to SearchString
     set newText to text items of theText
     set AppleScript's text item delimiters to ReplaceString
     set newText to newText as text
     set AppleScript's text item delimiters to OldDelims
     return newText
end searchReplace


-------------------------
[This script was automatically tagged for color coded syntax by Script to Markup Code]

Posted on
Mon Jun 28, 2004 8:47 pm
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

I've written a script that gets weather data from the NOAA website without needing any 3rd party program. It only gets the basic set of data, not everything Weatherman gets. But it's an alternative.

Read about it here

Posted on
Fri May 27, 2005 8:48 pm
wallachee offline
Posts: 141
Joined: Apr 30, 2005

(No subject)

Can someone explain how to get the variables from WeatherMan into Indigo? Whenever I run the applescript from above I get the following error

"The variable condtime is not defined."

It does this for every variable...like it is not properly communicating with WeatherMan....any ideas what I'm doing wrong?

-Bradley

Who is online

Users browsing this forum: No registered users and 7 guests