I do a LOT of business traveling, so my home automation system really helps give me some peace of mind while I’m on the road – doing things around the house for me that I can’t do remotely. I was able to easily remote into the house network and check on the status of Watchdog to see how things were going, but it became clear that there was some benefit for Watchdog to proactively communicate with me when I was outside the house. To do this, I wrote a basic SMS Text interface to send messages to my phone and my wife’s phone.
The initial uses of this feature were quite basic, and grew over time. The first main feature was to send security alerts to the driver of a departing vehicle. I made use of the fact that I have sensors so I can tell when the car has recently departed. When this event occurs, Watchdog does a quick sweep of the status of the house. So, if I’m about to leave for work and accidentally forgot to lock the back door, I get an SMS Text message while I’m still in the driveway so I can run back in and address the issue. Later, I wrote other alerts which I will explain in a future post.
In my experience, this worked pretty well, although our wireless provider sometimes had slight delays in delivering SMS Text messages, so I would be a mile away before I receive the text message. However, since switching providers to Verizon the SMS Text messages are practically instantaneous and I’ve not had any problems.
I wrote this using the Visual Basic .NET email interface. It leverages a little-known fact that wireless providers create a new email account for you when you buy an SMS text-enabled phone that looks something like this: firstname.lastname@example.org where the first 10 characters are the cell phone number. I wrote a simple module that took a command line parameter for the address and message, and it sent an email using my cable-provider’s SMTP service. The subject of the email shows up as the headline of the SMS Text, and when you open the text, you see the rest of the message.
Finally, I added the interface to Watchdog to automatically perform the checks and send a message if necessary.
Sub Main(ByVal CmdArgs() As String)
Dim i As Integer
Dim mySMTPClient As SmtpClient = New SmtpClient
Dim strMessage As String
Dim Message As MailMessage = New MailMessage(“Watchdog@VH.com”, CmdArgs(0) & “@vtext.com”)
Message.Subject = “SECURITY WARNING”
Message.Priority = MailPriority.High
strMessage = “”
mySMTPClient.Host = “smtp-server.???.com”
mySMTPClient.Port = 25
If CmdArgs.Length > 0 Then
For i = 1 To (CmdArgs.Length – 1)
strMessage = strMessage & ” ” & CmdArgs(i)
Message.Body = strMessage
Catch ex As Exception
Subject: SECURITY WARNING
Message: Before you leave, lock the back door.