Google Voice SMS Plugin

Posted on
Sat Jan 07, 2012 10:58 pm
dmeeker@mac.com offline
Posts: 85
Joined: Aug 26, 2011

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

Understood. You are only prompted to enter a phone number two times in the plugin.

1) When you set up the device with your google voice account.

2) When you make a trigger to send a message and you type which number to send the SMS to.

Here is how I have them configured:

The Device:
- Is my Google Voice Number. I created a google voice account JUST for Indigo. This Google voice account only has 1 phone attached to it: my home phone. I only use this account for Indigo.

The Trigger
- Is my my PERSONAL Google voice number. This is a different Google voice number than what Indigo is set up to use. When Indigo sends the message to this number, it goes to my cell phone(s).


I believe that if you are using the same phone to receive messages that is connected to your Google Voice account, there may be issues.


Dave

Posted on
Tue Jan 17, 2012 10:21 pm
kidney offline
Posts: 237
Joined: Jul 15, 2007

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

Does anyone have the version that support variables?

Posted on
Fri Jan 20, 2012 1:34 pm
dmeeker@mac.com offline
Posts: 85
Joined: Aug 26, 2011

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

I would be very interested in the variable-ready version also. The documentation mentions variable substitution options, but they clearly don't work in the version available for download.

Posted on
Sun Feb 05, 2012 7:39 pm
taankro offline
Posts: 5
Joined: Jan 28, 2012

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

You can add the variable substitution by modifying the /Library/Application Support/Perceptive Automation/Indigo 5/Plugins/GoogleVoiceSMS.indigoPlugin/Contents/Server Plugin/plugin.py.
Add the bold text to your file.
import re
for match in re.findall(r'%%v:([0-9]+)%%', smsMessage):
smsMessage = smsMessage.replace('%%v:' + match + '%%', indigo.variables[int(match)].value)

Code: Select all
       
def sendSMSMessage (self, action):
                smsDevice = indigo.devices[action.deviceId]
                smsNumber = smsDevice.pluginProps['address']
                smsMessage = action.props["smsMessage"]
                import re
                for match in re.findall(r'%%v:([0-9]+)%%', smsMessage):
                        smsMessage = smsMessage.replace('%%v:' + match + '%%', indigo.variables[int(match)].value)

                try:
                        indigo.server.log("Sending '"+smsMessage+"' to "+smsNumber)
                        smsDevice.updateStateOnServer(key="lastAction", value="Sending")
                        self.voice.send_sms(smsNumber, smsMessage)
                        smsDevice.updateStateOnServer(key="lastAction", value="Success")
                        indigo.server.log("Message sent successfully.")

                except:
                        smsDevice.updateStateOnServer(key="lastAction", value="Error")
                        indigo.server.log("Unable to send message.")


Save the file the click Plugins -> Google Voice SMS -> Reload

Posted on
Sun Feb 05, 2012 8:29 pm
dmeeker@mac.com offline
Posts: 85
Joined: Aug 26, 2011

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

Wow. Awesome.
I will give it a shot.
Thank you!

Posted on
Mon Feb 06, 2012 2:11 pm
jay (support) offline
Site Admin
User avatar
Posts: 18201
Joined: Mar 19, 2008
Location: Austin, Texas

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

Or you can edit it to call the substituteVariable() method described in the plugin.py section of the API docs (it's the last row of the last table)... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Feb 07, 2012 11:37 am
dmeeker@mac.com offline
Posts: 85
Joined: Aug 26, 2011

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

I added the codeblock to the plugin.py script, but alas, the variables are not coming through.

I have a trigger that responds to an incoming SMS. The incoming SMS is "security status".

The response sent back to my device is setup to be:

The front door is %%v:FrontDoorIs%%. The garage door is %%v:The_Garage_Door_Is%%.

Unfortunately, I end up getting that sent back to my phone verbatim, without the variable substitution.

I unloaded and reloaded the plugin. That didn't work.
I restarted indigo. That didn't work either.

Scratching my head....

Any thoughts?

My code looks like:

Code: Select all

    ########################################
    # Routines for Sending SMS
    ########################################

   def sendSMSMessage (self, action):
      smsDevice = indigo.devices[action.deviceId]
      smsNumber = smsDevice.pluginProps['address']
      smsMessage = action.props["smsMessage"]
      
                import re
                for match in re.findall(r'%%v:([0-9]+)%%', smsMessage):
                smsMessage = smsMessage.replace('%%v:' + match + '%%', indigo.variables[int(match)].value)

      try:
         indigo.server.log("Sending '"+smsMessage+"' to "+smsNumber)
         smsDevice.updateStateOnServer(key="lastAction", value="Sending")   
         self.voice.send_sms(smsNumber, smsMessage)
         smsDevice.updateStateOnServer(key="lastAction", value="Success")
         indigo.server.log("Message sent successfully.")   

      except:
         smsDevice.updateStateOnServer(key="lastAction", value="Error")
         indigo.server.log("Unable to send message.")
   

Posted on
Tue Feb 07, 2012 12:41 pm
taankro offline
Posts: 5
Joined: Jan 28, 2012

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

Sorry for the confusion. The code will do a variable substitution on the variable id not the variable name. Should be a number...

Posted on
Tue Feb 07, 2012 1:08 pm
dmeeker@mac.com offline
Posts: 85
Joined: Aug 26, 2011

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

Ok, So I replaced the variable names I posted before with the VariableID. I assume this is what ID we are dealing with?

I replaced what I had with the following:

The front door is %%v:1965161463%%. The garage door is %%v:214150226%%.


And I get that same exact (unprocessed) string sent via SMS.

Posted on
Tue Feb 07, 2012 7:23 pm
taankro offline
Posts: 5
Joined: Jan 28, 2012

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

I sent you an email. But you should check your log after you reload the module. Not sure if your code looks exactly like you posted but if it does you have indented the 3 lines you added one to many times. I suspect your log looks like this when you reload the module if that is the case:

Google Voice SMS Error Error in plugin execution InitializeMain:

Traceback (most recent call last):
<type 'exceptions.IndentationError'>: ('unexpected indent', ('plugin.py', 73, 3, '\t\t\timport re\n'))

Error plugin "Google Voice SMS 1.1.0" failed to initialize

Posted on
Tue Feb 07, 2012 7:53 pm
dmeeker@mac.com offline
Posts: 85
Joined: Aug 26, 2011

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

I emailed you back also, but for others, thought I'd also post here.

My actual code looks like this:

Code: Select all
   def sendSMSMessage (self, action):
      smsDevice = indigo.devices[action.deviceId]
      smsNumber = smsDevice.pluginProps['address']
      smsMessage = action.props["smsMessage"]
      import re
        for match in re.findall(r'%%v:([0-9]+)%%', smsMessage):
           smsMessage = smsMessage.replace('%%v:' + match + '%%', indigo.variables[int(match)].value)




I am not getting the indent error.

Instead, I am getting a variable undefined for "re":



Google Voice SMS Error Error in plugin execution InitializeMain:

Traceback (most recent call last):
File "plugin.py", line 25, in <module>
File "plugin.py", line 74, in Plugin
<type 'exceptions.NameError'>: name 're' is not defined

Error plugin "Google Voice SMS 1.1.0" failed to initialize

Posted on
Tue Feb 07, 2012 8:58 pm
taankro offline
Posts: 5
Joined: Jan 28, 2012

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

Changed to the substituteVariable() method that Jay referenced from above. Do this instead of the three lines from my earlier posts.
Code: Select all
if self.substituteVariable(smsMessage, validateOnly=True):
  smsMessage = self.substituteVariable(smsMessage)

Posted on
Wed Feb 08, 2012 10:25 am
jay (support) offline
Site Admin
User avatar
Posts: 18201
Joined: Mar 19, 2008
Location: Austin, Texas

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

You only need to call it with validation if you want to do something if there is a validation error - so in your case you can just cal the substitute without validation. It will return a string regardless of any errors.

Also, the return value when validateOnly is True is a tuple - the first item being a boolean and the second (if present) an error string. So you should test the first item in the tuple for true/false.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Feb 08, 2012 5:05 pm
taankro offline
Posts: 5
Joined: Jan 28, 2012

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

Ok. So I modified mine so that the sms will not be sent if a variable does not exist.
Code: Select all

    ########################################
    # Routines for Sending SMS
    ########################################

   def sendSMSMessage (self, action):
      smsDevice = indigo.devices[action.deviceId]
      smsNumber = smsDevice.pluginProps['address']
      smsMessage = action.props["smsMessage"]
      substituteVariable = self.substituteVariable(smsMessage, validateOnly=True)
      if not substituteVariable[0]:
         indigo.server.log(substituteVariable[1])
         return
      smsMessage = self.substituteVariable(smsMessage)
     
      try:
         indigo.server.log("Sending '"+smsMessage+"' to "+smsNumber)
         smsDevice.updateStateOnServer(key="lastAction", value="Sending")   
         self.voice.send_sms(smsNumber, smsMessage)
         smsDevice.updateStateOnServer(key="lastAction", value="Success")
         indigo.server.log("Message sent successfully.")   

      except:
         smsDevice.updateStateOnServer(key="lastAction", value="Error")
         indigo.server.log("Unable to send message.")
 

or if you don't mind sending the message with no value substituted you could:
Code: Select all
 ########################################
    # Routines for Sending SMS
    ########################################

   def sendSMSMessage (self, action):
      smsDevice = indigo.devices[action.deviceId]
      smsNumber = smsDevice.pluginProps['address']
      smsMessage = self.substituteVariable(action.props["smsMessage"])

      try:
         indigo.server.log("Sending '"+smsMessage+"' to "+smsNumber)
         smsDevice.updateStateOnServer(key="lastAction", value="Sending")   
         self.voice.send_sms(smsNumber, smsMessage)
         smsDevice.updateStateOnServer(key="lastAction", value="Success")
         indigo.server.log("Message sent successfully.")   

      except:
         smsDevice.updateStateOnServer(key="lastAction", value="Error")
         indigo.server.log("Unable to send message.")


Again sorry for the confusion.

Posted on
Thu Feb 09, 2012 1:49 pm
eme jota ce offline
Posts: 618
Joined: Jul 09, 2009
Location: SW Florida

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

dmeeker@mac.com wrote:
...

2) When you make a trigger to send a message and you type which number to send the SMS to.



Feel pretty foolish asking, but where?

No matter how many times I add a new trigger, I don't see a place where I type another number to send the SMS to...I had to add a second SMS plugin device with the number to which I want to send.
Last edited by eme jota ce on Thu Feb 09, 2012 4:40 pm, edited 1 time in total.

Page 4 of 21 1, 2, 3, 4, 5, 6, 7 ... 21

Who is online

Users browsing this forum: No registered users and 1 guest