Results 1 to 2 of 2

Thread: Get Weather Conditions using RSS feed

  1. #1
    Join Date
    Jan 2004

    Default Get Weather Conditions using RSS feed

    This is my Lua script that graps the current conditions for my area, using the Yahoo RSS feed.

    I grab the data and after converting the Icons to my own set, then I load them to my Leopard touch screen, using the Ocelot plugin.

    --Script to grab Current Weather Conditions
    --using Yahoo RSS weather feed
    function Getweather()
    CC = luacom.CreateObject("Msxml2.DOMDocument")
    CC.async = 0
    CC:load ("")
    -- put your zip code in front of XXXXX_f.xml
    if CC.parseError.errorCode ~=0 then
    print (CC.parseError.reason)
    -- Location
    node = CC:selectSingleNode ("//item/title")
    CCLocation = node.text
    -- Current Temp & Feels Like Temp (Wind Chill?)
    node = CC:selectSingleNode ("//item/yweather:condition")
    CCTemp = node.Attributes:getNamedItem("temp").nodevalue
    node = CC:selectSingleNode ("//channel/yweather:wind")
    CCFeelsTemp = node.Attributes:getNamedItem("chill").nodevalue
    --Conditions & Conditions Icon Number
    node = CC:selectSingleNode ("//item/yweather:condition")
    CCCond = node.Attributes:getNamedItem("text").nodevalue
    node = CC:selectSingleNode ("//item/yweather:condition")
    CCCondIcon = node.Attributes:getNamedItem("code").nodevalue
    --Atmospheric Conditions, Pressure, Trend, Unit
    node = CC:selectSingleNode ("//channel/yweather:atmosphere")
    CCPressure = node.Attributes:getNamedItem("pressure").nodevalue
    --Wind Conditions, Speed, Direction, (mph)
    node = CC:selectSingleNode ("//channel/yweather:wind")
    CCWindSpeed = node.Attributes:getNamedItem("speed").nodevalue
    node = CC:selectSingleNode ("//channel/yweather:wind")
    CCWindDirection = node.Attributes:getNamedItem("direction").nodevalue
    --check for verbage and convert
    if CCWindSpeed == "calm" then CCWindSpeed = 0 end
    --Humidity, Visability
    node = CC:selectSingleNode ("//channel/yweather:atmosphere")
    CCHmid = node.Attributes:getNamedItem("humidity").nodevalue
    node = CC:selectSingleNode ("//channel/yweather:atmosphere")
    CCVis = node.Attributes:getNamedItem("visibility").nodevalue
    -- Icon Conversions for use with ADI Leopard touch screen
    if CCCondIcon=="31" then CCCondIcon=31 end
    if CCCondIcon=="32" then CCCondIcon=31 end
    if CCCondIcon=="36" then CCCondIcon=31 end
    if CCCondIcon=="44" then CCCondIcon=31 end
    --Partial Sun
    if CCCondIcon=="23" then CCCondIcon=32 end
    if CCCondIcon=="24" then CCCondIcon=32 end
    if CCCondIcon=="29" then CCCondIcon=32 end
    if CCCondIcon=="30" then CCCondIcon=32 end
    --Scattered Showers
    if CCCondIcon=="39" then CCCondIcon=33 end
    if CCCondIcon=="41" then CCCondIcon=33 end
    if CCCondIcon=="45" then CCCondIcon=33 end
    if CCCondIcon=="48" then CCCondIcon=33 end
    if CCCondIcon=="26" then CCCondIcon=34 end
    if CCCondIcon=="27" then CCCondIcon=34 end
    if CCCondIcon=="28" then CCCondIcon=34 end
    if CCCondIcon=="11" then CCCondIcon=35 end
    if CCCondIcon=="12" then CCCondIcon=35 end
    if CCCondIcon=="40" then CCCondIcon=35 end
    if CCCondIcon=="5" then CCCondIcon=36 end
    if CCCondIcon=="6" then CCCondIcon=36 end
    if CCCondIcon=="7" then CCCondIcon=36 end
    if CCCondIcon=="8" then CCCondIcon=36 end
    if CCCondIcon=="9" then CCCondIcon=36 end
    if CCCondIcon=="10" then CCCondIcon=36 end
    if CCCondIcon=="13" then CCCondIcon=36 end
    if CCCondIcon=="14" then CCCondIcon=36 end
    if CCCondIcon=="15" then CCCondIcon=36 end
    if CCCondIcon=="16" then CCCondIcon=36 end
    if CCCondIcon=="18" then CCCondIcon=36 end
    if CCCondIcon=="25" then CCCondIcon=36 end
    if CCCondIcon=="42" then CCCondIcon=36 end
    if CCCondIcon=="43" then CCCondIcon=36 end
    if CCCondIcon=="46" then CCCondIcon=36 end
    if CCCondIcon=="0" then CCCondIcon=37 end
    if CCCondIcon=="1" then CCCondIcon=37 end
    if CCCondIcon=="2" then CCCondIcon=37 end
    if CCCondIcon=="3" then CCCondIcon=37 end
    if CCCondIcon=="4" then CCCondIcon=37 end
    if CCCondIcon=="17" then CCCondIcon=37 end
    if CCCondIcon=="35" then CCCondIcon=37 end
    if CCCondIcon=="37" then CCCondIcon=37 end
    if CCCondIcon=="38" then CCCondIcon=37 end
    if CCCondIcon=="47" then CCCondIcon=37 end
    if CCCondIcon=="20" then CCCondIcon=38 end
    if CCCondIcon=="19" then CCCondIcon=39 end
    if CCCondIcon=="21" then CCCondIcon=39 end
    if CCCondIcon=="22" then CCCondIcon=39 end
    if CCCondIcon=="33" then CCCondIcon=39 end
    if CCCondIcon=="34" then CCCondIcon=39 end
    -- close it all
    CC = nil
    collectgarbage ()
    --Debug print to check in Lua console
    print ("Weather "..CCLocation)
    print ("Currently "..CCCond..", Icon Number "..CCCondIcon)
    print ("Current Temp "..CCTemp.." F")
    print ("Feels Like "..CCFeelsTemp.." F")
    print ("Wind Speed "..CCWindSpeed.."mph, Direction "..CCWindDirection.." degrees")
    print ("Pressure "..CCPressure.." in")
    print ("Humidity "..CCHmid.."%, Visability "..CCVis.." miles")
    --Send variables to ADI Leopard touch screen to display Current Weather
    collectgarbage ()
    Just replace your 5 digit zipcode for your area!
    Todd Reed
    Ocelot Automation Rookie

  2. #2
    Join Date
    May 2007


    Todd Reed, how to use this?

    EDIT: Found it
    Last edited by reeven; July 27th, 2009 at 02:31 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts