Difference between revisions of "WeatherInfo.txt"

From XAP Automation
Jump to: navigation, search
 
m
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<nowiki>
+
<pre>
 
Sub Main()
 
Sub Main()
 +
' This script is linked to the Raw Device for the mi4.weather.xxxx
 +
' Lehane Kellett Oct 2006
 +
'
 
set shell = createobject("wscript.shell")
 
set shell = createobject("wscript.shell")
 
sTZInfoKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\"
 
sTZInfoKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\"
Line 29: Line 32:
 
' Change for your specific weather station - EGVP here
 
' Change for your specific weather station - EGVP here
 
'
 
'
xap.SetDisplayValue "mi4.Weather.egvp", "Report Stale"
+
xap.SetDisplayValue "mi4.Weather.egvp", "<font color=""red"">Report Stale</font>"
 
SetGlobal "ReportedExternalTemp", -999
 
SetGlobal "ReportedExternalTemp", -999
 
else
 
else
xap.SetDisplayValue "mi4.Weather.egvp", "Outside "& CurrTemp & "C"
+
xap.SetDisplayValue "mi4.Weather.egvp", "<font color=""green"">Outside "& CurrTemp & "C</font>"
 
SetGlobal "ReportedExternalTemp", CurrTemp
 
SetGlobal "ReportedExternalTemp", CurrTemp
 
'
 
'
Line 40: Line 43:
 
set shell=nothing
 
set shell=nothing
 
End Sub
 
End Sub
</nowiki>
+
</pre>

Latest revision as of 07:53, 18 October 2006

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