www.homeseer.com    
 

Go Back   HomeSeer Message Board > 3rd Party Plug-Ins/Scripts > Plug-ins by Author > Click Here for List of Author Forums > CFGuy Plug-Ins/Scripts

CFGuy Plug-Ins/Scripts General discussion area for Plug-Ins and Scripts authored or supported by CFGuy (Jeff Farmer)

Reply
 
Thread Tools Display Modes
  #1  
Old April 22nd, 2012, 05:01 PM
pogle's Avatar
pogle pogle is offline
Seer Deluxe
 
Join Date: Sep 2002
Location: Cary, NC - USA
Posts: 150
Script/Compile Issues.. ??

I tried to install the new weathercom files to eliminate the earlier error messages from when the logic was updated, but now I am getting some weird error messages in the logs.. Probably something I did wrong, but unsure how to fix it.. (see below).. also, when I try to go to my HS Setup page (http://192.168.1.26:81/conf), I get pages of javascript code, rather than the normal dashboard.. so I'm not sure how to even fix this:


4/22/2012 4:08:01 PM - SCR - Option Strict OffImports VB = Microsoft.VisualBasicImports System.GlobalizationImports System.IOImports System.TextImports System.Xml imports Schedulerimports SystemPublic Module scriptcode2317#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin Public WithEvents hs As Scheduler.hsapplication Public WithEvents hsp As scheduler.hsp Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End RegionPublic Dim debugMode As Boolean = TruePublic Dim sINI as String = "weathercom_xml.ini"Public Dim sINI2 as String = "\..\data\weathercom_xml\weatherHourly.dat"Public Dim IName as String = "weatherXML_WUnderground"Public Dim intDelayTime as Integer = 10Public Dim bOverRideDL as Boolean = FalseFunction downloadWUConditions(Optional ByVal sParam as String = "") Dim sFile as String sFile = downloadWUXML("Conditions") Return sFileEnd FunctionFunction downloadWUForecst(Optional ByVal sParam as String = "") Dim sFile as String sFile = downloadWUXML("Forecast") Return sFileEnd FunctionFunction downloadWUSecondary(Optional ByVal sParam as String = "") Dim sFile as String if hs.GetINISetting("settings","xmlSource","",sINI) <> "wu" Then if hs.GetINISetting("WeatherUnderground","conditions","",sINI) = "True" Then sFile = downloadWUXML("Conditions") End if End if if hs.GetINISetting("WeatherUnderground","hourly","",sINI) = "True" Then sFile = downloadWUXML("Hourly") End if sFile = downloadWUXML("Secondary") Return sFileEnd FunctionFunction downloadWUXML(Optional ByVal sFile as String = "") Dim aArray(3) as String Dim intmintime, nDiff as Integer Dim dx as Object Dim bRun, strPartnerID, lastran, sFileName, sStatus, sFile2, dChkKey, sURL, sMsg as String 'api.wunderground.com/api/[KEY]/FEATURE/[FEATURE…]/q/[QUERY].[FORMAT] Try debugMode = hs.GetINISetting ("Debug","debugMode","False",sINI) strPartnerID = hs.GetINISetting("Settings","WUAPI","",sINI) if strPartnerID.trim.length = 0 Then if debugMode = True Then dx.Add("The Weather Underground API code (") dx.Add(strPartnerID) dx.Add(") is either missing or invalid. The XML files can not be downloaded without that information. ") dx.Add("Please read the instructions on how to obtain and enter the Weather Underground API code.") hs.WriteLog(IName,dx.Value) dx.Reset End if Exit Function End if intmintime= CInt(hs.GetINISetting ("Settings","mintimewu",intDelayTime,sINI)) sMsg = "Weather Underground (WU) allows a limited number of downloads" sFileName = "N/A" dx = hs.CreateStringClass Select Case lCase(sFile) Case "alerts" sURL = getURLAlerts("") sFileName = getXMLAlerts("") dChkKey="lastranWUAt" bRun = hs.GetINISetting("WeatherUnderground",sFile,"",sINI) Case "almanac" sURL = getURLAlmanac("") sFileName = getXMLAlmanac("") dChkKey="lastranWUAl" bRun = hs.GetINISetting("WeatherUnderground",sFile,"",sINI) intmintime= 180 sMsg = "Weather Underground (WU): The Almanac file only updates once per day" Case "astronomy" sURL = getURLAstronomy("") sFileName = getXMLAstronomy("") dChkKey="lastranWUA" bRun = hs.GetINISetting("WeatherUnderground",sFile,"",sINI) intmintime= 180 sMsg = "Weather Underground (WU): The Astronomy file only updates once per day" Case "conditions" sURL = getURLConditions("") sFileName = getXMLConditions("") dChkKey="lastranWUC" bRun = hs.GetINISetting("WeatherUnderground",sFile,"",sINI) if hs.GetINISetting("settings","xmlSource","",sINI) = "wu" Then bRun = True End if Case "forecast" sURL = getURLForecast("") sFileName = getXMLForecast("") dChkKey="lastranWUF" bRun = hs.GetINISetting("WeatherUnderground",sFile,"",sINI) if hs.GetINISetting("settings","xmlSource","",sINI) = "wu" Then bRun = True End if Case "history" sURL = getURLHistory("") sFileName = getXMLHistory("") dChkKey="lastranHistory" bRun = hs.GetINISetting("WeatherUnderground",sFile,"",sINI) intmintime= 180 sMsg = "Weather Underground (WU): The History file only updates once per day" Case "hourly" sURL = getURLHourly("") sFileName = getXMLHourly("") dChkKey= "lastranHourly" bRun = hs.GetINISetting("WeatherUnderground",sFile,"",sINI) Case "radar" sURL = getURLRadar("") sFileName = getXMLRadar("") dChkKey="lastranWUR" bRun = hs.GetINISetting("WeatherUnderground",sFile,"",sINI) Case "secondary" sURL = getURLSecondary("") sFileName = getXMLSecondary("") dChkKey = "alstranWUS" bRun = True Case Else sURL = URLBuild(sFile) sFileName = getXMLMisc(sFile) dChkKey = "lastran" & sFile bRun = True End Select if lCase(bRun) <> "true" Then if debugMode = True Then dx.Add("The Weather Underground XML file for ") dx.Add(sFile) dx.Add(" has not been selected. Please activate it on the setup page if you wish to use this information.") hs.WriteLog(IName,dx.Value) End if Exit Function End if lastran = hs.GetINISetting ("Settings",dChkKey,"",sINI) if IsNumeric(intmintime) Then if intmintime < intDelayTime Then intmintime = intDelayTime End if End if if NOT IsDate(lastran) Then hs.SaveINISetting ("Settings",dChkKey,DateAdd("n",-15,Now),sINI) lastran = hs.GetINISetting ("Settings",dChkKey,"",sINI) End if if debugMode = True Then hs.WriteLog(IName,"last run time: " & lastran) End if nDiff = DateDiff("n",lastran,Now) if bOverRideDL = True Then intmintime = 0 End if if nDiff >= intmintime Then if len(trim(hs.GetINISetting("Settings","xmlweblocation","",sINI))) > 0 Then dx.Add(hs.GetAPPPath) dx.Add("\html\") dx.Add(hs.GetINISetting("Settings","xmlweblocation","",sINI)) dx.Add("\") dx.Add(Path.GetFileName(sFileName)) sFile2 = dx.Value dx.Reset End if aArray(0) = sURL aArray(1) = sFileName aArray(2) = sFile2 aArray(3) = "WU " & sFile sStatus = hs.runEx("weatherXML_web.vb","downloadFile",aArray,True) if debugMode = true Then hs.WriteLog(IName,"Download Status: " & sStatus) End if if sStatus <> "Success" Then Exit Function End if hs.SaveINISetting ("Settings",dChkKey,Now,sINI) Else if debugMode = true Then aArray(0) = sMsg aArray(1) = intmintime aArray(2) = nDiff aArray(3) = sFile hs.WriteLog(IName,hs.runEx("weatherXML_web.vb","downloadsLimited",aArray,True)) End if End if dx = Nothing Catch e as exception hs.WriteLog(IName,"downloadWUXML: " & e.Message) End Try Return sFileNameEnd FunctionFunction getHistoryCode(ByVal sParam as Object) as String Dim sCode as String Dim gh as New StringBuilder With gh .Append("history_") .Append(Now.addYears(-1).Year) .Append(Now.toString("MM")) .Append(Now.toString("dd")) sCode = .toString End With gh = Nothing Return sCodeEnd FunctionFunction getHourlyCode(ByVal sParam as Object) as String Return "hourly10day"End FunctionFunction getURLAlmanac(ByVal sParam as Object) as String Return URLBuild("almanac",False)End FunctionFunction getURLAlerts(ByVal sParam as Object) as String Return URLBuild("alerts")End FunctionFunction getURLAstronomy(ByVal sParam as Object) as String Return URLBuild("astronomy")End FunctionFunction getURLConditions(ByVal sParam as Object) as String Return URLBuild("conditions")End FunctionFunction getURLConditionsByStation(ByVal sParam as Object) as String Return URLBuild("conditions")End FunctionFunction getURLForecast(ByVal sParam as Object) as String Return URLBuild("forecast10day")End FunctionFunction getURLHistory(ByVal sParam as Object) as String Return URLBuild(getHistoryCode(""))End FunctionFunction getURLGeolookup(ByVal sParam as String) as String Return URLBuild("geolookup/" & sParam)End FunctionFunction getURLHourly(ByVal sParam as Object) as String Return URLBuild(getHourlyCode(""))End FunctionFunction getURLRadar(ByVal sParam as Object) as String Return URLBuild("radar")End FunctionFunction getURLWebcams(ByVal sParam as Object) as String Return URLBuild("webcams")End FunctionFunction getURLSecondary(ByVal sParam as Object) as String Dim aList as Array Dim x as Integer Dim sFileList, sURLList, bRun as String Dim gU as New StringBuilder sFileList = hs.GetINISetting("Settings","WUFiles","",sINI) aList = Split(sFileList,",") gU.Append("geolookup/alerts/radar") For x = 0 to aList.GetUpperBound(0) if lCase(aList(x)) <> "hourly" AND lCase(aList(x)) <> "forecast" AND lCase(aList(x)) <> "conditions" Then bRun = hs.GetINISetting("WeatherUnderground",aList(x),"",sINI) if bRun = "True" Then gU.Append("/") if lCase(aList(x)) = "history" Then gU.Append(lCase(getHistoryCode(""))) Else gU.Append(lCase(aList(x))) End if End if End if Next sURLList = gU.toString gU = Nothing Return URLBuild(sURLList)End FunctionFunction getXMLAlerts(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WUAlerts.xml"End FunctionFunction getXMLAlmanac(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WUAlmanac.xml"End FunctionFunction getXMLAstronomy(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WUAstronomy.xml"End FunctionFunction getXMLConditions(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WUCondition.xml"End FunctionFunction getXMLForecast(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WUForecast.xml"End FunctionFunction getXMLHistory(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WUHistory.xml"End FunctionFunction getXMLHourly(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WUHourly.xml"End FunctionFunction getXMLMisc(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WU" & sParam & ".xml"End FunctionFunction getXMLRadar(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WURadar.xml"End FunctionFunction getXMLSecondary(Optional ByVal sParam as String = "") Return hs.GetAppPath & "\data\weathercom_xml\WUSecondary.xml"End FunctionSub importAlmanac(ByVal strXMLFile as String) Dim aArray(1) as String Dim dRun as Date = Now() Dim x as Integer Dim fs, xNode as Object Dim unitTemp, sValue, sValue2, sYear as String Dim xmlfile As XmlDocument Dim ns As XmlNamespaceManager Dim oNodeList As XmlNodeList Try hs.runEx("weatherXML_dev.vb","getINIValues","",True) fs = hs.CreateStringClass unitTemp = hs.GetINISetting("InfoUnit","Temperature","F",sINI) ' Make sure the file downloaded if hs.runEx("weatherXML_dev.vb","XMLFileExists",strXMLFile,True) = False Then Exit Sub End if ' Start the import from the file xmlfile = New XmlDocument() Try xmlfile.Load(strXMLFile) Catch exc as Exception hs.SaveINISetting("Debug","ErrorReasonAlmanac",trim(exc.Message),sINI) hs.SaveINISetting("Debug","ErrorTimeAlmanac",Trim(Now()),sINI) hs.SaveINISetting("Debug","ErrorFileAlmanac",Trim(Path.GetFileName(strXMLFile)),sINI) dRun = dRun.addMinutes(-30) hs.SaveINISetting("Settings","lastranWUAl",dRun,sINI) fs.Add("Error File: ") fs.Add(Path.GetFileName(strXMLFile)) fs.Add(" Error Reason: ") fs.Add(exc.Message) hs.WriteLog(IName,fs.Value) fs.Reset Exit Sub End Try ns = New XmlNamespaceManager(xmlfile.NameTable) oNodeList = xmlfile.SelectNodes("response/almanac/temp_high", ns) For Each oNode as XmlNode In oNodeList sValue = "" sValue2 = "" xNode = oNode.selectSingleNode("normal") if NOT xNode Is Nothing Then if unitTemp = "F" Then xNode = oNode.selectSingleNode("normal").selectSingleNode("F") Else xNode = oNode.selectSingleNode("normal").selectSingleNode("C") End if if NOT xNode Is Nothing Then Try if unitTemp = "F" Then sValue = oNode.selectSingleNode("normal").selectSingleNode("F").innerText Else sValue = oNode.selectSingleNode("normal").selectSingleNode("C").innerText End if if debugMode = True Then hs.WriteLog(IName,"Todays Normal High: " & sValue) End if hs.runEx("weatherXML_dev.vb","setDeviceTempHistHigh",sValue,True) Catch e as Exception hs.WriteLog(IName,"Normal High: " & e.Message) End Try End if End if xNode = oNode.selectSingleNode("record") if NOT xNode Is Nothing Then if unitTemp = "F" Then xNode = oNode.selectSingleNode("record").selectSingleNode("F") Else xNode = oNode.selectSingleNode("record").selectSingleNode("C") End if if NOT xNode Is Nothing Then Try if unitTemp = "F" Then sValue2 = oNode.selectSingleNode("record").selectSingleNode("F").innerText Else sValue2 = oNode.selectSingleNode("record").selectSingleNode("C").innerText End if sYear = oNode.selectSingleNode("recordyear").innerText if debugMode = True Then hs.WriteLog(IName,"Todays Record High: " & sValue2) hs.WriteLog(IName,"Todays Record Year: " & sYear) End if aArray(0) = sValue2 aArray(1) = sYear hs.runEx("weatherXML_dev.vb","setDeviceTempRecordHigh",aArray,True) Catch e as Exception hs.WriteLog(IName,"Record High: " & e.Message) End Try End if End if Next oNodeList = xmlfile.selectNodes("response/almanac/temp_low") For Each oNode as XmlNode In oNodeList sValue = "" sValue2 = "" xNode = oNode.selectSingleNode("normal") if NOT xNode Is Nothing Then if unitTemp = "F" Then xNode = oNode.selectSingleNode("normal").selectSingleNode("F") Else xNode = oNode.selectSingleNode("normal").selectSingleNode("C") End if if NOT xNode Is Nothing Then Try if unitTemp = "F" Then sValue = oNode.selectSingleNode("normal").selectSingleNode("F").innerText Else sValue = oNode.selectSingleNode("normal").selectSingleNode("C").innerText End if if debugMode = True Then hs.WriteLog(IName,"Todays Normal Low: " & sValue) End if hs.runEx("weatherXML_dev.vb","setDeviceTempHistLow",sValue,True) Catch e as Exception hs.WriteLog(IName,"Todays Normal Low: " & e.Message) End Try End if End if xNode = oNode.selectSingleNode("record") if NOT xNode Is Nothing Then if unitTemp = "F" Then xNode = oNode.selectSingleNode("record").selectSingleNode("F") Else xNode = oNode.selectSingleNode("record").selectSingleNode("C") End if if NOT xNode Is Nothing Then Try if unitTemp = "F" Then sValue2 = oNode.selectSingleNode("record").selectSingleNode("F").innerText Else sValue2 = oNode.selectSingleNode("record").selectSingleNode("C").innerText End if sYear = oNode.selectSingleNode("recordyear").innerText if debugMode = True Then hs.WriteLog(IName,"Todays Record Low: " & sValue2) hs.WriteLog(IName,"Todays Record Year: " & sYear) End if aArray(0) = sValue2 aArray(1) = sYear hs.runEx("weatherXML_dev.vb","setDeviceTempRecordLow",aArray,True) Catch e as Exception hs.WriteLog(IName,"Record Low: " & e.Message) End Try End if End if Next oNodeList = Nothing if debugMode = true Then hs.WriteLog(IName,"Finished importing weather underground almanac.") End if xmlfile = Nothing fs = Nothing Catch e as Exception hs.WriteLog(IName,"importAlmanac: " & e.message) End TryEnd SubSub importAstronomy(ByVal strXMLFile as String) Dim aArray(1) as String Dim dRun as Date = Now() Dim fs as Object Dim sValue, sDay as String Dim xmlfile As XmlDocument Dim ns As XmlNamespaceManager Dim oNodeList As XmlNodeList Try hs.runEx("weatherXML_dev.vb","getINIValues","",True) fs = hs.CreateStringClass ' Start the import from the file xmlfile = New XmlDocument() Try xmlfile.Load(strXMLFile) Catch exc as Exception hs.SaveINISetting("Debug","ErrorReasonAstronomy",trim(exc.Message),sINI) hs.SaveINISetting("Debug","ErrorTimeAstronomy",Trim(Now()),sINI) hs.SaveINISetting("Debug","ErrorFileAstronomy",Trim(Path.GetFileName(strXMLFile)),sINI) dRun = dRun.addMinutes(-30) hs.SaveINISetting("Settings","lastranWUA",dRun,sINI) fs.Add("Error File: ") fs.Add(Path.GetFileName(strXMLFile)) fs.Add(" Error Reason: ") fs.Add(exc.Message) hs.WriteLog(IName,fs.Value) fs.Reset Exit Sub End Try ns = New XmlNamespaceManager(xmlfile.NameTable) oNodeList = xmlfile.SelectNodes("response/moon_phase", ns) For Each oNode as XmlNode In oNodeList sDay = oNode.selectSingleNode("ageOfMoon").innerText sValue = oNode.selectSingleNode("percentIlluminated").innerText fs.Add("percent") fs.Add(sDay) hs.SaveINISetting("Moon",fs.Value,sValue,sINI) fs.Reset aArray(0) = sDay aArray(1) = sValue hs.runEx("weatherXML_dev.vb","setDeviceMoonPhase",aArray,True) Next oNodeList = Nothing if debugMode = true Then hs.WriteLog(IName,"Finished importing weather underground astronomy.") End if xmlfile = Nothing fs = Nothing Catch e as Exception hs.WriteLog(IName,"importAstronomy: " & e.message) End TryEnd SubSub importWUConditions(ByVal strXMLFile as String) Dim aArray(2) as String Dim bChk as Boolean = False Dim bWd, bRh as Boolean Dim dRun as Date = Now() Dim x as Integer Dim fs, xNode, xNode2 as Object Dim curTemp, cBar, wcTemp, wcWind, wcHum, wkWind as String Dim unitTemp, sValue, sValue2, sYear, sWhereFrom, sWindDir as String Dim feelLike, sImage, sLastUp as String Dim xmlfile As XmlDocument Dim ns As XmlNamespaceManager Dim oNodeList As XmlNodeList Try if strXMLFile.trim.length = 0 Then strXMLFile = getXMLConditions("") End if fs = hs.CreateStringClass hs.runEx("weatherXML_dev.vb","getINIValues","",True) unitTemp = hs.GetINISetting("InfoUnit","Temperature","F",sINI) sWhereFrom = hs.GetINISetting("settings","xmlSource","",sINI) ' Start the import from the file xmlfile = New XmlDocument() Try xmlfile.Load(strXMLFile) Catch exc as Exception hs.SaveINISetting("Debug","ErrorReasonCondition",trim(exc.Message),sINI) hs.SaveINISetting("Debug","ErrorTimeCondition",Trim(Now()),sINI) hs.SaveINISetting("Debug","ErrorFileCondition",Trim(Path.GetFileName(strXMLFile)),sINI) dRun = dRun.addMinutes(-30) hs.SaveINISetting("Settings","lastranWUC",dRun,sINI) fs.Add("Error File: ") fs.Add(Path.GetFileName(strXMLFile)) fs.Add(" Error Reason: ") fs.Add(exc.Message) hs.WriteLog(IName,fs.Value) fs.Reset Exit Sub End Try ns = New XmlNamespaceManager(xmlfile.NameTable) oNodeList = xmlfile.SelectNodes("response/current_observation", ns) For Each oNode as XmlNode In oNodeList if sWhereFrom = "wu" OR sWhereFrom = "wwo" OR sWhereFrom = "wb" OR sWhereFrom = "cp" Then xNode = oNode.selectSingleNode("observation_time") if NOT xNode Is Nothing Then if sWhereFrom = "wu" Then Try sValue = oNode.selectSingleNode("observation_time").innerText hs.runEx("weatherXML_dev.vb","checkPreviousTime",sLastUp,True) sValue = replace(sValue,"Last Updated on ","") fs.Add(" ") fs.Add(Year(Now)) fs.Add(",") sLastUp = replace(sValue,",",fs.Value) fs.Reset hs.SaveINISetting ("Location","TimeChecked",Trim(sLastUp),sINI) if debugMode = True Then hs.WriteLog(IName,"time: " & sValue) End if ' Last Updated hs.runEx("weatherXML_dev.vb","setDeviceUpdated",sLastUp,True) Catch ex as Exception hs.WriteLog(IName,"Error with observation time: " & ex.Message) End Try Try ' Current Temp if unitTemp = "F" Then curTemp = oNode.selectSingleNode("temp_f").innerText Else curTemp = oNode.selectSingleNode("temp_c").innerText End if ' Check the temp for daily hi low values curTemp = replace(curtemp,".",NumberFormatInfo.CurrentInfo.NumberDecimalSeparator) hs.runEx("weatherXML_dev.vb","setDailyHiLow",curTemp.toString,True) Catch ex as Exception hs.WriteLog(IName,"Error with current temp: " & ex.Message) End Try Try ' Humidity xNode = oNode.selectSingleNode("relative_humidity") if Not xNode Is Nothing Then sValue = oNode.selectSingleNode("relative_humidity").innerText wcHum = replace(sValue,"%","") hs.runEx("weatherXML_dev.vb","setDeviceHumidity",wcHum.toString,True) bRh = True Else hs.runEx("weatherXML_dev.vb","setDeviceHumidity","",True) End if Catch ex as Exception hs.WriteLog(IName,"Error with humidity: " & ex.Message) End Try End if ' Wind Gust if sWhereFrom = "wu" or sWhereFrom = "wwo" Then if debugMode = True Then hs.WriteLog(IName,"Getting Wind Information") End if Try xNode = oNode.selectSingleNode("wind_gust_mph") if Not xNode Is Nothing Then wkWind = oNode.selectSingleNode("wind_gust_mph").innerText wKWind = hs.runEx("weatherXML_dev.vb","convertMPH",wkWind,True) hs.runEx("weatherXML_dev.vb","setDeviceWindGust",wkWind,True) Else hs.runEx("weatherXML_dev.vb","setDeviceWindGust","",True) End if Catch ex as Exception hs.WriteLog(IName,"Error with wind gust: " & ex.Message) End Try End if if sWhereFrom = "wu" Then Try ' Wind Degrees xNode = oNode.selectSingleNode("wind_degrees") if Not xNode Is Nothing Then hs.runEx("weatherXML_dev.vb","setDeviceWindDeg",oNode.selectSingleNode("wind_degrees").innerText,True) Else hs.runEx("weatherXML_dev.vb","setDeviceWindDeg","",True) End if Catch ex as Exception hs.WriteLog(IName,"Error with wind degrees: " & ex.Message) End Try Try ' Wind Direction xNode = oNode.selectSingleNode("wind_dir") if Not xNode Is Nothing Then sWindDir = oNode.selectSingleNode("wind_dir").innerText hs.runEx("weatherXML_dev.vb","setDeviceWindDir",sWindDir,True) Else hs.runEx("weatherXML_dev.vb","setDeviceWindDir","",True) End if Catch ex as Exception hs.WriteLog(IName,"Error with wind direction: " & ex.Message) End Try Try ' Wind Speed xNode = oNode.selectSingleNode("wind_mph") if Not xNode Is Nothing Then wcWind = oNode.selectSingleNode("wind_mph").innerText wKWind = hs.runEx("weatherXML_dev.vb","convertMPH",wcWind.toString,True) hs.runEx("weatherXML_dev.vb","setDeviceWindSpeed",wkWind.toString,True) bWd = True Else hs.runEx("weatherXML_dev.vb","setDeviceWindSpeed","",True) End if Catch ex as Exception hs.WriteLog(IName,"Error with wind speed: " & ex.Message) End Try Try ' Feel like if debugMode = True Then hs.WriteLog(IName,"Getting Feels Like Information") End if feelLike = "N/A" if uCase(unitTemp) = "F" Then xNode = oNode.selectSingleNode("windchill_f") xNode2 = oNode.selectSingleNode("heat_index_f") Else xNode = oNode.selectSingleNode("windchill_c") xNode2 = oNode.selectSingleNode("heat_index_c") End if if xNode Is Nothing AND xNode2 Is Nothing Then bChk = True Else bChk = true if curTemp > 80 Then if Not xNode2 Is Nothing THen if uCase(unitTemp) = "F" Then feelLike = oNode.selectSingleNode("heat_index_f").innerText if isNumeric(feelLike) Then bChk = false End if Else feelLike = oNode.selectSingleNode("heat_index_c").innerText if isNumeric(feelLike) Then bChk = false End if End if End if Else if Not xNode Is Nothing Then if uCase(unitTemp) = "F" Then feelLike = oNode.selectSingleNode("windchill_f").innerText if isNumeric(feelLike) Then bChk = false End if Else feelLike = oNode.selectSingleNode("windchill_c").innerText if isNumeric(feelLike) Then bChk = false End if End if End if End if End if if bChk = true Then if uCase(unitTemp) = "F" Then wcTemp = curTemp Else wcTemp = curTemp*(9/5)+32 End if aArray(0) = wcTemp aArray(1) = wcWind aArray(2) = wcHum feelLike = hs.runEx("weatherXML_dev.vb","getValueFeelsLike",aArray,True) if isNumeric(feelLike) Then if uCase(unitTemp) <> "F" Then feelLike = (feelLike-32)/9*5 End if End if End if ' Feels Like hs.runEx("weatherXML_dev.vb","setDeviceLike",feelLike,True) Catch ex as Exception hs.WriteLog(IName,"Error with feels lik: " & ex.Message) End Try Try ' Current Temperature if debugMode = True Then hs.WriteLog(IName,"Getting Temperature Information") End if aArray(0) = curTemp aArray(1) = feelLike hs.runEx("weatherXML_dev.vb","setDeviceValueTemp",aArray,True) Catch ex as Exception hs.WriteLog(IName,"Error with current temperature: " & ex.Message) End Try End if if sWhereFrom = "wu" OR sWhereFrom = "cp" Then Try ' Condition & Condition Icon sImage = oNode.selectSingleNode("icon_url").innerText if hs.GetINISetting("Settings","iconSet","",sINI) <> "" Then sImage = replace(sImage,"/i/c/k/",hs.GetINISetting("Settings","iconSet","",sINI)) End if aArray(0) = oNode.selectSingleNode("weather").innerText aArray(1) = sImage hs.runEx("weatherXML_dev.vb","setDeviceValueCondition",aArray,True) ' Condition Image hs.runEx("weatherXML_dev.vb","setDeviceCondImage","",True) Catch ex as Exception hs.WriteLog(IName,"Error with condition image: " & ex.Message) End Try End if if sWhereFrom = "wu" OR sWhereFrom = "wwo" Then Try ' Dewpoint if unitTemp = "F" Then hs.runEx("weatherXML_dev.vb","setDeviceDoTheDew",oNode.selectSingleNode("dewpoint_f").innerText,True) Else hs.runEx("weatherXML_dev.vb","setDeviceDoTheDew",oNode.selectSingleNode("dewpoint_c").innerText,True) End if Catch ex as Exception hs.WriteLog(IName,"Error with dewpoint: " & ex.Message) End Try End if if sWhereFrom = "wu" Then Try ' Barometer if hs.GetINISetting ("InfoUnit","pressureUnit","i",sINI) = "i" Then xNode = oNode.selectSingleNode("pressure_in") Else xNode = oNode.selectSingleNode("pressure_mb") End if if Not xNode Is Nothing Then if hs.GetINISetting ("InfoUnit","pressureUnit","i",sINI) = "i" Then cBar = oNode.selectSingleNode("pressure_in").innerText Else cBar = oNode.selectSingleNode("pressure_mb").innerText End if xNode=oNode.selectSingleNode("pressure_trend") if xNode Is Nothing Then aArray(0) = cBar aArray(1) = "" hs.runEx("weatherXML_dev.vb","setDeviceValueBarometer",aArray,True) Else aArray(0) = cBar aArray(1) = oNode.selectSingleNode("pressure_trend").innerText hs.runEx("weatherXML_dev.vb","setDeviceValueBarometer",aArray,True) End if Else aArray(0) = "" aArray(1) = "" hs.runEx("weatherXML_dev.vb","setDeviceValueBarometer",aArray,True) End if Catch ex as Exception hs.WriteLog(IName,"Error with barometer: " & ex.Message) End Try End if if sWhereFrom = "wu" OR sWhereFrom = "wb" OR sWhereFrom = "cp" Then Try ' Visibility if hs.GetINISetting("InfoUnit","speedUnit","mph",sINI) = "kmph" Then xNode = oNode.selectSingleNode("visibility_km") Else xNode = oNode.selectSingleNode("visibility_mi") End if if Not xNode Is Nothing Then if hs.GetINISetting("InfoUnit","distanceUnit","m",sINI) = "km" Then hs.runEx("weatherXML_dev.vb","setDeviceVisibility",oNode.selectSingleNode("visibility_km").innerText,True) Else hs.runEx("weatherXML_dev.vb","setDeviceVisibility",oNode.selectSingleNode("visibility_mi").innerText,True) End if Else hs.runEx("weatherXML_dev.vb","setDeviceVisibility","",True) End if Catch ex as Exception hs.WriteLog(IName,"Error with visibility: " & ex.Message) End Try End if Try ' UV Index xNode = oNode.selectSingleNode("UV") if NOT xNode Is Nothing Then sValue = oNode.selectSingleNode("UV").innerText hs.runEx("weatherXML_dev.vb","setDeviceUV",sValue,True) End if Catch ex as Exception hs.WriteLog(IName,"Error with UV: " & ex.Message) End Try End if End if Next oNodeList = Nothing xmlfile = Nothing fs = Nothing Catch e as Exception hs.WriteLog(IName,"importCondition: " & e.message) End Try End SubSub importWUForecast(ByVal strXMLFile as String) Dim bChk as Boolean = False Dim bWd, bRh as Boolean Dim dRun as Date = Now() Dim x as Integer Dim fs, ss, FSO, xNode, xNode2 as Object Dim curTemp, cBar, wcTemp, wcWind, wcHum as Single Dim unitTemp, sValue, sValue2, sYear, sWhereFrom, sWindDir, windDirImage as String Dim feelLike, sImage, sKey, sNext, sPeriod, fDev, fNext, sMarS, sMarE as String Dim sCond, sHi, sLow, sPrecip, sDay, sDate, sIconName, fTime as String Dim xmlfile As XmlDocument Dim ns As XmlNamespaceManager Dim oNodeList As XmlNodeList Try if strXMLFile.trim.length = 0 Then strXMLFile = getXMLForecast("") End if fs = hs.CreateStringClass ss = hs.CreateStringClass hs.runEx("weatherXML_dev.vb","getINIValues","",True) unitTemp = hs.GetINISetting("InfoUnit","Temperature","F",sINI) sWhereFrom = hs.GetINISetting("settings","xmlSource","",sINI) ' Start the import from the file xmlfile = New XmlDocument() Try xmlfile.Load(strXMLFile) Catch exc as Exception hs.SaveINISetting("Debug","ErrorReasonForecast",trim(exc.Message),sINI) hs.SaveINISetting("Debug","ErrorTimeForecast",Trim(Now()),sINI) hs.SaveINISetting("Debug","ErrorFileForecast",Trim(Path.GetFileName(strXMLFile)),sINI) dRun = dRun.addMinutes(-30) hs.SaveINISetting("Settings","lastranWUF",dRun,sINI) fs.Add("Error File: ") fs.Add(Path.GetFileName(strXMLFile)) fs.Add(" Error Reason: ") fs.Add(exc.Message) hs.WriteLog(IName,fs.Value) fs.Reset Exit Sub End Try ns = New XmlNamespaceManager(xmlfile.NameTable) hs.runEx("weatherXML_dev.vb","clearINIData","",True) hs.runEx("weatherXML_dev.vb","clearOldINIData","",True) hs.Runex("weatherXML_dev.vb","setDeviceForecastClear","",True) if debugMode = True Then hs.WriteLog(IName,"Set forecast information") End if x = 1 oNodeList = xmlfile.SelectNodes("response/forecast/simpleforecast/forecastdays/forecastday", ns) For Each oNode as XmlNode In oNodeList sValue = oNode.selectSingleNode("date").selectSingleNode("monthname").innerText sValue2 = oNode.selectSingleNode("date").selectSingleNode("day").innerText sYear = oNode.selectSingleNode("date").selectSingleNode("year").innerText fs.Add("DayDate") fs.Add(x) sKey = fs.Value fs.Reset fs.Add(sValue) fs.Add("/") fs.Add(sValue2) fs.Add("/") fs.Add(sYear) hs.SaveINISetting("Forecast",sKey,fs.Value,sINI) sDate = fs.Value fs.Reset fs.Add("DayName") fs.Add(x) sKey = fs.Value sValue = oNode.selectSingleNode("date").selectSingleNode("weekday").innerText hs.SaveINISetting("Forecast",sKey,sValue,sINI) sDay = sValue fs.Reset if unitTemp = "F" Then sValue = oNode.selectSingleNode("high").selectSingleNode("fahrenheit").innerText Else sValue = oNode.selectSingleNode("high").selectSingleNode("celsius").innerText End if fs.Add("DayHi") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,sValue,sINI) sHi = sValue fs.Reset if unitTemp = "F" Then sValue = oNode.selectSingleNode("low").selectSingleNode("fahrenheit").innerText Else sValue = oNode.selectSingleNode("low").selectSingleNode("celsius").innerText End if fs.Add("DayLow") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,sValue,sINI) sLow = sValue fs.Reset sValue = oNode.selectSingleNode("conditions").innerText fs.Add("DayCondition") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,sValue,sINI) if len(trim(sValue)) > 0 THen if len(Trim(hs.GetINISetting("Language Conditions",sValue,"",sINI))) = 0 Then hs.SaveINISetting("Language Conditions",sValue,sValue,sINI) End if End if sCond = sValue fs.Reset sValue = oNode.selectSingleNode("pop").innerText fs.Add("DayPrecipitation") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,sValue,sINI) sPrecip = sValue fs.Reset sValue = oNode.selectSingleNode("icon_url").innerText if hs.GetINISetting("Settings","iconSet","",sINI) <> "" Then sValue = replace(sValue,"/i/c/k/",hs.GetINISetting("Settings","iconSet","",sINI)) End if fs.Add("DayIcon") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,sValue,sINI) fs.Reset fs.Add("DayIconName") fs.Add(x) sKey = fs.Value sIconName = hs.runEx("weatherXML_dev.vb","saveIcon",sValue,True) hs.SaveINISetting("Forecast",sKey,sIconName,sINI) fs.Reset fs.Add("DayForecast") fs.Add(x) sKey = fs.Value sValue = hs.runEx("weatherXML_dev.vb","buildAForecast",cStr(x),True) if debugMode = True Then hs.WriteLog(IName,"Forecast: " & sValue) End if hs.SaveINISetting("Forecast",sKey,sValue,sINI) fs.Reset ' extra info for ini file only fs.Add("windSpeedkph") fs.Add(x) sKey = fs.Value sValue = oNode.selectSingleNode("avewind").selectSingleNode("kph").innerText hs.SaveINISetting("Forecast",sKey,sValue,sINI) fs.Reset fs.Add("windSpeed") fs.Add(x) sKey = fs.Value sValue = oNode.selectSingleNode("avewind").selectSingleNode("mph").innerText hs.SaveINISetting("Forecast",sKey,sValue,sINI) fs.Reset fs.Add("windDir") fs.Add(x) sKey = fs.Value sValue = oNode.selectSingleNode("avewind").selectSingleNode("dir").innerText hs.SaveINISetting("Forecast",sKey,sValue,sINI) fs.Reset ' Set the rest to blank fs.Add("NightCondition") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,"",sINI) fs.Reset fs.Add("NightPrecipitation") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,"",sINI) fs.Reset fs.Add("NightIcon") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,"",sINI) fs.Reset fs.Add("NightIconName") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,"",sINI) fs.Reset fs.Add("NightForecast") fs.Add(x) sKey = fs.Value hs.SaveINISetting("Forecast",sKey,"",sINI) fs.Reset x = x + 1 Next oNodeList = Nothing if debugMode = True Then hs.WriteLog(IName,"Start forecast devices") End if oNodeList = xmlfile.SelectNodes("response/forecast/txt_forecast/forecastdays/forecastday", ns) x = 1 sNext = "Today" For Each oNode as XmlNode In oNodeList sValue = oNode.selectSingleNode("title").innerText if inStr(sValue,"Tonight") > 0 Then sNext = "Tonight" End if sValue2 = "" if lCase(hs.GetINISetting("InfoUnit","Temperature","F",sINI)) = "f" Then xNode = oNode.selectSingleNode("fcttext") if NOT xNode Is Nothing Then sValue2 = oNode.selectSingleNode("fcttext").innerText Else xNode = oNode.selectSingleNode("fcttext_metric") if NOT xNode Is Nothing Then sValue2 = oNode.selectSingleNode("fcttext_metric").innerText End if End if Else xNode = oNode.selectSingleNode("fcttext_metric") if NOT xNode Is Nothing Then sValue2 = oNode.selectSingleNode("fcttext_metric").innerText Else xNode = oNode.selectSingleNode("fcttext") if NOT xNode Is Nothing Then sValue2 = oNode.selectSingleNode("fcttext").innerText End if End if End if if sNext = "Today" Then sPeriod = "Today" sNext = "Tonight" Elseif sNext = "Tonight" Then sPeriod = "Tonight" sNext = "Tomorrow" Elseif sNext = "Tomorrow" Then sPeriod = "Tomorrow" sNext = "Tomorrow Night" Elseif sNext = "Tomorrow Night" Then sPeriod = "Tomorrow Night" sNext = "Other" Elseif sNext = "Other" Then sPeriod = sValue End if fs.Add("ExtForecast") fs.Add(x) sKey = fs.Value fs.Reset fs.Add(sPeriod) fs.Add(": ") fs.Add(sValue2) hs.SaveINISetting("WeatherCom_ExtForecast",sKey,fs.Value,sINI) ss.Add(fs.Value) fs.Reset x = x + 1 Next oNodeList = Nothing xmlfile = Nothing ss = Nothing fs = Nothing hs.runEx("weatherXML_dev.vb","setDeviceForecast","",True) Catch e as Exception hs.WriteLog(IName,"importForecast: " & e.message) End Try End SubSub importHourly(Optional ByVal sParam as String = "") importForecastHourly(hs.GetAppPath & "\data\weathercom_xml\WUHourly.xml")End SubSub importForecastHourly(ByVal strXMLFile as String) Dim dRun as Date = Now() Dim x as Integer Dim fs, ss, xNode as Object Dim unitTemp, unitSpeed, sInvalid, sValue as String Dim xmlfile As XmlDocument Dim ns As XmlNamespaceManager Dim oNodeList As XmlNodeList Try hs.runEx("weatherXML_dev.vb","getINIValues","",True) fs = hs.CreateStringClass ss = hs.CreateStringClass unitTemp = hs.GetINISetting("InfoUnit","Temperature","F",sINI) unitSpeed = hs.GetINISetting("InfoUnit","SpeedUnit","mph",sINI) sInvalid = hs.GetINISetting("HStouch","invalidDevVal","-999",sINI) ' Make sure the file downloaded if hs.runEx("weatherXML_dev.vb","XMLFileExists",strXMLFile,True) = False Then Exit Sub End if ' Start the import from the XML file xmlfile = New XmlDocument() Try xmlfile.Load(strXMLFile) Catch exc as Exception hs.SaveINISetting("Debug","ErrorReasonHourly",trim(exc.Message),sINI) hs.SaveINISetting("Debug","ErrorTimeHourly",Trim(Now()),sINI) hs.SaveINISetting("Debug","ErrorFileHourly",Trim(Path.GetFileName(strXMLFile)),sINI) dRun = dRun.addMinutes(-30) hs.SaveINISetting("Settings","lastranWUH",dRun,sINI) fs.Add("Error File: ") fs.Add(Path.GetFileName(strXMLFile)) fs.Add(" Error Reason: ") fs.Add(exc.Message) hs.WriteLog(IName,fs.Value) fs.Reset Exit Sub End Try if debugMode = True Then hs.WriteLog(IName,"Getting hourly forecast information") End if ns = New XmlNamespaceManager(xmlfile.NameTable) oNodeList = xmlfile.SelectNodes("response/hourly_forecast/forecast", ns) if oNodeList.Count > 0 Then for x = 245 to 120 Step -1 fs.Add("hourTime") fs.Add(x) if len(trim(hs.GetINISetting("HourlyForecast",fs.Value,"",sINI2))) > 0 Then hs.SaveINISetting("HourlyForecast",fs.Value,"",sINI2) End if fs.Reset fs.Add("hourTemp") fs.Add(x) if len(trim(hs.GetINISetting("HourlyForecast",fs.Value,"",sINI2))) > 0 Then hs.SaveINISetting("HourlyForecast",fs.Value,"",sINI2) End if fs.Reset fs.Reset fs.Add("hourDewp") fs.Add(x) if len(trim(hs.GetINISetting("HourlyForecast",fs.Value,"",sINI2))) > 0 Then hs.SaveINISetting("HourlyForecast",fs.Value,"",sINI2) End if fs.Reset fs.Add("hourCond") fs.Add(x) if len(trim(hs.GetINISetting("HourlyForecast",fs.Value,"",sINI2))) > 0 Then hs.SaveINISetting("HourlyForecast",fs.Value,"",sINI2) End if fs.Reset fs.Add("hourIcon") fs.Add(x) if len(trim(hs.GetINISetting("HourlyForecast",fs.Value,"",sINI2))) > 0 Then hs.SaveINISetting("HourlyForecast",fs.Value,"",sINI2) End if fs.Reset fs.Add("hourIconName") fs.Add(x) if len(trim(hs.GetINISetting("HourlyForecast",fs.Value,"",sINI2))) > 0 Then hs.SaveINISetting("HourlyForecast",fs.Value,"",sINI2) End if fs.Reset Next End if x = 0 For Each oNode as XmlNode In oNodeList xNode = oNode.selectSingleNode("FCTTIME").selectSingleNode("pretty") if NOT xNode Is Nothing Then sValue = oNode.selectSingleNode("FCTTIME").selectSingleNode("pretty").innerText Else sValue = "" End if fs.Add("hourTime") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset if lCase(unitTemp) = "f" Then xNode = oNode.selectSingleNode("temp").selectSingleNode("english") Else xNode = oNode.selectSingleNode("temp").selectSingleNode("metric") End if if NOT xNode Is Nothing Then if lCase(unitTemp) = "f" Then sValue = oNode.selectSingleNode("temp").selectSingleNode("english").innerText Else sValue = oNode.selectSingleNode("temp").selectSingleNode("metric").innerText End if Else sValue = "" End if fs.Add("hourTemp") fs.Add(x+1) if cInt(sValue) < -15 OR cInt(sValue) > 200 Then sValue = sInvalid End if hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset if lCase(unitTemp) = "f" Then xNode = oNode.selectSingleNode("dewpoint").selectSingleNode("english") Else xNode = oNode.selectSingleNode("dewpoint").selectSingleNode("metric") End if if NOT xNode Is Nothing Then if lCase(unitTemp) = "f" Then sValue = oNode.selectSingleNode("dewpoint").selectSingleNode("english").innerText Else sValue = oNode.selectSingleNode("dewpoint").selectSingleNode("metric").innerText End if Else sValue = "" End if fs.Add("hourDewp") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset xNode = oNode.selectSingleNode("condition") if NOT xNode Is Nothing Then sValue = oNode.selectSingleNode("condition").innerText Else sValue = "" End if fs.Add("hourCond") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) if len(trim(sValue)) > 0 Then if len(Trim(hs.GetINISetting("Language Conditions",sValue,"",sINI))) = 0 Then hs.SaveINISetting("Language Conditions",sValue,sValue,sINI) End if End if fs.Reset xNode = oNode.selectSingleNode("icon_url") if NOT xNode Is Nothing Then sValue = oNode.selectSingleNode("icon_url").innerText Else sValue = "" End if if hs.GetINISetting("Settings","iconSet","",sINI) <> "" Then sValue = replace(sValue,"/i/c/k/",hs.GetINISetting("Settings","iconSet","",sINI)) End if fs.Add("hourIcon") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset fs.Add("hourIconName") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,hs.runEx("weatherXML_dev.vb","saveIcon",sValue,True),sINI2) fs.Reset if lCase(unitSpeed) = "mph" Then xNode = oNode.selectSingleNode("wspd").selectSingleNode("english") Else xNode = oNode.selectSingleNode("wspd").selectSingleNode("metric") End if if NOT xNode Is Nothing Then if lCase(unitSpeed) = "mph" Then sValue = oNode.selectSingleNode("wspd").selectSingleNode("english").innerText Else sValue = oNode.selectSingleNode("wspd").selectSingleNode("metric").innerText End if Else sValue = "" End if fs.Add("hourWSpd") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset xNode = oNode.selectSingleNode("wdir").selectSingleNode("dir") if NOT xNode Is Nothing Then sValue = oNode.selectSingleNode("wdir").selectSingleNode("dir").innerText Else sValue = "" End if fs.Add("hourWDir") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset xNode = oNode.selectSingleNode("uvi") if NOT xNode Is Nothing Then sValue = oNode.selectSingleNode("uvi").innerText Else sValue = "" End if fs.Add("hourUVIn") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset xNode = oNode.selectSingleNode("humidity") if NOT xNode Is Nothing Then sValue = oNode.selectSingleNode("humidity").innerText Else sValue = "" End if fs.Add("hourHumi") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset if lCase(unitTemp) = "f" Then xNode = oNode.selectSingleNode("windchill").selectSingleNode("english") Else xNode = oNode.selectSingleNode("windchill").selectSingleNode("metric") End if if NOT xNode Is Nothing Then if lCase(unitTemp) = "f" Then sValue = oNode.selectSingleNode("windchill").selectSingleNode("english").innerText Else sValue = oNode.selectSingleNode("windchill").selectSingleNode("metric").innerText End if Else sValue = "" End if fs.Add("hourWchl") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset if lCase(unitTemp) = "f" Then xNode = oNode.selectSingleNode("heatindex").selectSingleNode("english") Else xNode = oNode.selectSingleNode("heatindex").selectSingleNode("metric") End if if NOT xNode Is Nothing Then if lCase(unitTemp) = "f" Then sValue = oNode.selectSingleNode("heatindex").selectSingleNode("english").innerText Else sValue = oNode.selectSingleNode("heatindex").selectSingleNode("metric").innerText End if Else sValue = "" End if fs.Add("hourHInd") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset if lCase(unitTemp) = "f" Then xNode = oNode.selectSingleNode("feelslike").selectSingleNode("english") Else xNode = oNode.selectSingleNode("feelslike").selectSingleNode("metric") End if if NOT xNode Is Nothing Then if lCase(unitTemp) = "f" Then sValue = oNode.selectSingleNode("feelslike").selectSingleNode("english").innerText Else sValue = oNode.selectSingleNode("feelslike").selectSingleNode("metric").innerText End if Else sValue = "" End if fs.Add("hourFeels") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset if lCase(unitTemp) = "f" Then xNode = oNode.selectSingleNode("snow").selectSingleNode("english") Else xNode = oNode.selectSingleNode("snow").selectSingleNode("metric") End if if NOT xNode Is Nothing Then if lCase(unitTemp) = "f" Then sValue = oNode.selectSingleNode("snow").selectSingleNode("english").innerText Else sValue = oNode.selectSingleNode("snow").selectSingleNode("metric").innerText End if Else sValue = "" End if fs.Add("hourSnow") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset xNode = oNode.selectSingleNode("pop") if NOT xNode Is Nothing Then sValue = oNode.selectSingleNode("pop").innerText Else sValue = "" End if fs.Add("hourPop%") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset if lCase(unitTemp) = "f" Then xNode = oNode.selectSingleNode("qpf").selectSingleNode("english") Else xNode = oNode.selectSingleNode("qpf").selectSingleNode("metric") End if if NOT xNode Is Nothing Then if lCase(unitTemp) = "f" Then sValue = oNode.selectSingleNode("qpf").selectSingleNode("english").innerText Else sValue = oNode.selectSingleNode("qpf").selectSingleNode("metric").innerText End if Else sValue = "" End if fs.Add("hourTqpf") fs.Add(x+1) hs.SaveINISetting("HourlyForecast",fs.Value,sValue,sINI2) fs.Reset x = x + 1 Next oNodeList = Nothing xmlfile = Nothing ss = Nothing fs = Nothing Catch e as Exception hs.WriteLog(IName,"importForecastHourly: " & e.message) End Try End SubSub importHistory(ByVal strXMLFile as String) Dim dRun as Date = Now() Dim fs as Object Dim sValue, sTemp, unitTemp as String Dim xmlfile As XmlDocument Dim ns As XmlNamespaceManager Dim oNodeList As XmlNodeList Try hs.runEx("weatherXML_dev.vb","getINIValues","",True) unitTemp = hs.GetINISetting("InfoUnit","Temperature","F",sINI) fs = hs.CreateStringClass ' Make sure the file downloaded if hs.runEx("weatherXML_dev.vb","XMLFileExists",strXMLFile,True) = False Then Exit Sub End if ' Start the import from the file xmlfile = New XmlDocument() Try xmlfile.Load(strXMLFile) Catch exc as Exception hs.SaveINISetting("Debug","ErrorReasonHistory",trim(exc.Message),sINI) hs.SaveINISetting("Debug","ErrorTimeHistory",Trim(Now()),sINI) hs.SaveINISetting("Debug","ErrorFileHistory",Trim(Path.GetFileName(strXMLFile)),sINI) dRun = dRun.addMinutes(-30) hs.SaveINISetting("Settings","lastranHistory",dRun,sINI) fs.Add("Error File: ") fs.Add(Path.GetFileName(strXMLFile)) fs.Add(" Error Reason: ") fs.Add(exc.Message) hs.WriteLog(IName,fs.Value) fs.Reset Exit Sub End Try ns = New XmlNamespaceManager(xmlfile.NameTable) oNodeList = xmlfile.SelectNodes("response/history/dailysummary/summary", ns) For Each oNode as XmlNode In oNodeList if unitTemp = "F" Then sTemp = oNode.selectSingleNode("maxtempi").innerText sValue= oNode.selectSingleNode("mintempi").innerText Else sTemp = oNode.selectSingleNode("maxtempm").innerText sValue= oNode.selectSingleNode("mintempm").innerText End if hs.SaveINISetting("WeatherInfo","TempYearAgoHigh",sTemp,sINI) hs.runEx("weatherXML_dev.vb","setDeviceLastYearHigh",sTemp,True) hs.SaveINISetting("WeatherInfo","TempYearAgoLow",sValue,sINI) hs.runEx("weatherXML_dev.vb","setDeviceLastYearLow",sValue,True) fs.Reset Next oNodeList = Nothing if debugMode = true Then hs.WriteLog(IName,"Finished importing weather underground history.") End if xmlfile = Nothing fs = Nothing Catch e as Exception hs.WriteLog(IName,"importHistory: " & e.message) End TryEnd SubSub importWUSecondary(Optional sParam as String = "") Dim aArray as Array Dim x as Integer Dim sFileList, bRun as String Try if debugMode = True Then hs.WriteLog(IName,"Begin import of secondary data") End if if hs.GetINISetting("settings","xmlSource","",sINI) <> "wu" Then if hs.GetINISetting("WeatherUnderground","conditions","",sINI) = "True" Then importWUConditions(getXMLConditions("")) End if End if sFileList = hs.GetINISetting("Settings","WUFiles","",sINI) aArray = split(sFileList,",") For x = 0 to aArray.GetUpperBound(0) bRun = hs.GetINISetting("WeatherUnderground",aArray(x),"",sINI) if bRun = "True" Then If lCase(aArray(x)) = "almanac" Then importAlmanac(getXMLSecondary("")) Elseif lCase(aArray(x)) = "astronomy" Then importAstronomy(getXMLSecondary("")) Elseif lCase(aArray(x)) = "history" Then importHistory(getXMLSecondary("")) End if End if Next if hs.GetINISetting("WeatherUnderground","hourly","",sINI) = "True" Then importForecastHourly(getXMLHourly("")) End if Catch ex as Exception hs.WriteLog(IName,"importWUSeconday: " & ex.Message) End TryEnd SubFunction URLBuild(ByVal sFeature as String,Optional ByVal bLang as Boolean = True) as String Dim sReturn as String Dim sU as New StringBuilder With sU .Append(URLDomain()) .Append(sFeature) if bLang = True Then .Append(URLLanguage()) End if .Append("/q/") if hs.GetINISetting("Settings","wuStation","",sINI).trim.length = 0 Then .Append(URLLatLon()) Else .Append("pws:") .Append(hs.GetINISetting("Settings","wuStation","",sINI).trim) End if .Append(URLType()) End With sReturn = sU.ToString sU = Nothing Return sReturnEnd FunctionFunction URLDomain() as String Dim sReturn as String Dim sDom as New Stringbuilder With sDom .Append(hs.GetINISetting("Settings","wuURL","",sINI)) if sDom.toString.trim.length = 0 Then .Append("http://api.wunderground.com/api/") End if .Append(hs.GetINISetting("Settings","WUAPI","*****MISSING API CODE*****",sINI)) .Append("/") sReturn = .toString End With sDom = Nothing Return sReturnEnd FunctionFunction URLLanguage() as String Dim sReturn as String Dim sL as New Stringbuilder With sL .Append(hs.GetINISetting("Settings","WULanguage","",sINI)) if .toString.trim.length > 0 Then .Insert(0,"/lang:") End if sReturn = .toString End With sl = Nothing Return sReturnEnd FunctionFunction URLLatLon() as String Return hs.GetINISetting("Settings","wulat","",sINI) & "," & hs.GetINISetting("Settings","wulon","",sINI)End FunctionFunction URLType() as String Return ".xml"End FunctionEnd Module
4/22/2012 4:08:01 PM - Error - Script compile error: Type 'XmlDocument' is not defined.on line 309
Reply With Quote
  #2  
Old April 22nd, 2012, 07:38 PM
CFGuy's Avatar
CFGuy CFGuy is offline
Have A Blessed Day
 
Join Date: Jan 2001
Location: Basehor KS
Posts: 5,048
This means the scriptingReferences has not been setup yet.

Check out this thread:

http://forums.homeseer.com/showthread.php?t=153232
__________________
--
Jeff Farmer
HS 3.0.0.312, HSPhone
My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
Other Plugins In Use: APCUPSD, EasyTrigger, FBitSeer, HSTouch Server, Kinect, PHLocation, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer 1122, Panasonic BDT-110, Panasonic BDT-210 x2
Reply With Quote
  #3  
Old April 24th, 2012, 01:27 PM
CFGuy's Avatar
CFGuy CFGuy is offline
Have A Blessed Day
 
Join Date: Jan 2001
Location: Basehor KS
Posts: 5,048
Make sure it is in the [Settings] section:

Putting it at the end of the file most likely puts it in a different section.
Reply With Quote
  #4  
Old April 24th, 2012, 01:29 PM
pogle's Avatar
pogle pogle is offline
Seer Deluxe
 
Join Date: Sep 2002
Location: Cary, NC - USA
Posts: 150
Jeff,

Youre too fast.. just after I sent the last msg i looked again at the file and saw that I had put it in the "display" section - duh. I deleted my msg to you only to find that you had already replied.. now thats top service.. thanks!!!!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:12 PM.


Copyright HomeSeer Technologies, LLC