I also put together a quick script to download weather data from TWC (free registration required) and display images on my remote as dynamic images. This isn't documented so you'll have to read through the code to figure out how to setup a 'Weather' device but you should get the general idea.
Code: Select all
' Set folder location of Weather.com icons and downloaded images
DestFolder = "c:\Program Files\HouseBot\Config\Themes\Common\weather\"
' Weather.com partner ID
WeatherComPar = "xxxxxxxx"
' Weather.com key
WeatherComKey = "xxxxxxxx
' Get weather for this postal code
WeatherComZip = "xxxxx"
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
Set xml = CreateObject("Microsoft.XMLHTTP")
set oStream = createobject("Adodb.Stream")
oStream.type = adTypeBinary
Set MSXML = CreateObject("MSXML.DOMDocument")
MSXML.Async = False
MSXML.preserveWhiteSpace = False
MSXML.validateOnParse = True
MSXML.resolveExternals = False
XMLURL = "http://xoap.weather.com/weather/local/" + WeatherComZip + "?cc=*&prod=xoap&par=" + WeatherComPar + "&key=" + WeatherComKey + "&dayf=5"
' Get weather images and update device properties
' (customize this for your own use)
getImage "http://image.weather.com/web/radar/us_atl_metroradar_large_usen.jpg", "W_radar"
getImage "http://image.weather.com/images/sat/regions/southeast_sat_720x486.jpg", "W_sat"
set oStream = nothing
Set xml = Nothing
Loaded = MSXML.Load(XMLURL)
If (Loaded) Then
SetPropertyValue "Weather.W_cc_lsup", MSXML.SelectSingleNode("/weather/cc/lsup").text
SetPropertyValue "Weather.W_cc_tmp", MSXML.SelectSingleNode("/weather/cc/tmp").text + "°F"
SetPropertyValue "Weather.W_cc_flik", MSXML.SelectSingleNode("/weather/cc/flik").text + "°F"
SetPropertyValue "Weather.W_cc_t", MSXML.SelectSingleNode("/weather/cc/t").text
SetPropertyValue "Weather.W_cc_icon", DestFolder + MSXML.SelectSingleNode("/weather/cc/icon").text + ".png"
SetPropertyValue "Weather.W_cc_bar_r", MSXML.SelectSingleNode("/weather/cc/bar/r").text
SetPropertyValue "Weather.W_cc_bar_d", MSXML.SelectSingleNode("/weather/cc/bar/d").text
SetPropertyValue "Weather.W_cc_wind", "From the " + MSXML.SelectSingleNode("/weather/cc/wind/t").text + " at "+ MSXML.SelectSingleNode("/weather/cc/wind/s").text + " mph"
SetPropertyValue "Weather.W_cc_hmid", MSXML.SelectSingleNode("/weather/cc/hmid").text + "%"
SetPropertyValue "Weather.W_cc_vis", MSXML.SelectSingleNode("/weather/cc/vis").text
SetPropertyValue "Weather.W_cc_uv", MSXML.SelectSingleNode("/weather/cc/uv/i").text + " " + MSXML.SelectSingleNode("/weather/cc/uv/t").text
SetPropertyValue "Weather.W_cc_dewp", MSXML.SelectSingleNode("/weather/cc/dewp").text + "°F"
SetPropertyValue "Weather.W_dayf_lsup", MSXML.SelectSingleNode("/weather/dayf/lsup").text
Set NodeList = MSXML.documentElement.selectNodes("/weather/dayf/day")
For Each Node In NodeList
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_t", Node.attributes.getNamedItem("t").nodeValue
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_dt", Node.attributes.getNamedItem("dt").nodeValue
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_hi", Node.selectSingleNode("hi").text + "°F"
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_low", Node.selectSingleNode("low").text + "°F"
set PartList = Node.selectNodes("part")
For Each Part In PartList
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_part" + Part.attributes.getNamedItem("p").nodeValue + "_icon", DestFolder + Part.selectSingleNode("icon").text + ".png"
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_part" + Part.attributes.getNamedItem("p").nodeValue + "_t", Part.selectSingleNode("t").text
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_part" + Part.attributes.getNamedItem("p").nodeValue + "_wind_s", Part.selectSingleNode("wind/s").text + "mph"
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_part" + Part.attributes.getNamedItem("p").nodeValue + "_wind_gust", Part.selectSingleNode("wind/gust").text
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_part" + Part.attributes.getNamedItem("p").nodeValue + "_wind_d", Part.selectSingleNode("wind/d").text
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_part" + Part.attributes.getNamedItem("p").nodeValue + "_wind_t", Part.selectSingleNode("wind/t").text
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_part" + Part.attributes.getNamedItem("p").nodeValue + "_ppcp", Part.selectSingleNode("ppcp").text + "%"
SetPropertyValue "Weather.W_dayf_day" + Node.attributes.getNamedItem("d").nodeValue + "_part" + Part.attributes.getNamedItem("p").nodeValue + "_hmid", Part.selectSingleNode("hmid").text + "%"
Next
Next
End If
Sub getImage(URL, PropName)
DirArray = Split(URL, "/")
ImageFile = DirArray(UBound(DirArray))
xml.Open "GET", URL, False
xml.Send
oStream.open
oStream.write xml.responseBody
oStream.savetofile DestFolder & ImageFile, adSaveCreateOverWrite
oStream.close
SetPropertyValue "Weather." + PropName, DestFolder + ImageFile
End Sub
Click these thumbnails for bigger pictures: