Replacing AppleScript with Restful URLs

Posted on
Fri Nov 15, 2019 12:22 pm
Mark offline
User avatar
Posts: 201
Joined: Apr 21, 2005
Location: California

Replacing AppleScript with Restful URLs

I often control my devices from a computer using Keyboard Maestro. I find it very handy, and much faster, to have keyboard shortcuts to control various things (printers, lights, monitors, etc, all plugged into Insteon devices). I used to use AppleScript for this, but prepping for 7.4 I've replaced all my outside-Indigo AppleScripts with Restful URLs. So far so good, but I can't seem to find an example of of a Restful URL to turn on and off scenes.

I found a python example:
Code: Select all
 indigo.insteon.sendSceneOff(54, sendCleanUps=True)

Is there a Restful URL for same?

Posted on
Fri Nov 15, 2019 2:09 pm
matt (support) offline
Site Admin
User avatar
Posts: 20569
Joined: Jan 27, 2003
Location: Texas

Re: Replacing AppleScript with Restful URLs

There isn't currently a direct way to do that via a RESTful URL, but you could create Action Groups for the scenes you want to send and execute those.

Alternatively and what I would recommend, you could execute the python snipped you found using Indigo's Plugin Host command line, which I think you could call from a script inside Keyboard Maestro. If you need the full path then the indigo-host command can be found here:

/usr/local/bin/indigo-host

Image

Posted on
Fri Nov 15, 2019 5:23 pm
Mark offline
User avatar
Posts: 201
Joined: Apr 21, 2005
Location: California

Re: Replacing AppleScript with Restful URLs

Thanks for the quick reply Matt. Interesting about the command line. I may fool with that. But I've got KM executing lots of Action Groups, so I'll likely stick with that MO, since I already know how to do that. I like to eliminate "subway stops" when I can, [keys -> executing KM macros ->executing Restful URLs -> executing Action Groups -> executing scenes] is a lot of stops! It's not that it doesn't work, but I have to be mindful of being able to remember how all that strings together in a month or a year (heck, in five minutes!) should something go wrong. Less is more, in this case. I was just looking to eliminate what stops I could.

Please put a request for firing scenes with Restful URLs on the wish list.

I'm now down to just one AppleScript that I can't seem to figure out how to replace. I'll create a new post with that issue...

I'll miss AppleScript support, but to be honest, I did manage to strip it all out with less trouble than I had anticipated. I didn't really want to learn a new language, but I have to admit Python is very clean, usually much simpler/shorter than AppleScript (and, of course, less buggy). I completely overhauled my entire system (new devices, new house, new modem, new functionalities, but simpler overall) and as I was rebuilding I just didn't transfer over anything that used AppleScript. I've got the house running like I want, and did so with a lot less junk (code) than I had before...

I've complained a lot here in the past about Insteon devices and their reliability, both lifespan and sending/receiving commands, but since I eliminated all the non-RF devices (at no small expense!) I finally have a house that works as I had envisioned. I went from about 70% reliable to very close to 100%. Too soon to tell about the longevity issue... fingers crossed...

Posted on
Tue Jan 14, 2020 8:49 pm
Nidocamen offline
Posts: 32
Joined: Oct 18, 2011

Re: Replacing AppleScript with Restful URLs

Hey Matt, is the indigo-host piece relatively new? (I'm guessing no but thought I'd ask lol)

On my system, indigo-host doesn't exist at /usr/local/bin

I'm on Indigo 6.1.9 on macOS Sierra (I know, I know, gotta upgrade lol)

Thx :)

matt (support) wrote:
There isn't currently a direct way to do that via a RESTful URL, but you could create Action Groups for the scenes you want to send and execute those.

Alternatively and what I would recommend, you could execute the python snipped you found using Indigo's Plugin Host command line, which I think you could call from a script inside Keyboard Maestro. If you need the full path then the indigo-host command can be found here:

/usr/local/bin/indigo-host

Posted on
Wed Jan 15, 2020 10:46 am
jay (support) offline
Site Admin
User avatar
Posts: 16821
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Replacing AppleScript with Restful URLs

It was installed starting with Indigo 7.4.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jan 16, 2020 7:10 am
Nidocamen offline
Posts: 32
Joined: Oct 18, 2011

Re: Replacing AppleScript with Restful URLs

Ok. The Restful stuff was implemented somewhat in Indigo 6, right? I can't recall where the docs were on the syntax / URL structure.

I just need to be able to exec some action groups and update variables and need to do it from outside of Indigo but not necessarily via AppleScript.

jay (support) wrote:
It was installed starting with Indigo 7.4.

Posted on
Thu Jan 16, 2020 10:06 am
jay (support) offline
Site Admin
User avatar
Posts: 16821
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Replacing AppleScript with Restful URLs

Here's the REST API docs. Should work with Indigo 6 as well.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Jan 17, 2020 9:16 pm
Nidocamen offline
Posts: 32
Joined: Oct 18, 2011

Re: Replacing AppleScript with Restful URLs

Awesome, thanks! :)

jay (support) wrote:
Here's the REST API docs. Should work with Indigo 6 as well.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest