storms

Taught Audrey to Track Hurricanes

I am heading to the Bahamas but of course, I pick the tail end of hurricane season.  But not to worry, I taught Audrey to track storms and let me know when my cruise is at risk.

I found Weather Underground’s RSS feeds for storm tracking and wrote a script that gets all storms in the North Atlantic, removes any of the “invest storms”, fixes up the text, and then posts it to my dashboard and lifestream.  If its less than 5 days before my departure, she will send me a daily email if any storms are active.

Like a good assistant should.

Details for the Geeks


For the tech on how I did this, here are the ingredients:

All the Audrey tech laid out here including Homeseer Software HS2 Script below running every 20 mins Remember, I am not a professional coder by any means so edit for your own purposes and use at your own risk.

'=============================================================
' check_storms.txt
' Check storms for cruise
' Lee Rogers 9/4/2011 10:39 AM
' http://digitallifediaries.com

Sub Main

strScript = "Vacation Storms"
mto		  = "email_address"
mfrom	  = "homeseer_address"

' ---------------------------------------------------------------------------
'hs.writelog strScript, "Setting database string"
	CONN_STRING	= "Provider=SQLOLEDB;Data Source=V-DATABASE;" _
		& "Initial Catalog=lifestream;User Id=user;Password=password;" _
		& "Connect Timeout=15;Network Library=dbmssocn;"

	intCat	= 35
	dtDate = "10/12/2011"
	dtDiff = dateadd("d","-5", dtDate)

	Set rstDelete = CreateObject("ADODB.Recordset")
	hs.writelog strScript, "Clearing future storm entries"
	strSQL = "DELETE FROM dbo.entries WHERE category = 35;"
	rstDelete.Open strSQL, CONN_STRING, 1, 3, &H0001

	Set rstAddEntry = CreateObject("ADODB.Recordset")
	hs.writelog strScript, "Opening database"
	strSQL = "SELECT * FROM dbo.entries WHERE id=0;"
	rstAddEntry.Open strSQL, CONN_STRING, 1, 3, &H0001

	strRSSUrl = "http://rss.wunderground.com/auto/rss_full/tropical/index.xml?basin=at"
	i = 0

	Set xmlDoc = CreateObject("Microsoft.XMLDOM")
	xmlDoc.async = False
	xmlDoc.Load(strRSSUrl)
	set xmlDocElement = xmlDoc.documentElement
	Set xmlItems      = xmlDocElement.getElementsByTagName("item")
	'strNumMsg = "Currently tracking " & xmlItems.Length & " storms"
	'strNum = "Storms currently being tracked"
	strBody = "
    ” for x = 1 to xmlItems.Length Set xmlItem = xmlItems.nextNode strTitle = xmlItem.selectSingleNode(“title”).Text strTitle = replace(strTitle,” – North Atlantic”,””) strLink = xmlItem.selectSingleNode(“link”).Text strLink = replace(strLink,”.html”,”_5day.gif”) strLink = replace(strLink,”http://www.wunderground.com/tropical/tracking”,”http://icons-ak.wunderground.com/data/images”) strInvest = left(strTitle,6) if not strInvest = “Invest” then strBody = strBody & ”

  • ” & strTitle & “
  • ” ‘ ————————————————————————— ‘ hs.writelog strScript, “Post to life stream” hs.writelog strScript, “Adding ‘” & strTitle & “‘ to database” rstAddEntry.AddNew rstAddEntry.Fields(“title”).Value = strTitle rstAddEntry.Fields(“date”).Value = dtDate rstAddEntry.Fields(“link”).Value = strLink rstAddEntry.Fields(“category”).Value = intCat rstAddEntry.Fields(“tags”).Value = “TheBahamas” rstAddEntry.Update i = i + 1 end if Next strBody = strBody & “

"
	strSubject 	= "Currently tracking " & i & " storm(s)"
	strBody 	= strSubject & strBody

	hs.SetDeviceString "V10", strBody, True

	if date() >= cDate(dtDiff) then
		hs.sendemail mto,mfrom, strSubject & " in the North Atlantic","http://leerogers.me/?q=TheBahamas"
	end if

	if date() = cdate("10/14/2011") then
		hs.DisableEvent "Check Storms"
		hs.writelog strScript, "Disabling storm checking"
	end if

End Sub