Home Automation via SMS messages

Just got unlimited texting on my cellphone....

Items needed:

1. A dedicated email address for the relaying (POP3, SMTP, no ssl)
2. A cellphone - With SMS texting - Unlimited, preferably, or you'll be paying out the nose...
3. An Ubuntu Server with your home automation items attached to it.

We'll be sending text messages to our email address, then checking the email with the Ubuntu server and running a command accordingly
The server will then reply with a text message letting us know if the command was carried out.

Setting up Email

You'll need a dedicated account -

Setting up the Cellphonage

Sending a text message to an email address is easy - I'm on AT&T, and you can just select an email address just like a phone number.
If that doesn't work, check out this:
http://en.wikipedia.org/wiki/SMS_gateway#Carrier-provided_SMS_to_email_g...

Setting up Ubuntu Server

We're gonna use Mutt to check and sent emails to the phone:

sudo apt-get install mutt

Edit the muttrc configuration file accordingly:

nano ~/.muttrc

Edit:

set pop_user = "EMAIL@WHEREVER.com"
set pop_delete = yes # We'll delete the messages once we download them
set pop_pass = "EMAIL PASSWORD"
set pop_host = "MAIL.WHEREVER.COM"
set spoolfile = "/home/phrank/sms/spool" # The local file where the emails will be stored

set smtp_url = "smtp://USERNAME@mail.WHEREVER.com:PORT/"
set smtp_pass = "EMAIL PASSWORD"
set from = "EMAIL ADDRESS"
set realname = "WHATEVER YOU WANT" # something like "Home Automation"

Test and make sure you can send a recieve emails from within Mutt. "G" to check email, "m" to send

Send an email via the command line

:

echo "message body" | mutt -s "subject" phonenumber@carrier.com

Check the link below on what email address to use to send a SMS text message to your phone:
http://en.wikipedia.org/wiki/SMS_gateway#Carrier-provided_email_or_web_t...

Getting Mail via command line

Running the following command will get new email, put it in the spool file, and then exit:

mutt -e "push  <fetch-mail> <quit>"

We can then run a few commands on the mail spool to get info:

SENDER=$(cat $SPOOL | grep From: | sed 's/From: //g') # Who from
BODY=$(cat $SPOOL | tail -n 6 $FILE | head -n 1) # First line of body of email
COMMAND=$(echo $BODY | cut -d ' ' -f1 | tr [A-Z] [a-z]) # First word of body
TEXT=$(echo $BODY | cut -d ' ' -f2-) # Rest of body

Comments

I've been working on this

I've been working on this since I got unlimited texting with a new phone too. I've been too busy with school and stuff to actually mess with this idea to the point that you have though. It is funny, I thought that I was the only one to think about this... guess not. I just happened to find your site by accident. If I write up a tut of my own (since some of the things that I did was different), then I will be sure to add a link.

I guess that great minds think alike.
Cheers!!

Doc Haven

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options