Google Voice SMS Plugin

Posted on
Wed Oct 19, 2011 4:46 pm
ChrisB offline
User avatar
Posts: 41
Joined: Sep 12, 2011

Google Voice SMS Plugin

Note: this plugin has been open sourced and is now available on GitHub. Check there for the latest version.

About the Google Voice SMS Plugin

This plugin enables Indigo 5 to send and receive (works with SIRI) SMS messages through a free Google Voice account. Thanks to baadpuppy (Jim) for introducing the SMS concept in a previous post.

There are added security measures in place to help prevent unauthorized use:

1) You must define a device for each cell phone number that you send/receive text messages to/from. When an SMS is received, it is checked against the existing devices to determine if the from number is authorized.

2) You have complete control over what functions can be performed and what the commands are that perform those functions.

3) For each trigger you define, you can have the Google Voice SMS plugin send you a confirmation that the action has been performed. This provides acknowledgment for the commands you send and, in the unlikely event your number is spoofed, you will also receive acknowledgments.

4) If you want to be creative, you can create each trigger to work on a condition that a variable has a user defined value (i.e. variable LoggedIn is True). The first SMS command you send could be Login password (where password equals whatever you define). Create a trigger looking for that command/password and if received it changes the value of the variable LoggedIn to True. From that point on, all SMS triggers you defined will work because the condition will be True. When you are done, send a command (i.e. Logout) and the LoggedIn variable will be set to False and all SMS triggers will be disabled.

Of course, with anything, you are responsible for ensuring that your system/home is secure. There are various ways to communicate with Indigo from outside of your home and with each method you increase the risk of unauthorized access to your home. This plugin is great for controlling lights, scenes, A/V equipment (using the Global Cache Plugin), thermostats, iTunes and other plugins. Although you can send commands to your alarm panel, unlock doors and open the garage door, it is definitely not recommend. I am in no way responsible for the plugin's proper or improper uses. THE END USER HEREBY WAIVES ALL LIABILITY CLAIMS. :-)

Note: Currently, the plugin removes all SMS messages from Google Voice after it retrieves/parses the messages - I couldn't get the API to only delete the SMS messages that were read. Google Voice saves all deleted messages in the Trash for 30 days (or more from what I read). I created a separate Google Voice account just for Indigo because I didn't want others to know/have the number to my HA system. I would highly recommend you do the same. In fact, my Indigo uses a separate e-mail account for that very same reason.

Required prerequisites
In order to use this plugin, you must have a valid Google Voice account. The account costs nothing although I'm sure they would limit the number of SMS message if it is abused. Follow this link to setup your account.

Future Functionality
- TBD

Installation/Usage

New installation and upgrade existing installation

1. Download the plugin from GitHub
2. Unzip it and double-click on the GoogleVoiceSMS.indigoPlugin

Plugin config screen.png
Plugin config screen.png (50.52 KiB) Viewed 28200 times


6. Enter your Google Voice e-mail and password - click save.

7. The next step is to create one or more SMS devices (cell phone). Make sure your screen looks like the one below (except for the name).

Create new SMS Device.png
Create new SMS Device.png (54.48 KiB) Viewed 28200 times


8. Click on Edit Device Settings and enter the 10 digit number for the SMS device. Do not include any symbols, spaces or a leading "1" in the number. Click Save and then OK on the Create New Device window.

Edit SMS device number.png
Edit SMS device number.png (28.36 KiB) Viewed 28200 times


9. To send SMS messages, create an action and define the text message you would like to send to the SMS device.

Create SMS Action.png
Create SMS Action.png (70.49 KiB) Viewed 28200 times

Action SMS message to send.png
Action SMS message to send.png (31.96 KiB) Viewed 28200 times

NOTE: You can use the special variable substitution fields in the Message to Send field - see Variable Substitution for more information.


10. Each device created also has the ability to receive SMS messages. In order to respond to those messages, create a trigger that will respond to the Received Text of an SMS device.

Trigger Defined.png
Trigger Defined.png (50.2 KiB) Viewed 28014 times


Make sure you set Received Text Becomes Equal to whatever message you are looking for. The plugin automatically converts all text received to lower case letters, strips all leading and trailing spaces and removes all periods from the contents. In order for the plugin to work properly, enter the received text in lower case letters.

The first action I defined toggles the lamp on/off.

Trigger Action 1.png
Trigger Action 1.png (54.8 KiB) Viewed 28014 times


The second action sends me a confirmation that the command was received and performed.

Trigger Action 2.png
Trigger Action 2.png (64.54 KiB) Viewed 28014 times

Trigger Action 2 - Edit Device.png
Trigger Action 2 - Edit Device.png (32.24 KiB) Viewed 28000 times

NOTE: You can use the special variable substitution fields in the Message to Send field - see Variable Substitution for more information.


You can get creative with the commands and response that you send/receive. For instance, a conversation with PAT (the name of my system) looks like this:

iPhone Screen.PNG
iPhone Screen.PNG (101.62 KiB) Viewed 27999 times


Notice that, because the plugin converts commands to lower case and strips the period, ToGGle desk LaMp. works the same as Toggle desk lamp. If you would like to do the same thing, refer to the second trigger action screen above. The trigger is activated by a text from the Google Voice SMS plugin, the first action toggles the lamp and the second action uses the Google Voice SMS plugin to send a response back.

That's all there is to it!

A little background
Since I started with Indigo, I've been looking for a way to receive SMS messages for various notifications. I tried different approaches but I couldn't get anything to work. I gave up and resorted to having Indigo send e-mails instead. One night I was reading the forum and found a post by Jim (baadpuppy) outlining a script that he created to send SMS through Google Voice -- I was in Heaven! It took me two days to figure out how to get it installed and working because, in the end, Google had made changes to the login methods which rendered the pygooglevoice module unusable. After a little research, I found the problem and made the correction in pygooglevoice - everything started working.

I thought others may want the same functionality so I created a plugin that takes care of everything for you.

If you find any bugs, have feature requests or suggestions please let me know.

~Chris

Change History
Version 1.1.2 (November 2, 2011)
- Added the ability to do variable substitution in the Send an SMS message Action. See Variable Substitution for more information.

Version 1.1.1 (November 2, 2011):
- Captured error generated when no preferences have been entered.

Version 1.1.0 (November 2, 2011):
-Added the ability to receive SMS commands
-The Google Voice SMS Plugin now maintains a persistent connection to Google Voice to maximize the response received from SMS messages.
-The send SMS process has been modified to support the persistent Google Voice connection
-Included additional support files to parse HTML from Google
Note: I'll release a maintenance update that will streamline some of the code that I used.

Version 1.0.0 (October 19, 2011):
- Initial Public release of the Google Voice SMS Plugin
Last edited by ChrisB on Wed Nov 02, 2011 11:18 pm, edited 9 times in total.

Posted on
Thu Oct 20, 2011 9:32 am
eme jota ce offline
Posts: 618
Joined: Jul 09, 2009
Location: SW Florida

Re: Google Voice SMS Plugin for Indigo 5 available now

Very useful plugin. Thanks for the contribution, Chris.

I've been using the Textie App on my iPhone because Indigo can send emails, which Textie converts to a text message that pops-up on the phone, but Google Voice would be much more convenient.

Posted on
Thu Oct 20, 2011 10:01 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Google Voice SMS Plugin for Indigo 5 available now

Good job Chris - I would make one suggestion though: creating a new device for any phone number you want to send to is quite a bit of overhead for the user - why not just collect the phone # and message in the action and just skip devices altogether? That's what the Action Collection plugin does - it just collects all the information it needs in each action so you don't have to define devices.

Just a thought.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Oct 20, 2011 10:10 am
ChrisB offline
User avatar
Posts: 41
Joined: Sep 12, 2011

Re: Google Voice SMS Plugin for Indigo 5 available now

Hi Jay,

Good point and originally I set it up that way. The reason I added devices is because I was planing to have the action update a state that contains the last message sent. From there, I would create a trigger on Fail that would send the text message to a backup e-mail defined in the device setup.

Chris

Posted on
Thu Oct 20, 2011 11:25 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Google Voice SMS Plugin for Indigo 5 available now

Interesting - didn't realize you could get failures via their API - that's pretty cool.

So, in that case, you might want to alternatively allow users to pick an Address Book entry (using the Address Book API's via pyobjc which is included with Mac OS X) - then you'd have all the #'s and addresses that were in the address book and you'd have all kinds of fallback options. I've been thinking about how to integrate Address Book information into Indigo - this seems like one idea...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Oct 20, 2011 12:49 pm
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Google Voice SMS Plugin for Indigo 5 available now

jay wrote:
Interesting - didn't realize you could get failures via their API - that's pretty cool.

So, in that case, you might want to alternatively allow users to pick an Address Book entry (using the Address Book API's via pyobjc which is included with Mac OS X) - then you'd have all the #'s and addresses that were in the address book and you'd have all kinds of fallback options. I've been thinking about how to integrate Address Book information into Indigo - this seems like one idea...


You don't need to use pyObjc directly for the Address Book.

Try:

import AddressBook

It's included with v2.5, I thought it was a Python included module, but I'm starting to suspect it's part of the pyobjc framework that is included with Python...?

But it gives full access to the address book... I'm trying to think of a good way to use it....

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Thu Oct 20, 2011 4:37 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Google Voice SMS Plugin for Indigo 5 available now

That IS using pyobjc - AddressBook is the name of the framework (/System/Library/Frameworks/AddressBook.framework) so pyobjc is importing that framwork.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Oct 20, 2011 8:29 pm
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Google Voice SMS Plugin for Indigo 5 available now

jay wrote:
That IS using pyobjc - AddressBook is the name of the framework (/System/Library/Frameworks/AddressBook.framework) so pyobjc is importing that framwork.


What confused me is that typical PyobjC code is fairly C based code... And I'm see real Python examples from the AddressBook module... But yes, as I mentioned in the previous posting, I already had that suspicion...

- Ben

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Fri Oct 21, 2011 10:39 am
ChrisB offline
User avatar
Posts: 41
Joined: Sep 12, 2011

Re: Google Voice SMS Plugin for Indigo 5 available now

jay wrote:
Interesting - didn't realize you could get failures via their API - that's pretty cool.


That would be cool but that's not the case. I was thinking more along the lines of the service being down, google making changes to the login method (again) or for some reason the login credentials were not working. For those things, the plugin looks for exceptions and changes the state accordingly. From there a trigger can be created to send an e-mail instead.

I've been thinking about how to integrate Address Book information into Indigo - this seems like one idea...


Having the address book integrated into Indigo would be nice. It would be a lot better than having each plugin developer create their own interface! :-)

Chris

Posted on
Fri Oct 21, 2011 2:27 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Google Voice SMS Plugin for Indigo 5 available now

We aren't adding it - as I implied, it's really questionable whether it's useful but to a very small subset of plugins. You'll need to do it yourself (but it isn't really that hard)...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 02, 2011 12:17 pm
ChrisB offline
User avatar
Posts: 41
Joined: Sep 12, 2011

Google Voice SMS Plugin for Indigo 5 (SIRI support added)

The Google Voice SMS Plugin has been updated to add support for receiving SMS. Please review the first message in this thread for additional information and usage instructions.

Enjoy,

Chris

Posted on
Wed Nov 02, 2011 2:08 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Google Voice SMS Plugin for Indigo 5 (SIRI support added

I like this implementation - it allows you to tightly control what commands will be executed via the SMS message - it's not like having an open-ended command interpreter. The user can easily implement only the commands that they are comfortable with exposing.

Nice job Chris!

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Nov 09, 2011 10:51 am
Chompy offline
User avatar
Posts: 84
Joined: Sep 07, 2009
Location: Seattle, WA

Re: Google Voice SMS Plugin for Indigo 5 (SIRI support added

Great plugin!

I was originally having problems with it determining whether my texts were authorized.

Code: Select all
Google Voice SMS                Time: 10:44 AM  From: Cory:  MSG: Turn on office light  *unauthorized*


It turns out that if you have contacts setup on Google Voice, the plugin sees the text as coming from the contact name instead of the phone number. Deleting the contact info from Google Voice fixes this.

Posted on
Wed Nov 09, 2011 12:30 pm
bobeast offline
User avatar
Posts: 400
Joined: Apr 16, 2003

Re: Google Voice SMS Plugin for Indigo 5 (SIRI support added

ok. I'm prolly missing something obvious here. Who do I send the text TO so that Indigo receives it? my gmail voice number? The email address I set up in Indigo settings?

Choose to chance the rapids.
Dare to dance the tide.

Posted on
Wed Nov 09, 2011 4:04 pm
Chompy offline
User avatar
Posts: 84
Joined: Sep 07, 2009
Location: Seattle, WA

Re: Google Voice SMS Plugin for Indigo 5 (SIRI support added

ok. I'm prolly missing something obvious here. Who do I send the text TO so that Indigo receives it? my gmail voice number? The email address I set up in Indigo settings?


You send it to the google voice #. Preferably one you've setup that's dedicated specifically to Indigo.

Who is online

Users browsing this forum: No registered users and 0 guests