Send Control command from Applescript

Posted on
Thu Apr 10, 2014 5:34 pm
Benwin offline
Posts: 8
Joined: Jan 21, 2013

Send Control command from Applescript

I have just started playing with Xcode using the Cocoa Applescript environment.

I have recently built a menu bar based app that gives me control of multiple apps and functions on my computer.
I was toying with the idea of adding some frequently used indigo commands, the computer running the app is not the same one running indigo server so I usually open the indigo web control page to send commands, is there a way of sending the commands from my menu bar app instead, maybe using a

Code: Select all
do shell script "curl -L " & "http://indigo.server.computer.:8176/commands/turn.light.on/etc/etc"
Code: Select all


or something similar

thanks

Ben

Posted on
Fri Apr 11, 2014 11:02 am
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Send Control command from Applescript

Check out the RESTful API.

[MODERATOR NOTE] Moved to the AppleScript forum since it's specifically a question about AppleScript.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Apr 11, 2014 2:09 pm
Benwin offline
Posts: 8
Joined: Jan 21, 2013

Re: Send Control command from Applescript

Thanks Jay

I checked out the RESTful API and came up with this

Code: Select all
do shell script " curl -u username:password -L http://10.0.1.18:8176/devices/kitchen?isOn=0&_method=put"


For some reason the indigo log is stating access denied! Am I not sending the username and password correctly?

B

Posted on
Fri Apr 11, 2014 2:53 pm
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Send Control command from Applescript

I believe you also need --digest to specify digest authentication.

Code: Select all
do shell script " curl -u username:password --digest -L http://10.0.1.18:8176/devices/kitchen?isOn=0&_method=put"

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Apr 11, 2014 3:12 pm
Benwin offline
Posts: 8
Joined: Jan 21, 2013

Re: Send Control command from Applescript

Hmm now the log is telling me it could not find device "Kitchen"

I know its there I just made a sandwich :wink:

I tried using the device ID and it still states it can't find it

Posted on
Sat Apr 12, 2014 7:21 am
jay (support) offline
Site Admin
User avatar
Posts: 18221
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Send Control command from Applescript

The RESTful API doesn't use device IDs so you have to use the name. And they are case-sensitive.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Apr 12, 2014 10:13 am
Benwin offline
Posts: 8
Joined: Jan 21, 2013

Re: Send Control command from Applescript

Marvalous, works like a charm, thank you very much.

B :D

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 21 guests