Access to incoming text?

Posted on
Mon Nov 25, 2019 1:39 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Access to incoming text?

I'd like to do the following:

1) Have python script run to launch and manipulate a web page in chrome
2) Have the python script ask me for input at some point in the execution by sending me an iMessage (Example: "What is the city you're in?")
3) Have the script use my iMessage response as the input to continue the execution (Example: "Baltimore, MD")

I have this working using the raw_input() function in Python 2.7 but would prefer to use iMessage plugin so I don't have to physically be in front of my console when it runs.

If it helps, here's how I'm using raw_input():
Code: Select all
code = raw_input("What is the secret password: ")
rsa_box = driver.find_element_by_id("input_secret")
rsa_box.send_keys(code)
submit_ = driver.find_element_by_id("btn_verify")
submit_.click()
time.sleep(10)
submit_ = driver.find_element_by_id("btn_remember_device_continue")
submit_.click()
time.sleep(20)

Posted on
Mon Nov 25, 2019 2:00 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Access to incoming text?

I did some reading on the python scripting side and here's what I'm going to try. Please let me know if you think there is a better way, or if there's an easy way for you to update the plugin to capture responses in scripts?

1) Run my script until I need to ask a user
2) Send user a question using the iMessage plugin
3) The user sends the secret code in response to the question
4) Upon confirmation, take the last message that was sent to iMessage (on Indigoserver) and populate a variable
5) Continue my script and read the value from an indigo variable to enter into the website using selenium

If #4 is already done by the plugin, I'm guessing I just need the confirmation to continue the script somehow which raw_input() does natively.

Posted on
Mon Nov 25, 2019 2:10 pm
GlennNZ offline
User avatar
Posts: 1562
Joined: Dec 07, 2014
Location: Central Coast, Australia

Access to incoming text?

Hi

You could ask a question - but pretty sure just waits for a yes or no - eg - no one is home these lights are on.. do you want to turn them off. Plugin waits for yes/yep etc before runs action group.

iMessage is locked down to only the phones you allow.

So really could send a message / or have a button that says request confirmation - which sends message.

& then
Simply trigger on the password received
Eg.
Message received from buddy ‘Baltimore MD’ change variable to unlocked.
Then could change back whenever suit/certain time etc.

Technically don’t need the question, just indigo receiving password is enough to unlock.

Glenn


Sent from my iPad using Tapatalk

Posted on
Tue Nov 26, 2019 8:52 am
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Access to incoming text?

My current solution sends an iMessage to the user and tells them they have 90 seconds to update a variable. It requires the timing is perfect so it's not ideal.

2 questions:

1) What is the python snippet to send an iMessage. I only see the one that asks a question in your Read.me
2) Is there any other way to enter data into Indigo other than updating a variable?

Asynchronous iMessage integration would be a great update to the plugin.

Posted on
Tue Dec 17, 2019 1:04 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Access to incoming text?

What is the python snippet to send an iMessage without a prompt? I only see the one that asks a question in your Read.me

Posted on
Wed Dec 18, 2019 6:53 pm
GlennNZ offline
User avatar
Posts: 1562
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: Access to incoming text?

Hi
Code: Select all
import datetime
now = datetime.datetime.now()
 # dd/mm/YY H:M:S
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
# and add togther the message you want to send
messagevariable = dt_string + " was the time this was sent"
imessageID = 'com.GlennNZ.indigoplugin.iMessage'
imsgPlugin = indigo.server.getPlugin(imessageID)
imsgPlugin.executeAction('sendMessage', props={'message':messagevariable, 'buddyId':'me@glennhawken.com'})


Like above - sorry can't test this currently, so maybe some formatting errors (I do a lot of C# stuff, so sometimes my syntax is in the wrong language!) But think this will be okay.

Not sure what you mean by - Asynchronous iMessage integration - likely not possible within my understanding of word given query of database that occurs.

Glenn
Last edited by GlennNZ on Sat Dec 21, 2019 12:58 am, edited 1 time in total.

Posted on
Thu Dec 19, 2019 10:03 am
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Access to incoming text?

Thanks Glenn. I modified slightly to now = datetime.datetime.now() to get it to run and added my own email address as the BuddyId

Looks like it timed out in 10 seconds.


Code: Select all
Dec 19, 2019 at 11:00:44 AM
   Action Group                    Send Python Test iMessage
   Embedded script executor host1 started
   Error                           because embedded scripts execute sequentially they must complete their execution within 10 seconds.
   Error                           modify the script to exit quickly or convert it to an external file (not embedded).
   Stopping embedded script executor host1 (pid 19706)
   Error                           process (pid 19706) failed to quit after polite request -- forcing it to quit now
   Stopped "embedded script executor host1"

Posted on
Sat Dec 21, 2019 12:59 am
GlennNZ offline
User avatar
Posts: 1562
Joined: Dec 07, 2014
Location: Central Coast, Australia

Re: Access to incoming text?

Sorry - had some time to check

See above - as have edited.

Or this works

Code: Select all
import datetime
now = datetime.datetime.now()
 # dd/mm/YY H:M:S
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
# and add togther the message you want to send
messagevariable = dt_string + " was the time this was sent"
imessageID = 'com.GlennNZ.indigoplugin.iMessage'
imsgPlugin = indigo.server.getPlugin(imessageID)
imsgPlugin.executeAction('sendMessage', props={'message':messagevariable, 'buddyId':'emailaddress@myemail.com'})

Who is online

Users browsing this forum: No registered users and 5 guests

cron