Using Weatherman with Indigo

Posted on
Mon Oct 20, 2003 9:20 pm
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

Using Weatherman with Indigo

Dean Davis has a nice program that can get weather from the internet called WeathermanX. It's fully applescriptable and you can use it to put weather values into Indigo. Here is a basic sample of how to get the data from Weatherman:

Code: Select all
tell application "WeatherManX"
   --
   
   set the wind_dir to the Wind Direction of City "Albuquerque, NM"
   set the temp to the Current Temperature of City "Albuquerque, NM"
   set the wind_speed to the Wind Speed of City "Albuquerque, NM" as real
   set the cond to the Conditions of City "Albuquerque, NM"
   set the dew to the Dewpoint of City "Albuquerque, NM"
   set the baro to the Current Pressure of City "Albuquerque, NM"
   set the humid to the Humidity of City "Albuquerque, NM"
   set the vis to the (Visibility of City "Albuquerque, NM") as integer
   set the ptrend to the Pressure Trend of City "Albuquerque, NM"
   set the wether to the Weather of City "Albuquerque, NM"
   
end tell


In this case my city is Albuquerque, NM but you would replace that with whatever you need. I have my script set to put these applescript variables to Indigo variables that update every 15 minutes. I can then use it to plan irrigation scheduling.

Posted on
Mon Nov 10, 2003 9:32 am
dalenis offline
Posts: 123
Joined: Apr 02, 2003
Location: Lunenburg, MA

(No subject)

Hi Greg,

I need some help.....I can't figure out how to get WeatherMan X data into Indigo variables. Heck I can't figure out how to get anything into the Indigo variables. What is the correct syntax to get any information into Indigo variables....could you or someone post a simple example.

Thanks,

Dale

Posted on
Mon Nov 10, 2003 11:37 am
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

Try something like this:

Code: Select all
set the (value of variable "MyIndigoVariable") to temp

Posted on
Mon Nov 10, 2003 12:10 pm
dalenis offline
Posts: 123
Joined: Apr 02, 2003
Location: Lunenburg, MA

(No subject)

Thanks Greg.....worked like a charm! I really need to take the time and learn all the in's and out's of AppleScript!

Thanks,

Dale

Posted on
Mon Nov 10, 2003 1:14 pm
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

Don't feel bad. I don't know it that well either. I mostly learn from taking apart other people's script and asking a lot of questions on the various Applescript mailing lists I belong to.

Posted on
Mon Nov 10, 2003 2:25 pm
dalenis offline
Posts: 123
Joined: Apr 02, 2003
Location: Lunenburg, MA

(No subject)

That is how I have been learning as well. What list are you subscribed to? I just signed up to Apple's list.....

Thanks,

Dale

Posted on
Mon Nov 17, 2003 11:39 pm
Ewicp offline
Posts: 28
Joined: Jul 08, 2003
Location: Tempe, Arizona

(No subject)

Greetings.
With the help of my Unix-Savvy buddy, I have a shell script running that goes to the National Weather Service (I think) website and pulls information that is then stored as a text file. It does this every four hours. What I would like to do is take some of these values and put them into Indigo as variables. IE: dew point, temp, wind speed, etc. Anyone know of a script that can do this from a text file?
Thanks.

Eric

Posted on
Tue Nov 18, 2003 12:40 am
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

There is a example applescript that is installed somewhere with osx that uses soap to get the latest weather. Might be a starting point.

It's installed where the applescript menu is and is called "internet weather by zip" under the "internet scripts"

Posted on
Sat Nov 22, 2003 12:04 am
pablo offline

(No subject)

ok.. I'm a total newbie at this applescript. Can someone explain in detail how you use that script to get values from weatherman X into indigo? Thanks.

Posted on
Sat Nov 22, 2003 12:59 am
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

Here is an updated script that will do 3 things:

1) Get the values from WeathermanX
2) Create variables in Indigo if they don't exist.
3) Put the values of weatherman into the indigo variables.

This is intended to be a attachment script so use GetWeather in the Applescript area of a trigger to use this.

Note that you might want to change some of the variable names to suite your taste. It's just an example to get you started.

--[url=applescript://com.apple.scripteditor/?action=new&script=using%20terms%20from%20application%20%22Indigo%22%0A%09on%20GetWeather()%0A%09%09--get%20the%20values%20from%20weatherman%0A%09%09tell%20application%20%22WeatherManX%22%0A%09%09%09set%20the%20wind_dir%20to%20the%20Wind%20Direction%20of%20City%20%22Albuquerque,%20NM%22%0A%09%09%09set%20the%20temp%20to%20the%20Current%20Temperature%20of%20City%20%22Albuquerque,%20NM%22%0A%09%09%09set%20the%20wind_speed%20to%20the%20Wind%20Speed%20of%20City%20%22Albuquerque,%20NM%22%20as%20real%0A%09%09%09set%20the%20cond%20to%20the%20Conditions%20of%20City%20%22Albuquerque,%20NM%22%0A%09%09%09set%20the%20dew%20to%20the%20Dewpoint%20of%20City%20%22Albuquerque,%20NM%22%0A%09%09%09set%20the%20baro%20to%20the%20Current%20Pressure%20of%20City%20%22Albuquerque,%20NM%22%0A%09%09%09set%20the%20humid%20to%20the%20Humidity%20of%20City%20%22Albuquerque,%20NM%22%0A%09%09%09set%20the%20vis%20to%20the%20(Visibility%20of%20City%20%22Albuquerque,%20NM%22)%20as%20integer%0A%09%09%09set%20the%20ptrend%20to%20the%20Pressure%20Trend%20of%20City%20%22Albuquerque,%20NM%22%0A%09%09%09set%20the%20wether%20to%20the%20Weather%20of%20City%20%22Albuquerque,%20NM%22%0A%09%09end%20tell%0A%09%09--create%20variable%20if%20they%20don't%20exsit%0A%09%09if%20not%20(variable%20%22wind_dir%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22wind_dir%22,%20value%3A%22unknown%22%7D%0A%09%09if%20not%20(variable%20%22temp%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22temp%22,%20value%3A%22unknown%22%7D%0A%09%09if%20not%20(variable%20%22wind_speed%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22wind_speed%22,%20value%3A%22unknown%22%7D%0A%09%09if%20not%20(variable%20%22cond%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22cond%22,%20value%3A%22unknown%22%7D%0A%09%09if%20not%20(variable%20%22dew%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22dew%22,%20value%3A%22unknown%22%7D%0A%09%09if%20not%20(variable%20%22baro%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22baro%22,%20value%3A%22unknown%22%7D%0A%09%09if%20not%20(variable%20%22humid%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22humid%22,%20value%3A%22unknown%22%7D%0A%09%09if%20not%20(variable%20%22vis%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22vis%22,%20value%3A%22unknown%22%7D%0A%09%09if%20not%20(variable%20%22ptrend%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22ptrend%22,%20value%3A%22unknown%22%7D%0A%09%09if%20not%20(variable%20%22wether%22%20exists)%20then%20make%20new%20variable%20with%20properties%20%7Bname%3A%22wether%22,%20value%3A%22unknown%22%7D%0A%09%09--set%20the%20values%20of%20these%20variables%20in%20indigo%0A%09%09set%20the%20(value%20of%20variable%20%22wind_dir%22)%20to%20wind_dir%0A%09%09set%20the%20(value%20of%20variable%20%22temp%22)%20to%20temp%0A%09%09set%20the%20(value%20of%20variable%20%22wind_speed%22)%20to%20wind_speed%0A%09%09set%20the%20(value%20of%20variable%20%22cond%22)%20to%20cond%0A%09%09set%20the%20(value%20of%20variable%20%22dew%22)%20to%20dew%0A%09%09set%20the%20(value%20of%20variable%20%22baro%22)%20to%20baro%0A%09%09set%20the%20(value%20of%20variable%20%22humid%22)%20to%20humid%0A%09%09set%20the%20(value%20of%20variable%20%22vis%22)%20to%20vis%0A%09%09set%20the%20(value%20of%20variable%20%22ptrend%22)%20to%20ptrend%0A%09%09set%20the%20(value%20of%20variable%20%22wether%22)%20to%20wether%0A%09end%20GetWeather%0Aend%20using%20terms%20from]Click here to open this script in a new Script Editor window[/url].

using terms from application "Indigo"
     on GetWeather()
          --get the values from weatherman
          tell application "WeatherManX"
               set the wind_dir to the Wind Direction of City "Albuquerque, NM"
               set the temp to the Current Temperature of City "Albuquerque, NM"
               set the wind_speed to the Wind Speed of City "Albuquerque, NM" as real
               set the cond to the Conditions of City "Albuquerque, NM"
               set the dew to the Dewpoint of City "Albuquerque, NM"
               set the baro to the Current Pressure of City "Albuquerque, NM"
               set the humid to the Humidity of City "Albuquerque, NM"
               set the vis to the (Visibility of City "Albuquerque, NM") as integer
               set the ptrend to the Pressure Trend of City "Albuquerque, NM"
               set the wether to the Weather of City "Albuquerque, NM"
          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
Sat Nov 22, 2003 8:14 am
Guest offline

(No subject)

Thanks for the script. I copied and pasted this script into the script editor, I did a save as "weather" into the script folder in the indigo folder. Then I set up a timed action to run the script every X minutes. So what do I do now?

Posted on
Sat Nov 22, 2003 9:52 am
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

(No subject)

Does the script work? Is is putting data into the variables?

Posted on
Sat Nov 22, 2003 9:57 am
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

(No subject)

Anonymous wrote:
I did a save as "weather" into the script folder in the indigo folder.


Be sure and save the script into the Indigo User Data/scripts/attachments/ folder (not just the scripts folder). To make the attachment (the GetWeather() function) available you will need to either restart Indigo or choose "Reload Attachments" from the script menu.

Regards,
Matt

Posted on
Sat Nov 22, 2003 5:27 pm
pablo offline

(No subject)

I'm not sure I'm setting this up correctly. Right now I have a timed action called getweather. The script "getweather.scp" is set to run every 15 minutes.

Getweather

Time/Date Trigger
Every: 15.0 minutes
Everyday

Condition: Always

Action
Execute Applescript
File: getweather.scp

I also have created a variable called temp..which is set to 30 (?). I'm not sure what the default value should be? Then I have a Trigger action setup called "temp over 34". Also, I thought the script would create new variable if they are not created already? Should I be bale to see these in the variable list window?

THE TRIGGER
TYPE: Variable Changed,
Var: Temp
Becomes greater than: 34

Condition: Always

Send Device action
Action: Turn On
Device: Space Heater


Nothing seems to happen when I execute this action. Any ideas? Or Am I doing this all wrong? Thanks for your help.

Posted on
Sat Nov 22, 2003 5:37 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

(No subject)

Ahh, now I see the problem you are having. Greg posted an attachment script which defines a new function GetWeather(), that you should call in your action. You don't want to try to run the attachment script you saved, you just want Indigo to load it so you can use call function (just having the script inside the attachments folder will cause Indigo to automatically load the script).

So, inside your Time/Date Action you should have an AppleScript action that is just a single line:

GetWeather()

Don't have the Action run an external AppleScript file at all, just select the radio button that lets you type AppleScript directly into the dialog.

Regards,
Matt

Who is online

Users browsing this forum: No registered users and 4 guests

cron