|
Page 1 of 1
|
[ 10 posts ] |
|
Remotely get variable value and execute a command
| Author |
Message |
|
defsquad
Joined: Nov 13, 2011 Posts: 7
|
 Remotely get variable value and execute a command
Hi there,
Just starting to toy around with Indigo's RESTful API, and some basic scripting with Applescript right now (would like to do more Ruby scripting instead). Anyway, I'm also playing around with the following:
Both of these are on the same wired gigabit network: HTPC -- running Indigo Office PC -- running Proximity.app
When I walk into the office, Proximity.app recognizes my iPhone as being near, and fires off an Applescript, that right now is simply firing a curl command to Indigo to turn on the lamplinc in the office. Now, this is great, and works flawlessly, however, I'd like to get the isDaylight variable's current variable back and if it's false (e.g. it's dark outside), turn on the lamplinc, otherwise, leave the lamplinc off.
I did some searching it looks like there isn't a way to readily get the value back, other than visiting the variable's page (looking at the Indigo RESTful API docs); I'm thinking I could just use Ruby to screen scrape the value I need and return that back to my apple script to then determine whether or not to t urn on the lamp when I walk in the office with my iPhone.
Is this my only option, or are there other cleaner options for remotely getting variable values?
Thanks! I can't wait to start trying to integrate arduinos, rfid, supermechanical's twine (supermechanical.com), a pebble watch (getpebble.com), and HOPEFULLY a couple LEAP's (leapmotion.com) into the mix!
|
| Fri May 25, 2012 8:16 pm |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11689 Location: Texas
|
 Re: Remotely get variable value and execute a command
You can get access to the Variable's attributes either in text form: http://127.0.0.1:8176/variables/isDaylight.txtOr as XML: http://127.0.0.1:8176/variables/isDaylight.xmlAnother option would be to have the AppleScript remotely target your Indigo Mac. That can be a bit buggy though -- I've seen problems with it if the OS X versions running on each Mac aren't the same. I think it was just a major version difference, like OS X 10.5 not working well with 10.6.
_________________
|
| Sat May 26, 2012 10:35 am |
|
 |
|
defsquad
Joined: Nov 13, 2011 Posts: 7
|
 Re: Remotely get variable value and execute a command
thanks matt, do you recommend one way over another for remotely getting the value from that returned text (e.g. applescript, ruby, python, perl, php, good ole shell scripting, other)? i tried it with ruby, but am having a heck of a time because of the digest authorization; finding the right ruby gem combination for authorizing remotely to the indigo web server to get that variable.txt has been a pain. here's where i ran into issues using ruby (granted, not directly related to indigo, but related to digest authorization).. http://stackoverflow.com/questions/1077 ... igest-auththe crazy thing is, i can use curl just fine to set the device on/off states, with that --digest flag. anyway, thanks for any help you can provide!
|
| Sat May 26, 2012 10:06 pm |
|
 |
|
defsquad
Joined: Nov 13, 2011 Posts: 7
|
 Re: Remotely get variable value and execute a command
any additional thoughts on this one matt? do you have any personal recommendations for coding the GET of the variable html file and parsing it? thanks much.
|
| Sun May 27, 2012 8:37 pm |
|
 |
|
defsquad
Joined: Nov 13, 2011 Posts: 7
|
 Re: Remotely get variable value and execute a command
managed to get it working; landed on the httpclient ruby gem; much easier to integrate working digest auth compared to the other gem i was using.
the next issue is getting my applescript to run the ruby file... which it does, however the problem is that for some reason my rubygem environment won't see the fact that i've installed the gems i need globally. *sigh*
oh well, that's not an indigo issue, just updating this post. if anyone needs the updated ruby code, it's available at the SO link i originally posted above.
|
| Mon May 28, 2012 3:49 pm |
|
 |
|
defsquad
Joined: Nov 13, 2011 Posts: 7
|
 Re: Remotely get variable value and execute a command
.... and with some stupid applescript trickery; here it is all running via the app "Proximity" and it's ability to only fire off applescripts.. - Code: Select all
do shell script "~/.rvm/bin/ruby /scripts/bt_office_proximity-near.rb"
i hope this helps others to use ruby and applescript controlling a remote indigo server with a bluetooth proximity app on your local desktop. 
Last edited by defsquad on Tue May 29, 2012 9:14 pm, edited 1 time in total.
|
| Mon May 28, 2012 4:33 pm |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11689 Location: Texas
|
 Re: Remotely get variable value and execute a command
I might not be understanding the problem requirements fully, but note that you can use the RESTful APIs to execute an Action Group as well. So you could have it just execute an Action Group which then contains the AppleScript (or better yet, python) embedded script that actually has the logic you want.
_________________
|
| Mon May 28, 2012 7:55 pm |
|
 |
|
defsquad
Joined: Nov 13, 2011 Posts: 7
|
 Re: Remotely get variable value and execute a command
Good morning Matt,
Thanks for the response. Yeah, I may not have painted the whole picture of what I was after. The problem is that the bluetooth proximity application I'm using on my office computer can only launch applescripts, however I couldn't seem to get the isDaylight variable via an applescript, only from parsing it via a ruby script. So basically I'm executing the ruby script via terminal via an applescript. *whew*
Very convoluted way to do what I'm wanting to do. I'll definitely investigate action pages (I'm only scratching the surface of what Indigo offers, as I'm slowly building out my home automation setup).
I definitely appreciate the active interaction and support with the community; i also appreciate the fact that other apps and devices can interact with Indigo, not just supported Insteon and x10 devices.
Regards.
|
| Tue May 29, 2012 7:14 am |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6651 Location: Austin, Texas
|
 Re: Remotely get variable value and execute a command
- Code: Select all
tell application "IndigoServer" set varValue to value of variable "isDaylight" end tell
If your Indigo server is on a remote machine: - Code: Select all
tell application "IndigoServer" of machine "eppc://USERNAME:PASSWORD@IPADDRESS" set varValue to value of variable "isDaylight" end tell
_________________ Jay (Indigo Support)
|
| Tue May 29, 2012 8:32 am |
|
 |
|
defsquad
Joined: Nov 13, 2011 Posts: 7
|
 Re: Remotely get variable value and execute a command
bwahaha, that's easy enough. *sigh* oh well, was still fun hacking around with applescript + ruby to make it happen 
|
| Tue May 29, 2012 9:13 pm |
|
|
|
Page 1 of 1
|
[ 10 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|