My iPhone 4 control page

Posted on
Wed Jan 05, 2011 12:41 pm
scotsman offline
Posts: 66
Joined: Aug 14, 2010
Location: Austin, Texas

My iPhone 4 control page

Thought I might share my control page for my iPhone 4. I created a floor plan in photoshop to be the exact width of the iPhone 4 screen. It needed to be scrollable to comfortably fit all 3 floors in. It was designed to be as simple as possible (and wife friendly!). I found the simple floor plan much better than any 3D view that I experimented with.

- The weather link at the top takes you to a dedicated page with a 6 day forecast, pulled from a weather underground xml feed. I have nice weather icons refresh that I found online.

- I created custom buttons and graphics to create an engaging visual design. Sorry indigo - didn't like your light icons...

- I keep the amount of scenes to two for each floor, making things very simple. The scene buttons live under each floor as do the thermostat controls, visually linking activities to place.

- There is a 'master' light switch at each floor to switch all on or all off - needed some applescript gymnastics with help from Jay (thanks!) to get those working properly.

- Hitting the temperature brings up the thermostat controls.

Still a work in progress. I want to add further links to control the 'House Mode', create an iPad version, integrate the house music system, sprinklers and alarm. It would be great to be able to pull a video camera feed in as well, but I don't believe I can do that yet. Oh and I'd like to be able to monitor my solar panel performance too.

Loving the custom control page functionality, and simple applescript extensions. Hungry for more. (e.g. adding my own tab bar, better display of long variables like a multi-line weather forecast, cut and paste between control pages, aligning tools, better font control, customized layouts for different orientation etc.).

I am an interaction designer for a living so hence the care with the design. Has become the most useful app I have. I have come to use only the control pages, and my wife actually uses it all the time (although she doesn't like me controlling the lights when I am at work...) It looks great on the hi-res retina display.
Last edited by scotsman on Wed Apr 27, 2011 7:51 am, edited 1 time in total.

Posted on
Wed Jan 05, 2011 2:11 pm
kendals offline
Posts: 95
Joined: May 24, 2004

Re: My iPhone 4 control page

Wow! These pages are some of the best I have seen yet!! Care to share your scripts / icons with others? I love the control pages (especially the weather..is it a constantly live updating button?), but am not very good at the programming to get some great functionality like you have.

Scott

Posted on
Thu Jan 06, 2011 6:46 pm
AlaskaDave offline
User avatar
Posts: 293
Joined: Oct 16, 2008
Location: Juneau, Alaksa

Re: My iPhone 4 control page

Very clean and nice...love the look! Must load fast as well. I need to simplify mine. Tried to get too crazy and as a result takes too long to load. Would love to get my weather icon to display... have any tips on how you got this to update? In Alaska I'm having a rough time finding a reliable feed for my area. Seems that they come and go over time and no station is all that close to my house and with our micro climates might just have to install a weather station myself in the future. Thanks for sharing.

Posted on
Thu Jan 06, 2011 8:03 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: My iPhone 4 control page

Great design -- thanks for sharing!

Image

Posted on
Sat Jan 08, 2011 3:36 pm
scotsman offline
Posts: 66
Joined: Aug 14, 2010
Location: Austin, Texas

Re: My iPhone 4 control page

Thanks!
Care to share your scripts / icons with others?


Scripts are still in progress, but they were all based on berkinet's adjustment of the NOAA script on the Indigo website (Wunderground_sync-V2_5). I am enlarging it to include a moon phase and 6 day weather forecast. Watch this space. The original script is downloadable from Indigo I believe.

I'd like to share my zip file of weather images, but I can't upload a zip onto the forum. Any suggestions?

the weather..is it a constantly live updating button?


Yes! It even changes at night time. All part of the Berkinet's excellent script.

Alskadave - the script does include a method of updating the icon. But can't help you with Alaska weather stations.

I'll update as I build it out.

Posted on
Sun Jan 09, 2011 5:36 am
kendals offline
Posts: 95
Joined: May 24, 2004

Re: My iPhone 4 control page

Sine you cannot upload a zip file into the forum, you might have to do a link to a 3rd party site so that we can get to the files.

Posted on
Sun Jan 09, 2011 9:15 am
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: My iPhone 4 control page

Could you upload the file to the User Contribution Library?

Posted on
Sun Feb 13, 2011 6:48 pm
hammer32 offline
Posts: 66
Joined: May 13, 2006
Location: Copperas Cove, TX

Re: My iPhone 4 control page

Scotsman inspired me to work on an iPhone interface this weekend. I borrowed heavily from him as well as from another user, whose post I cannot locate at the moment...

I followed scotsman's lead in using the built-in NOAA Weather script and found icons on the internet. The only issue I have is that NOAA has a number of weather descriptions with a "/" in them, such as "Heavy Rain Fog/Mist", the full list can be found here: http://www.nws.noaa.gov/xml/current_obs/weather.php , I can put the "/" in the image file name, but Indigo understandably doesn't like them and won't load their icon.

I'm using WiFi to detect the presence of our iPhones to automatically set the home/away status (reference: viewtopic.php?f=4&t=4894&start=15 ). I ping the iPhones every ten minutes at their reserved LAN IP address. If they're not detected then, I send an email that gets received by the Push Mail app (WiFi goes to sleep when the screen is locked, this turns on WiFi briefly) and re-ping. After a set time the house goes into "away" mode and attempts to cultivate the 'lived in' look at sunset.

Like the weather icon, the buttons change based on variables set when they're pressed. Button templates from: http://www.teehanlax.com/blog/2010/08/1 ... a-display/

Image

Image

Image

Image

Posted on
Sun Feb 13, 2011 6:56 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: My iPhone 4 control page

Thanks for sharing, and more importantly thank goodness neither of you were home when the funnel cloud hit.

Image

Posted on
Sun Feb 13, 2011 10:54 pm
scotsman offline
Posts: 66
Joined: Aug 14, 2010
Location: Austin, Texas

Re: My iPhone 4 control page

Nice! love the auto-detection of people in the house. How does it work in practice? If your phone runs out of batteries, does your house automatically go into shutdown mode? What does "Sleep Owen" mean? And what does "Sleep House" mean?

Next thing I want to do is put some sort of house status variable together.

By the way I managed to upload my collection of weather icons to the user contribution library if anyone wants to user them in their own projects - I only just did it though so it may take a moment to get checked.

Here's my latest addition - a dedicated weather page and 5-day forecast. You tap the button at the top of the main page to go to the weather.

photo 1.png
photo 1.png (54.45 KiB) Viewed 11409 times


photo 2.png
photo 2.png (71.6 KiB) Viewed 11409 times


Here's my adjusted Weather Underground script that provides the 6 day forecast and various other tweaks. It may not be pretty but works for me. No guarantees included!
Code: Select all
(*
"Wunderground Script" for Indigo
 by Richard Perlman, and based on the original NOAA script written by
 Karl Smith and modified by Matt Bendiksen
 
 V. 3 Modified by Andrew Nairn
------------------------------------------------------------------------------------
Description:
--------------
  The Wunderground (Weather Underground) Script will poll a
  Wunderground Station and/or PWS (Personal Weather Station)
  to retreive the latest weather information for the
  specified station code(s). The weather information
  is saved into Indigo Variables that can be used as desired.
 
  Look in the Description tab for more information and the
  development history/Change Log.

Installation and setup instructions:
------------------------------------------
  1) Place this script in Indigo's Background Tasks folder or any other folder of
your choosing..

  2) Lookup your Wunderground  station code(s):

  For Personal Weather Stations (PWS) go to...
   http://www.wunderground.com/weatherstation/index.asp
   
   If you want to use an airport station, find out the code
   for your airport. This is usually a "K" followed by the 3 letter airport code.
  For example, the code for San Francisco  (SFO) is KSFO.

  3) In Indigo use the Variable Window to enter the codes for the station(s)
   you have selected
   For PWSs create an Indigo variable _Wunderground_PWS_List and set the
   value to one or more PWS codes separated by commas.
   For example,  KCAREDDI3,KCAREDDI2
   
   For an Airport station, create an Indigo variable _Wunderground_APT and use
  the airport station code as the value.
 
  For a 6-day forecast create an Indigo variable _Wunderground_ZIP and populate it with your zip code.
 
  4) In this script select the specific data fields you wish to monitor in the
  properties section below. Read the comments above that section for more
 information. Note that the default is to collect most data from a PWS and
 only get the weather condition and icon name from the airport station.
 
 5) If you want to use the daily High/Low feature (on by default),
 then you need to create the following variables in Indigo:
 Last_High_Time
 Last_High_Temp
 Last_Low_Time
 Last_Low_Temp
 Local_High_Time
 Local_High_Temp
 Local_Low_Time
 Local_Low_Temp
 LastCheck
 
  6) If you wish to use the weather icon feature, for example in a control page,
 put the icons folder, "Observation_Icons" into the Indigo variable images folder.
 Library-> Application Support-> Perceptive Automation-> Indigo 4->
               IndigoWebServer-> images-> controls-> variables
Then create the following Indigo variables:
 Wunderground_Condition
 Wunderground_Icon

 You may use other images, but they must have the same names as the included files.
 If you do want to use icons in a control page, just display "Variable Value" for the
variable "Wunderground_Icon" as image "current.png" If you don't want to use the
icoms, you should change the runSetIcon property to  false.
 
   7) In Indigo, Create a Time/Date Trigger and select an Action Type of "Execute AppleScript"
that executes this script file. This script file will then be called at the times/frequency
you defined for the trigger.

License:
  Wunderground Script is released under the GNU general public license.
------------------------------------------------------------------------------------
*)
-- Before we get started, make sure another instance of this script is not running
-- Before we get started, make sure another instance of this script is not running
if not dupeProcCheck("Wunderground") then
   LogWunderground("Cancelled attempt to start script while another instance was running.", "", 0)
   error number -128
end if

set debug to true
-- *----------------- USER DEFINED VARIABLES -----------------------*

-- The following two property sections define the  fields to be retrieved from the XML data
-- from the XML data. These should be seto to either the source of the data:
-- "PWS" for Personal Weather Stations, or
-- "APT": for Airport stations,
-- or "" (Null) for fields you do not wish to retrieve and save in Indigo

-- The following fields are available from airport and personal weather stations
property GetDewpointC : ""
property GetDewpointF : ""
property GetDewpointString : ""
property GetElevation : "PWS"
property GetHeatIndexC : ""
property GetHeatIndexF : ""
property GetHeatIndexString : ""
property GetObservationTime : "PWS"
property GetPrecip_1hr_in : "PWS"
property GetPrecip_1hr_m : ""
property GetPrecip_1hr_string : ""
property GetPrecip_today_in : "PWS"
property GetPrecip_today_m : ""
property GetPrecip_today_string : "PWS"
property GetPressureIN : "PWS"
property GetPressureMB : ""
property GetPressureString : ""
property GetRelativeHumidity : "PWS"
property GetTempC : "PWS"
property GetTempF : "PWS"
property GetTempString : ""
property GetWindDegrees : ""
property GetWindDirection : ""
property GetWindGustMPH : ""
property GetWindMPH : ""
property GetWindString : "PWS"
property GetWindchillC : ""
property GetWindchillF : ""
property GetWindchillString : ""
property GetObservationTimerfc822 : "PWS"
property GetStationID : "PWS"
property GetFull : "PWS"
property GetNeighborhood : ""
property GetCity : "PWS"
property GetState : ""
property GetZip : ""
property GetLatitude : ""
property GetLongitude : ""

-- The following fields are usually only available from an airport station
property GetWeather : "APT"
property GetIcon : "APT"

-- The following fields are available from the weather underground 7-day forecast
property GetDay1Period1Name : "Forecast"
property GetDay1Period1TextForecast : "Forecast"
property GetDay1Period1Icon : "Forecast"
property GetDay1Period2Name : "Forecast"
property GetDay1Period2TextForecast : "Forecast"
property GetDay1Period2Icon : "Forecast"

property GetDay1Name : "Forecast"
property GetDay1High : "Forecast"
property GetDay1Low : "Forecast"
property GetDay1Conditions : "Forecast"
property GetDay1Icon : "Forecast"
property GetDay2Name : "Forecast"
property GetDay2High : "Forecast"
property GetDay2Low : "Forecast"
property GetDay2Conditions : "Forecast"
property GetDay2Icon : "Forecast"
property GetDay3Name : "Forecast"
property GetDay3High : "Forecast"
property GetDay3Low : "Forecast"
property GetDay3Conditions : "Forecast"
property GetDay3Icon : "Forecast"
property GetDay4Name : "Forecast"
property GetDay4High : "Forecast"
property GetDay4Low : "Forecast"
property GetDay4Conditions : "Forecast"
property GetDay4Icon : "Forecast"
property GetDay5Name : "Forecast"
property GetDay5High : "Forecast"
property GetDay5Low : "Forecast"
property GetDay5Conditions : "Forecast"
property GetDay5Icon : "Forecast"
property GetDay6Name : "Forecast"
property GetDay6High : "Forecast"
property GetDay6Low : "Forecast"
property GetDay6Conditions : "Forecast"
property GetDay6Icon : "Forecast"

property GetAgeOfMoon : ""
property GetPercentIlluminated : ""



-- the following properties control the script behavior for optional features:
-- saveHighLow controls the saving of high and low temperature observations
-- runSetIcon controls the setting of the weather icon for Indigo control pages
property saveHighLow : true
property runSetIcon : true

property downloadTimeout : 30 -- seconds to wait for download to complete. Make this longer if you are on a very slow connection
property downloadRetryDelay : 30 -- seconds to wait between retries

--(*-------------- DO NOT MODIFY AFTER THIS -------------------*)
global myFile
global location, station_id, observation_time, observation_time_rfc822, weather, temperature_string, temp_c, temp_f, relative_humidity, wind_string, wind_dir, wind_degrees, wind_mph, wind_gust_mph, pressure_string, pressure_mb, pressure_in, dewpoint_string, dewpoint_f, dewpoint_c, heat_index_string, heat_index_f, heat_index_c, windchill_string, windchill_f, windchill_c, precip_1hr_string, precip_1hr_in, precip_1hr_m, precip_today_string, precip_today_in, precip_today_m, loc_full, loc_neighborhood, loc_city, loc_state, loc_zip, loc_latitude, loc_longitude, loc_elevation, icon
global Day1Period1Name, Day1Period1TextForecast, Day1Period1Icon, Day1Period2Name, Day1Period2TextForecast, Day1Period2Icon, Day1Name, Day1High, Day1Low, Day1Conditions, Day1Icon, Day2Name, Day2High, Day2Low, Day2Conditions, Day2Icon, Day3Name, Day3High, Day3Low, Day3Conditions, Day3Icon, Day4Name, Day4High, Day4Low, Day4Conditions, Day4Icon, Day5Name, Day5High, Day5Low, Day5Conditions, Day5Icon, Day6Name, Day6High, Day6Low, Day6Conditions, Day6Icon, AgeOfMoon, PercentIlluminated
global tempdebug1, tempdebug2

-- main()
ClearVariables() -- initialize the data variables to a known state
if debug then LogWunderground("Script Launched", "", 0) -- Tell Indigo we've started, IF we are in Debug mode
set errorID1 to false
set errorID2 to false
set errorCount to 0


-- get some information from Indigo: the date of the last update, Night/Day and the station IDs      
tell application "IndigoServer"
   -- the time of the last update
   if not (variable "Wunderground_Observation_Time_rfc822" exists) then -- create it.
      make new variable with properties {name:"Wunderground_Observation_Time_rfc822", value:"Fri, 1 January 2010 00:00:00 GMT"}
   else if value of variable "Wunderground_Observation_Time_rfc822" is equal to "" then
      set the value of variable "Wunderground_Observation_Time_rfc822" to "Fri, 1 January 2010 00:00:00 GMT" as text
   end if
   
   set theLastRFCDate to value of variable "Wunderground_Observation_Time_rfc822" as text
   set isDaylight to value of variable "isDaylight" as boolean -- use for setting the Icon
   
   -- Get the Airport station if it has been defined
   if (variable "_Wunderground_APT" exists) then
      set stationAPT to value of variable "_Wunderground_APT" as text
   else
      set stationAPT to "none" as text
   end if
   
   -- Get the PWS list if it has been defined      
   if (variable "_Wunderground_PWS_List" exists) then
      set pwsList to value of variable "_Wunderground_PWS_List"
   else
      set pwsList to ""
   end if
   set stationCount to count words of pwsList
   
   -- Get the Forecast zip code if it has been defined
   if (variable "_Wunderground_ZIP" exists) then
      set forecastZIP to value of variable "_Wunderground_ZIP" as text
   else
      set forecastZIP to "none" as text
   end if
   
end tell



-- Make sure we have at least 1 station to check, if not, log the problem and bail
if stationAPT is equal to "none" and stationCount is equal to 0 then
   LogWunderground("Script exiting: No stations (Airport or PWS) defined", "", 0)
   return false
end if

try -- the Airport station
   if stationAPT is not equal to "none" then -- we have an airport station ID, so let's try it.
      -- setup a temporary file to receive the xml data
      if GetTemp(stationAPT, "APT") is true then
         -- get the xml file from the Wunderground web site and save it in the temporary folder
         if GetXMLfile(stationAPT, "APT") is true then
            if ParseXML("APT") is false then -- we failed, otherwise we will save the data, below
               -- at the end of the repeat
               LogWunderground("Error parsing data from from Airport Station: " & stationAPT, "", 0)
            end if
         else
            LogWunderground("Error getting data from Station 1: " & stationAPT, "", 0)
         end if
      else
         LogWunderground("Error creating data file for Airport Station: " & stationAPT, "", 0)
      end if
   end if
on error errString number errNum
   LogWunderground("Script Failed: Airport station" & stationAPT, errString, errNum)
end try

repeat with PWS from 1 to stationCount -- cycle through the PWS station(s) until we get a good one
   set stationPWS to word PWS of pwsList
   
   if debug then
      set logMsg to "DEBUG: Start PWS loop- Station # is: " & PWS & ", Error count is: " & errorCount
      LogWunderground(logMsg, "", 0)
   end if
   
   try
      -- setup a temporary file to receive the xml data
      if GetTemp("PWS") is true then
         if debug then log "We received a file for station: " & PWS
         -- get the xml file from the Wunderground web site and save it in the temporary folder
         if GetXMLfile(stationPWS, "PWS") is true then
            if debug then log "The file was valid for station: " & PWS
            -- read the xml file values to send to indigo and check that
            -- the observation we just received is newer than the one we already had
            if ParseXML("PWS") is true and length of observation_time_rfc822 is greater than 0 then
               if debug then log "We parsed the file for station: " & PWS
               set theNewRFCDate to observation_time_rfc822 as text
               if debug then log "The last rfc observation date: " & theLastRFCDate
               if debug then log "The new rfc observation date: " & theNewRFCDate
               set lastObservation to dateToEpoch(theLastRFCDate)
               set newObservation to dateToEpoch(theNewRFCDate)
               if debug then log "Compared new ==>" & newObservation & "<== to old ==>" & lastObservation & "<=="
               if newObservation is greater than lastObservation then -- send the data into Indigo variables
                  if errorCount > 0 then
                     LogWunderground("Found current valid Observation from Station: " & stationPWS, "", 0)
                  end if
                  exit repeat -- our work here is done, for now
               else
                  set errorCount to errorCount + 1
                  LogWunderground("Stale Observation from Station: " & stationPWS, "", 0)
               end if
            else
               set errorCount to errorCount + 1
               LogWunderground("Null data from Station 1: " & stationPWS, "", 0)
            end if
         else
            errorCount to errorCount + 1
            LogWunderground("No data from Station 1: " & stationPWS, "", 0)
         end if
      end if
   end try
end repeat

try -- the forecast
   if GetTemp(forecastZIP) is true then
      -- get the xml file from the Wunderground web site and save it in the temporary folder
      if GetXMLfile(forecastZIP, "Forecast") is true then
         
         
         if ParseXML("Forecast") is false then -- we failed, otherwise we will save the data, below
            -- at the end of the repeat
            LogWunderground("Error parsing data from from weather underground forecast: " & forecastZIP, "", 0)
         end if
      else
         LogWunderground("Error getting data from weather underground forecast: " & forecastZIP, "", 0)
      end if
   else
      LogWunderground("Error creating data file weather underground forecast: " & forecastZIP, "", 0)
   end if
on error errString number errNum
   LogWunderground("Script Failed: weather underground forecast " & forecastZIP, errString, errNum)
end try

--log errorCount

if errorCount is equal to stationCount and stationCount is greater than 1 then
   LogWunderground("No Available PWS Servers or no current data", "", 0)
else -- save the data and meta data
   SendToIndigo()
   
   if saveHighLow is true then
      set currentTemp to temp_f as number
      SetHighLow(currentTemp, observation_time)
   end if
   
   if runSetIcon is true and stationAPT is not equal to "none" then
      setIcon(icon, isDaylight, "current")
   end if
   
   if runSetIcon is true and forecastZIP is not equal to "none" then
      setIcon(Day1Period1Icon, isDaylight, "day1period1")
      setIcon(Day1Period2Icon, isDaylight, "day1period2")
      setIcon(Day1Icon, isDaylight, "day1icon")
      setIcon(Day2Icon, isDaylight, "day2icon")
      setIcon(Day3Icon, isDaylight, "day3icon")
      setIcon(Day4Icon, isDaylight, "day4icon")
      setIcon(Day5Icon, isDaylight, "day5icon")
      setIcon(Day6Icon, isDaylight, "day6icon")
   end if
   
end if
return
-- end of main()

on ClearVariables()
   -- Wunderground location vars
   set loc_full to ""
   set loc_neighborhood to ""
   set loc_city to ""
   set loc_state to ""
   set loc_zip to ""
   set loc_latitude to ""
   set loc_longitude to ""
   set loc_elevation to ""
   -- Wunderground observation vars
   set station_id to ""
   set observation_time to ""
   set observation_time_rfc822 to ""
   set weather to ""
   set temperature_string to ""
   set temp_c to ""
   set temp_f to ""
   set relative_humidity to ""
   set wind_string to ""
   set wind_dir to ""
   set wind_degrees to ""
   set wind_mph to ""
   set wind_gust_mph to ""
   set pressure_string to ""
   set pressure_mb to ""
   set pressure_in to ""
   set dewpoint_string to ""
   set dewpoint_f to ""
   set dewpoint_c to ""
   set heat_index_string to ""
   set heat_index_f to ""
   set heat_index_c to ""
   set windchill_string to ""
   set windchill_f to ""
   set windchill_c to ""
   set precip_1hr_string to ""
   set precip_1hr_in to ""
   set precip_1hr_m to ""
   set precip_today_string to ""
   set precip_today_in to ""
   set precip_today_m to ""
   set icon to ""
   -- Internal script vars and flags
   set stationID1 to ""
   set stationID2 to ""
   set newObservation to ""
   set lastObservation to ""
   set theLastRFCDate to ""
   set theNewRFCDate to ""
   -- Wunderground 7-day forecast vars
   set Day1Period1Name to ""
   set Day1Period1TextForecast to ""
   set Day1Period1Icon to ""
   set Day1Period2Name to ""
   set Day1Period2TextForecast to ""
   set Day1Period2Icon to ""
   set Day1Name to ""
   set Day1High to ""
   set Day1Low to ""
   set Day1Icon to ""
   set Day1Conditions to ""
   set Day2Name to ""
   set Day2High to ""
   set Day2Low to ""
   set Day2Conditions to ""
   set Day2Icon to ""
   set Day3Name to ""
   set Day3High to ""
   set Day3Low to ""
   set Day3Conditions to ""
   set Day3Icon to ""
   set Day4Name to ""
   set Day4High to ""
   set Day4Low to ""
   set Day4Conditions to ""
   set Day4Icon to ""
   set Day5Name to ""
   set Day5High to ""
   set Day5Low to ""
   set Day5Conditions to ""
   set Day5Icon to ""
   set Day6Name to ""
   set Day6High to ""
   set Day6Low to ""
   set Day6Conditions to ""
   set Day6Icon to ""
   set AgeOfMoon to ""
   set PercentIlluminated to ""
   
end ClearVariables

on GetTemp(stationType)
   try
      -- get a path to a file in the temporary folder to save the xml file
      tell application "Finder"
         set myFile to "var:tmp:wunderground_" & stationType & "_sync_temp.xml"
      end tell
      return true
   on error errString number errNumber
      LogWunderground("GetTemp", errString, errNum)
      return false
   end try
end GetTemp

on GetXMLfile(stationID, stationType)
   if stationType is equal to "PWS" then
      set wunderURL to "http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=/"
   else if stationType is equal to "APT" then
      set wunderURL to "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query="
   else if stationType is equal to "Forecast" then
      
      set wunderURL to "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query="
      
   else
      return false
   end if
   
   set myPath to POSIX path of myFile -- convert the path for the shell call below
   set tryCount to 1
   set success to false
   
   repeat 4 times -- we will wait 30 seconds for a response, and wait another 30 seconds between retries
      with timeout of downloadTimeout + 2 seconds
         try
            do shell script "> " & myPath & ";/usr/bin/curl -s -S -m " & downloadTimeout & " " & wunderURL & stationID & " >" & myPath
            
            --tell application "URL Access Scripting"
            --   download wunderURL & stationID to file myFile replacing yes
            --   -- work around -31040 error:
            --   tell application "URL Access Scripting" to quit
            -- end tell
            -- a quick check to make sure we got something valid
            -- If this command fails, the script will jump to the on error clause
            -- and then try again up to 4 times, otherwise, we will set the success flag
            if stationType = "APT" or stationType = "PWS" then
               do shell script "/usr/bin/egrep \"<station_id>" & stationID & "</station_id>\" " & myPath
            end if
            set success to true
            exit repeat
         on error errString number errNum
            if errString is equal to "The command exited with a non-zero status." then
               set errString to "Null Station ID in XML data"
            end if
            LogWunderground("GetXMLfile: " & stationID & " try #" & tryCount, errString, errNum)
            set tryCount to tryCount + 1
         end try
      end timeout
      delay downloadRetryDelay -- and then try again
   end repeat
   
   return success
end GetXMLfile

on ParseXML(staTyp)
   try
      tell application "System Events"
         
         
         if staTyp is equal to "PWS" or staTyp is equal to "APT" then
            set elem1 to XML element 1 of XML file myFile
            if staTyp is equal to "PWS" then set elem2 to XML element "location" of elem1
            if staTyp is equal to "APT" then set elem2 to XML element "display_location" of elem1
            if GetObservationTime is equal to staTyp then set observation_time to value of XML elements of elem1 whose name is "observation_time"
            if GetObservationTimerfc822 is equal to staTyp then set observation_time_rfc822 to value of XML elements of elem1 whose name is "observation_time_rfc822"
            if GetStationID is equal to staTyp then set station_id to value of XML elements of elem1 whose name is "station_id"
            if GetWeather is equal to staTyp then set weather to value of XML elements of elem1 whose name is "weather"
            if GetTempString is equal to staTyp then set temperature_string to value of XML elements of elem1 whose name is "temperature_string"
            if GetTempF is equal to staTyp then set temp_f to value of XML elements of elem1 whose name is "temp_f"
            if GetTempC is equal to staTyp then set temp_c to value of XML elements of elem1 whose name is "temp_c"
            if GetRelativeHumidity is equal to staTyp then set relative_humidity to value of XML elements of elem1 whose name is "relative_humidity"
            if GetWindString is equal to staTyp then set wind_string to value of XML elements of elem1 whose name is "wind_string"
            if GetWindDirection is equal to staTyp then set wind_dir to value of XML elements of elem1 whose name is "wind_dir"
            if GetWindDegrees is equal to staTyp then set wind_degrees to value of XML elements of elem1 whose name is "wind_degrees"
            if GetWindMPH is equal to staTyp then set wind_mph to value of XML elements of elem1 whose name is "wind_mph"
            if GetWindGustMPH is equal to staTyp then set wind_gust_mph to value of XML elements of elem1 whose name is "wind_gust_mph"
            if GetPressureString is equal to staTyp then set pressure_string to value of XML elements of elem1 whose name is "pressure_string"
            if GetPressureMB is equal to staTyp then set pressure_mb to value of XML elements of elem1 whose name is "pressure_mb"
            if GetPressureIN is equal to staTyp then set pressure_in to value of XML elements of elem1 whose name is "pressure_in"
            if GetDewpointString is equal to staTyp then set dewpoint_string to value of XML elements of elem1 whose name is "dewpoint_string"
            if GetDewpointF is equal to staTyp then set dewpoint_f to value of XML elements of elem1 whose name is "dewpoint_f"
            if GetDewpointC is equal to staTyp then set dewpoint_c to value of XML elements of elem1 whose name is "dewpoint_c"
            if GetHeatIndexString is equal to staTyp then set heat_index_string to value of XML elements of elem1 whose name is "heat_index_string"
            if GetHeatIndexF is equal to staTyp then set heat_index_f to value of XML elements of elem1 whose name is "heat_index_f"
            if GetHeatIndexC is equal to staTyp then set heat_index_c to value of XML elements of elem1 whose name is "heat_index_c"
            if GetWindchillString is equal to staTyp then set windchill_string to value of XML elements of elem1 whose name is "windchill_string"
            if GetWindchillF is equal to staTyp then set windchill_f to value of XML elements of elem1 whose name is "windchill_f"
            if GetWindchillC is equal to staTyp then set windchill_c to value of XML elements of elem1 whose name is "windchill_c"
            if GetPrecip_1hr_string is equal to staTyp then set precip_1hr_string to value of XML elements of elem1 whose name is "precip_1hr_string"
            if GetPrecip_1hr_in is equal to staTyp then set precip_1hr_in to value of XML elements of elem1 whose name is "precip_1hr_in"
            if GetPrecip_1hr_m is equal to staTyp then set precip_1hr_m to value of XML elements of elem1 whose name is "precip_1hr_metric"
            if GetPrecip_today_string is equal to staTyp then set precip_today_string to value of XML elements of elem1 whose name is "precip_today_string"
            if GetPrecip_today_in is equal to staTyp then set precip_today_in to value of XML elements of elem1 whose name is "precip_today_in"
            if GetPrecip_today_m is equal to staTyp then set precip_today_m to value of XML elements of elem1 whose name is "precip_today_metric"
            if GetIcon is equal to staTyp then set icon to value of XML elements of elem1 whose name is "icon"
            if GetFull is equal to staTyp then set loc_full to value of XML elements of elem2 whose name is "full"
            if GetNeighborhood is equal to staTyp then set loc_neighborhood to value of XML elements of elem2 whose name is "neighborhood"
            if GetCity is equal to staTyp then set loc_city to value of XML elements of elem2 whose name is "city"
            if GetState is equal to staTyp then set loc_state to value of XML elements of elem2 whose name is "state"
            if GetZip is equal to staTyp then set loc_zip to value of XML elements of elem2 whose name is "zip"
            if GetLatitude is equal to staTyp then set loc_latitude to value of XML elements of elem2 whose name is "latitude"
            if GetLongitude is equal to staTyp then set loc_longitude to value of XML elements of elem2 whose name is "longitude"
            if GetElevation is equal to staTyp then set loc_elevation to value of XML elements of elem2 whose name is "elevation"
         end if
         
         
         
         if staTyp is equal to "Forecast" then
            
            
            set theValuesList to {}
            set txt_forecast to XML element 1 of (XML elements of (XML element 1 of contents of XML file myFile) whose name is "txt_forecast")
            
            tell txt_forecast
               if GetDay1Period1Name is equal to staTyp then set Day1Period1Name to (value of XML elements of XML element 3 whose name is "title") as string
               if GetDay1Period1TextForecast is equal to staTyp then set Day1Period1TextForecast to (value of XML elements of XML element 3 whose name is "fcttext") as string
               if GetDay1Period1Icon is equal to staTyp then set Day1Period1Icon to (value of XML elements of XML element 3 whose name is "icon") as string
               if GetDay1Period2Name is equal to staTyp then set Day1Period2Name to (value of XML elements of XML element 4 whose name is "title") as string
               
               if GetDay1Period2TextForecast is equal to staTyp then set Day1Period2TextForecast to (value of XML elements of XML element 4 whose name is "fcttext") as string
               if GetDay1Period2Icon is equal to staTyp then set Day1Period2Icon to (value of XML elements of XML element 4 whose name is "icon") as string
            end tell
            
            set theValuesList to {}
            set simpleforecast to XML element 1 of (XML elements of (XML element 1 of contents of XML file myFile) whose name is "simpleforecast")
            tell simpleforecast
               set valuesListTotal to (count of XML elements)
               repeat with thisElement from 1 to valuesListTotal
                  set high to (value of XML elements of (XML elements of XML element thisElement whose name is "high") whose name is "fahrenheit") as number
                  set low to (value of XML elements of (XML elements of XML element thisElement whose name is "low") whose name is "fahrenheit") as number
                  set theDay to (value of XML elements of (XML elements of XML element thisElement whose name is "date") whose name is "weekday") as string
                  set conditions to (value of XML elements of XML element thisElement whose name is "conditions") as string
                  set icon to (value of XML elements of XML element thisElement whose name is "icon") as string
                  set theValuesList to theValuesList & {{theDay, high, low, conditions, icon}}
               end repeat
               
            end tell
            if GetDay1Name is equal to staTyp then set Day1Name to item 1 of item 1 of theValuesList
            if GetDay1High is equal to staTyp then set Day1High to item 2 of item 1 of theValuesList
            if GetDay1Name is equal to staTyp then set Day1Low to item 3 of item 1 of theValuesList
            if GetDay1Conditions is equal to staTyp then set Day1Conditions to item 4 of item 1 of theValuesList
            if GetDay1Icon is equal to staTyp then set Day1Icon to item 5 of item 1 of theValuesList
            if GetDay2Name is equal to staTyp then set Day2Name to item 1 of item 2 of theValuesList
            if GetDay2High is equal to staTyp then set Day2High to item 2 of item 2 of theValuesList
            if GetDay2Name is equal to staTyp then set Day2Low to item 3 of item 2 of theValuesList
            if GetDay2Conditions is equal to staTyp then set Day2Conditions to item 4 of item 2 of theValuesList
            if GetDay2Icon is equal to staTyp then set Day2Icon to item 5 of item 2 of theValuesList
            if GetDay3Name is equal to staTyp then set Day3Name to item 1 of item 3 of theValuesList
            if GetDay3High is equal to staTyp then set Day3High to item 2 of item 3 of theValuesList
            if GetDay3Name is equal to staTyp then set Day3Low to item 3 of item 3 of theValuesList
            if GetDay3Conditions is equal to staTyp then set Day3Conditions to item 4 of item 3 of theValuesList
            if GetDay3Icon is equal to staTyp then set Day3Icon to item 5 of item 3 of theValuesList
            if GetDay4Name is equal to staTyp then set Day4Name to item 1 of item 4 of theValuesList
            if GetDay4High is equal to staTyp then set Day4High to item 2 of item 4 of theValuesList
            if GetDay4Name is equal to staTyp then set Day4Low to item 3 of item 4 of theValuesList
            if GetDay4Conditions is equal to staTyp then set Day4Conditions to item 4 of item 4 of theValuesList
            if GetDay4Icon is equal to staTyp then set Day4Icon to item 5 of item 4 of theValuesList
            if GetDay5Name is equal to staTyp then set Day5Name to item 1 of item 5 of theValuesList
            if GetDay5High is equal to staTyp then set Day5High to item 2 of item 5 of theValuesList
            if GetDay5Name is equal to staTyp then set Day5Low to item 3 of item 5 of theValuesList
            if GetDay5Conditions is equal to staTyp then set Day5Conditions to item 4 of item 5 of theValuesList
            if GetDay5Icon is equal to staTyp then set Day5Icon to item 5 of item 5 of theValuesList
            if GetDay6Name is equal to staTyp then set Day6Name to item 1 of item 6 of theValuesList
            if GetDay6High is equal to staTyp then set Day6High to item 2 of item 6 of theValuesList
            if GetDay6Name is equal to staTyp then set Day6Low to item 3 of item 6 of theValuesList
            if GetDay6Conditions is equal to staTyp then set Day6Conditions to item 4 of item 6 of theValuesList
            if GetDay6Icon is equal to staTyp then set Day6Icon to item 5 of item 6 of theValuesList
            
            set moon_phase to XML element 1 of (XML elements of (XML element 1 of contents of XML file myFile) whose name is "moon_phase")
            
            tell moon_phase
               
               if GetPercentIlluminated is equal to staTyp then set PercentIlluminated to value of XML elements of moon_phase whose name is "ageOfMoon"
               if GetAgeOfMoon is equal to staTyp then set AgeOfMoon to value of XML elements of moon_phase whose name is "ageOfMoon"
               
            end tell
            
         end if
         
         
      end tell
      
      return true
   on error errString number errNum
      LogWunderground("ParseXML", errString, errNum)
      return false
   end try
end ParseXML

on SendToIndigo()
   -- Sometimes rain data can be negative, probably due to PWS errors. we fix that here.   
   
   if precip_1hr_in < 0 then
      --set precip_1hr_in to precip_1hr_in as real
      set precip_1hr_in to 0
   end if
   
   if precip_1hr_m < 0 then
      --set precip_1hr_m to precip_1hr_m as real
      set precip_1hr_m to 0
   end if
   
   if precip_today_in < 0 then
      --set precip_today_in to precip_today_in as real
      set precip_today_in to 0
   end if
   
   if precip_today_m < 0 then
      --set precip_today_m to precip_today_m
      set precip_today_m to 0
   end if
   
   
   -- load the data into an array to be sent to Indigo.
   -- the array contains three elements:
   -- 1) the name of the Indogo var;
   -- 2) the source flag to control whether this var should be updated;
   -- 3) and the variable value  from the Wunderground XML data
   set arr to {¬
      {"Wunderground_Location_Full", GetFull, loc_full}, ¬
      {"Wunderground_Location_Neighborhood", GetNeighborhood, loc_neighborhood}, ¬
      {"Wunderground_Location_City", GetCity, loc_city}, ¬
      {"Wunderground_Location_State", GetState, loc_state}, ¬
      {"Wunderground_Location_Zip", GetZip, loc_zip}, ¬
      {"Wunderground_Location_Latitude", GetLatitude, loc_latitude}, ¬
      {"Wunderground_Location_Longitude", GetLongitude, loc_longitude}, ¬
      {"Wunderground_Location_Elevation", GetElevation, loc_elevation}, ¬
      {"Wunderground_Observation_Time", GetObservationTime, observation_time}, ¬
      {"Wunderground_Observation_Time_rfc822", GetObservationTimerfc822, observation_time_rfc822}, ¬
      {"Wunderground_StationID", GetStationID, station_id}, ¬
      {"Wunderground_Condition", GetWeather, weather}, ¬
      {"Wunderground_Temperature", GetTempString, temperature_string}, ¬
      {"Wunderground_Temperature_F", GetTempF, temp_f}, ¬
      {"Wunderground_Temperature_C", GetTempC, temp_c}, ¬
      {"Wunderground_Relative_Humidity", GetRelativeHumidity, relative_humidity}, ¬
      {"Wunderground_Wind", GetWindString, wind_string}, ¬
      {"Wunderground_Wind_Direction", GetWindDirection, wind_dir}, ¬
      {"Wunderground_Wind_Degrees", GetWindDegrees, wind_degrees}, ¬
      {"Wunderground_Wind_MPH", GetWindMPH, wind_mph}, ¬
      {"Wunderground_Wind_Gust", GetWindGustMPH, wind_gust_mph}, ¬
      {"Wunderground_Pressure", GetPressureString, pressure_string}, ¬
      {"Wunderground_Pressure_mb", GetPressureMB, pressure_mb}, ¬
      {"Wunderground_Pressure_in", GetPressureIN, pressure_in}, ¬
      {"Wunderground_Dewpoint", GetDewpointString, dewpoint_string}, ¬
      {"Wunderground_Dewpoint_F", GetDewpointF, dewpoint_f}, ¬
      {"Wunderground_Dewpoint_C", GetDewpointC, dewpoint_c}, ¬
      {"Wunderground_Heat_Index", GetHeatIndexString, heat_index_string}, ¬
      {"Wunderground_Heat_Index_F", GetHeatIndexF, heat_index_f}, ¬
      {"Wunderground_Heat_Index_C", GetHeatIndexC, heat_index_c}, ¬
      {"Wunderground_Windchill", GetWindchillString, windchill_string}, ¬
      {"Wunderground_Windchill_F", GetWindchillF, windchill_f}, ¬
      {"Wunderground_Windchill_C", GetWindchillC, windchill_c}, ¬
      {"Wunderground_Precip_1hr_string", GetPrecip_1hr_string, precip_1hr_string}, ¬
      {"Wunderground_Precip_1hr_in", GetPrecip_1hr_in, precip_1hr_in}, ¬
      {"Wunderground_Precip_1hr_m", GetPrecip_1hr_m, precip_1hr_m}, ¬
      {"Wunderground_Precip_today_string", GetPrecip_today_string, precip_today_string}, ¬
      {"Wunderground_Precip_today_in", GetPrecip_today_in, precip_today_in}, ¬
      {"Wunderground_Precip_today_m", GetPrecip_today_m, precip_today_m}, ¬
      {"Wunderground_Icon", GetIcon, icon}, ¬
      {"Wunderground_Day1Period1Name", GetDay1Period1Name, Day1Period1Name}, ¬
      {"Wunderground_Day1Period1TextForecast", GetDay1Period1TextForecast, Day1Period1TextForecast}, ¬
      {"Wunderground_Day1Period1Icon", GetDay1Period1Icon, Day1Period1Icon}, ¬
      {"Wunderground_Day1Period2Name", GetDay1Period2Name, Day1Period2Name}, ¬
      {"Wunderground_Day1Period2TextForecast", GetDay1Period2TextForecast, Day1Period2TextForecast}, ¬
      {"Wunderground_Day1Period2Icon", GetDay1Period2Icon, Day1Period2Icon}, ¬
      {"Wunderground_Day1Name", GetDay1Name, Day1Name}, ¬
      {"Wunderground_Day1High", GetDay1High, Day1High}, ¬
      {"Wunderground_Day1Low", GetDay1Low, Day1Low}, ¬
      {"Wunderground_Day1Conditions", GetDay1Conditions, Day1Conditions}, ¬
      {"Wunderground_Day1Icon", GetDay1Icon, Day1Icon}, ¬
      {"Wunderground_Day2Name", GetDay2Name, Day2Name}, ¬
      {"Wunderground_Day2High", GetDay2High, Day2High}, ¬
      {"Wunderground_Day2Low", GetDay2Low, Day2Low}, ¬
      {"Wunderground_Day2Conditions", GetDay2Conditions, Day2Conditions}, ¬
      {"Wunderground_Day2Icon", GetDay2Icon, Day2Icon}, ¬
      {"Wunderground_Day3Name", GetDay3Name, Day3Name}, ¬
      {"Wunderground_Day3High", GetDay3High, Day3High}, ¬
      {"Wunderground_Day3Low", GetDay3Low, Day3Low}, ¬
      {"Wunderground_Day3Conditions", GetDay3Conditions, Day3Conditions}, ¬
      {"Wunderground_Day3Icon", GetDay3Icon, Day3Icon}, ¬
      {"Wunderground_Day4Name", GetDay4Name, Day4Name}, ¬
      {"Wunderground_Day4High", GetDay4High, Day4High}, ¬
      {"Wunderground_Day4Low", GetDay4Low, Day4Low}, ¬
      {"Wunderground_Day4Conditions", GetDay4Conditions, Day4Conditions}, ¬
      {"Wunderground_Day4Icon", GetDay4Icon, Day4Icon}, ¬
      {"Wunderground_Day5Name", GetDay5Name, Day5Name}, ¬
      {"Wunderground_Day5High", GetDay5High, Day5High}, ¬
      {"Wunderground_Day5Low", GetDay5Low, Day5Low}, ¬
      {"Wunderground_Day5Conditions", GetDay5Conditions, Day5Conditions}, ¬
      {"Wunderground_Day5Icon", GetDay5Icon, Day5Icon}, ¬
      {"Wunderground_Day6Name", GetDay6Name, Day6Name}, ¬
      {"Wunderground_Day6High", GetDay6High, Day6High}, ¬
      {"Wunderground_Day6Low", GetDay6Low, Day6Low}, ¬
      {"Wunderground_Day6Conditions", GetDay6Conditions, Day6Conditions}, ¬
      {"Wunderground_Day6Icon", GetDay6Icon, Day6Icon}, ¬
      {"Wunderground_AgeOfMoon", GetAgeOfMoon, AgeOfMoon}, ¬
      {"Wunderground_PercentIlluminated", GetPercentIlluminated, PercentIlluminated} ¬
         }
   
   set Day1Period1Name to ""
   set Day1Period1TextForecast to ""
   set Day1Period2Name to ""
   set Day1Period2TextForecast to ""
   set Day1Name to ""
   set Day1High to ""
   set Day1Low to ""
   set Day1Conditions to ""
   set Day2Name to ""
   set Day2High to ""
   set Day2Low to ""
   set Day2Conditions to ""
   set Day3Name to ""
   set Day3High to ""
   set Day3Low to ""
   set Day3Conditions to ""
   set Day4Name to ""
   set Day4High to ""
   set Day4Low to ""
   set Day4Conditions to ""
   set Day5Name to ""
   set Day5High to ""
   set Day5Low to ""
   set Day5Conditions to ""
   set Day6Name to ""
   set Day6High to ""
   set Day6Low to ""
   set Day6Conditions to ""
   set AgeOfMoon to ""
   set PercentIlluminated to ""
   
   repeat with thisArr in arr
      try
         tell application "IndigoServer"
            if (item 2 of thisArr) is not "" then
               -- if the update flag is true, and the var does not exist in Indigo, then create it
               if not (variable (item 1 of thisArr) exists) then
                  --make new variable with properties {name:(item 1 of thisArr), value:(item 3 of thisArr)}
                  make new variable with properties {name:(item 1 of thisArr), value:""}
                  set value of variable (item 1 of thisArr) to (item 3 of thisArr) as string
               else
                  -- Update the var value in Indigo.
                  -- Note: We set the variables as strings in case any are nul
                  -- which is common in PWS data
                  set value of variable (item 1 of thisArr) to (item 3 of thisArr) as string
               end if
            else -- if the update flag is false, and the var exists in Indigo, then delete it from Indigo
               if (variable (item 1 of thisArr) exists) then delete variable (item 1 of thisArr)
            end if
         end tell
      on error errString number errNum
         LogWunderground("SendToIndigo", errString, errNum)
      end try
   end repeat
   return true
end SendToIndigo

on SetHighLow(currentTemp, theDate)
   
   set theDate to theDate as text
   set theDay to word 5 of theDate as number
   set theTime to word 6 of theDate & ":" & word 7 of theDate & " " & word 8 of theDate
   
   tell application "IndigoServer"
      set lastCheck to the value of variable "LastCheck" as number
      -- Firstly reset every day
      if theDay is not equal to lastCheck then
         set value of variable "Local_High_Temp" to ""
         set value of variable "Local_Low_Temp" to ""
         set the value of variable "LastCheck" to theDay
      end if
      
      -- Secondly, check if we have a new high      
      set oldHigh to the value of variable "Local_High_Temp" as real
      if oldHigh is equal to "" then set oldHigh to 0 as real
      if currentTemp is greater than oldHigh then
         set the value of variable "Local_High_Temp" to temp_f
         set the value of variable "Local_High_Time" to theTime
      end if
      
      -- And now, check if we have a new high   
      
      set oldLow to the value of variable "Local_Low_Temp" as real
      if oldLow is equal to "" or oldLow is equal to 0 then set oldLow to 100 as real
      if currentTemp is less than oldLow then
         set the value of variable "Local_Low_Temp" to temp_f
         set the value of variable "Local_Low_Time" to theTime
      end if
      
   end tell
   
end SetHighLow

on setIcon(iconName, isDaylight, iconType)
   if isDaylight is true then
      set iconFile to iconName & ".png"
   else
      set iconFile to "nt_" & iconName & ".png"
   end if
   set iconDir to "/Library/Application Support/Perceptive Automation/Indigo 4/IndigoWebServer/images/controls/variables/Observation_Icons"
   -- copy the appropriate icon png to the "current" icon files
   
   do shell script "cd " & quoted form of iconDir & ";" & "cp -f " & iconFile & " ../" & iconType & ".png; cp -f " & iconFile & " ../" & iconType & "+true.png"
end setIcon



on dupeProcCheck(myName)
   set procCount to do shell script "ps axww|grep -e \"osascript.*" & myName & "\"|grep -v grep|wc -l"
   
   if procCount as integer is greater than 1 then
      return false
   else
      return true
   end if
end dupeProcCheck

on dateToEpoch(rfcDate)
   return do shell script "/bin/date -j -f \"%a, %d %B %Y %T %Z\" \"" & rfcDate & "\"  \"+%s\""
end dateToEpoch

on LogWunderground(errText, errString, errNum)
   tell application "IndigoServer"
      try
         if errString is not "" then
            log errText & ":" & errString & "(" & (errNum as string) & ")" using type "Wunderground"
         else
            log errText using type "Wunderground"
         end if
      end try
   end tell
end LogWunderground


Thanks!

Posted on
Mon Feb 14, 2011 12:28 pm
gregjsmith offline
Posts: 946
Joined: Apr 01, 2003
Location: Rio Rancho, NM

Re: My iPhone 4 control page

scotsman wrote:
Here's my adjusted Weather Underground script that provides the 6 day forecast and various other tweaks. It may not be pretty but works for me. No guarantees included!


Does this work with the PWS or does it require using the nearest airport to get the forecast?

Posted on
Mon Feb 14, 2011 3:52 pm
hammer32 offline
Posts: 66
Joined: May 13, 2006
Location: Copperas Cove, TX

Re: My iPhone 4 control page

scotsman wrote:
Nice! love the auto-detection of people in the house. How does it work in practice? If your phone runs out of batteries, does your house automatically go into shutdown mode?


We usually plug the phones into bedside chargers overnight and haven't had the batteries die yet. If they do die, or miss one of the 10 minute pings, I've got a 30 minute timer before the house is "armed." If motion is detected inside of that time it keeps pushing the 30 minute timer farther out. Ultimately, except for an email from the house telling me it's armed, nothing would work differently until sunset when certain lights would start turning on/off at random.

scotsman wrote:
What does "Sleep Owen" mean? And what does "Sleep House" mean?


"Sleep Owen" puts my son's room to sleep - shuts off the overhead light, turns on and then dims a lamp over several minutes, allows the rope lights under his dresser to work when motion is detected, and turns on his 'bedtime' music. Similarly, the "Sleep House" turns off any lights that may be left on in the house, enables the main bedroom rope lights, and turns on some white noise. To get maximum SAF, I tried to put all the information she uses most on a single page :)


scotsman wrote:
Next thing I want to do is put some sort of house status variable together.

By the way I managed to upload my collection of weather icons to the user contribution library if anyone wants to user them in their own projects - I only just did it though so it may take a moment to get checked.


Those are great graphics! I haven't figured out how to switch between day and night weather graphics with the NOAA script. Once I get my PWS back up I'll have to give your script a try.

Posted on
Wed Feb 16, 2011 11:49 am
ckeyes888 offline
Posts: 2417
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: My iPhone 4 control page

On the 6 day forecast script above I'm not sure I understand how to just retrieve the forecast only and not all the
other data. Would you mind giving some additional info on that?

Thanks,

Carl

Posted on
Sat Feb 19, 2011 10:49 pm
scotsman offline
Posts: 66
Joined: Aug 14, 2010
Location: Austin, Texas

Re: My iPhone 4 control page

On the 6 day forecast script above I'm not sure I understand how to just retrieve the forecast only and not all the
other data. Would you mind giving some additional info on that?


You stop the other data from being retrieved by omitting the APT, PWS or Forecast code in the control section. e.g. to not retrieve the windspeed you make sure that the code says: property GetWindMPH : "".

Does this work with the PWS or does it require using the nearest airport to get the forecast?


Neither. I use the ForecastXML feed from Weather Underground. More info here:

http://wiki.wunderground.com/index.php/API_-_XML

Posted on
Mon Feb 21, 2011 12:34 pm
hamw offline
Posts: 1212
Joined: Mar 31, 2008

Re: My iPhone 4 control page

Scotsman and hammer32: have sent you PM re icons.
Thanks!

Who is online

Users browsing this forum: No registered users and 2 guests