Indigo RESTful API / URL Examples

Posted on
Mon Jun 16, 2014 11:11 am
mark_anderson_us offline
Posts: 65
Joined: Jun 05, 2014

[SOLVED] Re: Indigo RESTful API / URL Examples

jay (support) wrote:
I'd caution anyone about building an IWS plugin - as we've stated before, we're going to be converting the web server to use the IOM to access the server (a la Server Plugins) rather than it's current built-in method. Those old communication methods will be deprecated so any existing IWS plugins will need to be rewritten, at least in terms of data access and communication with the Indigo Server process.



Thanks for the heads up. Definitely don;t want to start with something that will be deprecated soon
Last edited by mark_anderson_us on Mon Jun 16, 2014 3:00 pm, edited 1 time in total.

Posted on
Mon Jun 16, 2014 11:43 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Indigo RESTful API / URL Examples

Thanks for the heads up. Definitely don;t want to start with something that will be deprecated soon

Mark, I should mentioned the down-the-road plans for changing out the IWS structure, but I still felt it may be a valid option for you for two primary reasons: first off you are talking maybe an hour to spin up a plugin that does nothing but run a template, so throwing it away at a future date and rewriting is not a huge loss; secondly, "soon" is a very relative term in the scope of technology.

I would agree that it would be prudent not to invest time into a complicated, time-consuming IWS plugin.

Adam

Posted on
Mon Jun 16, 2014 1:30 pm
mark_anderson_us offline
Posts: 65
Joined: Jun 05, 2014

Re: Indigo RESTful API / URL Examples

I just did some more research and it seems all that's required is to add a response header somewhere in the CherryPy config (or app). Here's an example of one that supposed to work: https://gist.github.com/enjalot/2904124

and another example: http://pythonhosted.org/jasy/_modules/j ... erver.html

Anyone know how to add custom response headers in CherryPy

Posted on
Mon Jun 16, 2014 2:54 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Indigo RESTful API / URL Examples

mark_anderson_us wrote:
From what I understand the response needs to contain an Access-Control-Allow-Origin: header

Try shutting down the Indigo Server (not just quitting the client), the modifying this file:

/Library/Application Support/Perceptive Automation/Indigo 6/IndigoWebServer/indigopy/indigoutil.py

by adding a line to this:

Code: Select all
def ModHttpServerName():
   cherrypy.response.headers['Server'] = 'IndigoWebServer/5.0'

so that it becomes:

Code: Select all
def ModHttpServerName():
   cherrypy.response.headers['Server'] = 'IndigoWebServer/5.0'
   cherrypy.response.headers['Access-Control-Allow-Origin'] = '*'

Then restart the Indigo Server.

Image

Posted on
Mon Jun 16, 2014 3:00 pm
mark_anderson_us offline
Posts: 65
Joined: Jun 05, 2014

Re: Indigo RESTful API / URL Examples

Thanks Matt!

Worked great. Now I'm in business

Regards

Mark

Posted on
Mon Jun 16, 2014 8:48 pm
mark_anderson_us offline
Posts: 65
Joined: Jun 05, 2014

Re: Indigo RESTful API / URL Examples

So, I got some basic stuff working with devices using Angular.

I created the following Angular "objects"
  • DeviceService (factory pattern) - Gets a list of devices or a named devices detailsMain controller
  • Main layout - has header, footer, etc, and "slots in" content based on which route (controller) is chosen
  • Main Controller - specifies routes (controller and templates)
  • DeviceListController - Gets list of devices using DeviceService
  • DeviceController - Gets device details when clicking a device, using DeviceService

Things are looking good.

Regards

Mark

Posted on
Tue Jan 06, 2015 2:34 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Indigo RESTful API / URL Examples

I hope this is not to off topic. But I have a question with setting variables through a http request.
I am using this for setting a variable from another controller:

http://MYIP:8176/variables/MYVARIABLE?_ ... t&value=TV

To me it seams like this is accessible without any authentication. Is this a calculated risk or am I missing something?
Maybe I am being paranoid, but if someone changes the "right" variable in my system they can make a lot of things happen...
I understand that the outsider would need to know the variable name, so it is a long shot...


Håvard

Håvard

Posted on
Tue Jan 06, 2015 10:40 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo RESTful API / URL Examples

It should fail if you have authentication turned on. If you're testing in a browser it's likely that the browser is caching previous authentication information for you.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jan 06, 2015 11:24 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Indigo RESTful API / URL Examples

Thank you for your feedback Jay.
I had toggled the authentication so I assume it had something to do with this. It is not working anymore now anyway...
But if I want to set a variable in Indigo from Vera in my case. What would be the best way? I assumed that setting it by running a http request from the vera was the easiest.
Any suggestions?

The reason I want to do this is to update Indigo when an activity is changed on the harmony app on vera (The vera has a very nice harmony plugin).

Håvard

Håvard

Posted on
Tue Jan 06, 2015 11:38 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo RESTful API / URL Examples

Can the Vera not handle doing digest authentication? I don't know anything about their scripting environment, but it seems like it would be able to perform an http request using digest authentication since that's one of the built-in authentication methods in http...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jan 07, 2015 4:53 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: Indigo RESTful API / URL Examples

I think only basic authentication is available in ui5. I don't use my Vera much these days, so I am not up to date... But as I understand you a http request is my best try? I have posted on the Vera forum to see if it is possible to do digest authentication.

Håvard

Håvard

Posted on
Wed Jan 07, 2015 6:32 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo RESTful API / URL Examples

Yep, that would definitely be the most straight-forward way.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Jan 10, 2015 3:02 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Indigo RESTful API / URL Examples

I don't use Vera, but having tried various approaches for setting/calling things from outside of Indigo I settled on a Python script which I can call in many ways from my Windows PC - task scheduler, desktop shortcut or (the way I mostly use it) keyboard shortcut via some hotkey software I've used for years.

Posted on
Mon Mar 16, 2015 5:13 pm
pegoto offline
Posts: 27
Joined: Jul 21, 2011

Re: Indigo RESTful API / URL Examples

jay (support) wrote:
It should fail if you have authentication turned on. If you're testing in a browser it's likely that the browser is caching previous authentication information for you.


How can you authenticate when using the restful url?

I purchased some of these tags (http://wirelesstag.net/index.html) and they work well and they can call a URL. I have the URL right when I manually hit it in a browser where I can authenticate, but the tag cannot do it because it lacks authentication.

The URL i am using is similar to this:

http://127.0.0.1:8176/actions/party%20s ... od=execute
and I did try the below but it would not work at all
http://username:password@127.0.0.1:8176 ... od=execute

Posted on
Mon Mar 16, 2015 7:39 pm
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Indigo RESTful API / URL Examples

How can you authenticate when using the restful url?

The RESTful service uses standard web authentication routines, so it is completely up to the client to provide the authentication information... the URL format that you specified (http://username:password@xyz.com) is a fairly standard convention, but it must be implemented by the client -- in this case your tag's software.

I would suggest that you contact the tag maker's support and inquire about accessing password-protected web services (ideally using digest authentication, though you could turn on basic if necessary).

Adam

Who is online

Users browsing this forum: No registered users and 2 guests