Difference between revisions of "WeatherInfo.txt"

From XAP Automation
Jump to: navigation, search
 
Line 1: Line 1:
<nowiki>
+
<pre>
 
Sub Main()
 
Sub Main()
 
set shell = createobject("wscript.shell")
 
set shell = createobject("wscript.shell")
Line 40: Line 40:
 
set shell=nothing
 
set shell=nothing
 
End Sub
 
End Sub
</nowiki>
+
</pre>

Revision as of 08:55, 13 October 2006

Sub Main()
	set shell = createobject("wscript.shell")
	sTZInfoKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\"
	sActiveTimeBias = "ActiveTimeBias"
	nActiveTimeBias = shell.regread(sTZInfoKey & sActiveTimeBias)
'
' Have local offset from GMT/UTC in nActiveTimeBias
'
' Get reading from xAPWeather for local station
'
	CurrTemp=xap.getfromraw(rawmessage, "Weather.Report,tempc")
	ReportTime=xap.getfromraw(rawmessage, "Weather.Report,utc")
	ReportDate=xap.getfromraw(rawmessage, "Weather.Report,date")
'
'Check following line for all locales
'YMMV
'
	t=Mid(ReportDate,5,2)&"/"&Mid(ReportDate,7,2)&"/"&Left(ReportDate,4)&" " & ReportTime&":00"
	if IsDate(t) then
    		tv=CDate(t)
    		td=DateDiff("n",tv,Now())+nActiveTimeBias
	else
		td=99999
	end if
	if ((td > 140) or (CurrTemp="unknown")) then
'
' Update values displayed on Floorplan
' Change for your specific weather station - EGVP here
'
		xap.SetDisplayValue "mi4.Weather.egvp", "Report Stale"
		SetGlobal "ReportedExternalTemp", -999
	else
		xap.SetDisplayValue "mi4.Weather.egvp", "Outside "& CurrTemp & "C"
		SetGlobal "ReportedExternalTemp", CurrTemp
'
' You may want to add other code here
'
	end if
	set shell=nothing
End Sub