Tuesday 26 March 2013

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


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


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

Upgrade existing installation

1. Download the plugin from here
2. Unzip it and replace the previous GoogleVoiceSMS.indigoPlugin with the updated version (located in /Library/Application Support/Perceptive Automation/Indigo 5/Plugins/ folder)
3. Reload the plugin
4. Edit Device Settings for each SMS device previously created. No changes are necessary, just click SAVE and then OK. This causes Indigo to add the new state (receivedText) to each device.

New installation
1. Download the plugin from here
2. Unzip it and copy the GoogleVoiceSMS.indigoPlugin file to your /Library/Application Support/Perceptive Automation/Indigo 5/Plugins (Disabled)/ folder.
3. Restart the Indigo server.
4. Pull down the Plugins menu, select Google Voice SMS, then Enable.
5. The plugin's config screen should pop up.

Attachment:
Plugin config screen.png
Plugin config screen.png [ 50.52 KiB | Viewed 5061 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).

Attachment:
Create new SMS Device.png
Create new SMS Device.png [ 54.48 KiB | Viewed 5061 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.

Attachment:
Edit SMS device number.png
Edit SMS device number.png [ 28.36 KiB | Viewed 5061 times ] 


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

Attachment:
Create SMS Action.png
Create SMS Action.png [ 70.49 KiB | Viewed 5061 times ] 

Attachment:
Action SMS message to send.png
Action SMS message to send.png [ 31.96 KiB | Viewed 5061 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.

Attachment:
Trigger Defined.png
Trigger Defined.png [ 50.2 KiB | Viewed 4875 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.

Attachment:
Trigger Action 1.png
Trigger Action 1.png [ 54.8 KiB | Viewed 4875 times ] 


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

Attachment:
Trigger Action 2.png
Trigger Action 2.png [ 64.54 KiB | Viewed 4875 times ] 

Attachment:
Trigger Action 2 - Edit Device.png
Trigger Action 2 - Edit Device.png [ 32.24 KiB | Viewed 4861 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:

Attachment:
iPhone Screen.PNG
iPhone Screen.PNG [ 101.62 KiB | Viewed 4860 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. SeeVariable 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.

1 comment: