WeatherInfo.txt

From XAP Automation
Jump to: navigation, search
Sub Main()
' This script is linked to the Raw Device for the mi4.weather.xxxx
' Lehane Kellett Oct 2006
'
	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", "<font color=""red"">Report Stale</font>"
		SetGlobal "ReportedExternalTemp", -999
	else
		xap.SetDisplayValue "mi4.Weather.egvp", "<font color=""green"">Outside "& CurrTemp & "C</font>"
		SetGlobal "ReportedExternalTemp", CurrTemp
'
' You may want to add other code here
'
	end if
	set shell=nothing
End Sub