[SOLVED]run (php) url as action?

Posted on
Thu Jan 02, 2014 4:34 pm
reiniertc offline
Posts: 9
Joined: Jan 02, 2014

[SOLVED]run (php) url as action?

I'm switching from homeseer to indigo and have a question.
Much of my previous setup is based on running php-url's.
Wih those URL's, I control my sonos, update my mysql database etc.

Is it possible to create an action that calls an url?
(like: 192.168.8.11/scripts/control_tv.php?action=volup)

Posted on
Thu Jan 02, 2014 6:56 pm
jay (support) offline
Site Admin
User avatar
Posts: 18255
Joined: Mar 19, 2008
Location: Austin, Texas

Re: run (php) url as action?

I've never tried it, but you can try the Server Actions->Run Shell Script action - assuming that you can execute a PHP script with a shebang at the top it might work.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jan 02, 2014 8:17 pm
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: run (php) url as action?

If you are going to go through a standard web interface (like Apache) then you can use a script action and execute a curl system command to fetch/execute the page via URL. Of course, in the long run, converting any devices and controls you have to an Indigo plugin (when available) will give you far better response time / performance.

Adam

Posted on
Fri Jan 03, 2014 2:17 am
reiniertc offline
Posts: 9
Joined: Jan 02, 2014

Re: run (php) url as action?

Thanks for the quick replies.
I'm not sure if converting everything to plugins is my best solution, because my ultimate setup will look something like this:
- mac mini with indigo to control my zwave devices and run timed events
- non-zwve devices (mobotix cam, sonos, some data fetching from web pages etc) will be controlled via php
- additional functions (my online administration, gps tracking of cell phones) via php
- a custom html interface based on twitter bootstrap

So I will allways be needing php. I'm gonna try the "shell command" option, So my first thing to do is to rtfm and find out how to pass variables and values to a shell command string :-)

(so far I like what I'm seeing)

Posted on
Fri Jan 03, 2014 8:34 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: run (php) url as action?

I'm not sure if you are going to want to use AppleScript or Python, but the basic premise is pretty easy - you will grab the values of variables and/or device states (or whatever else you are using to build it) into variables and use it to build the URL to pass to curl in a system call.

The How-To Wiki has a couple of scripting guide pages that may be helpful, depending upon which language you decide to use. Once you can get the info you need, do a search for "curl" on the forums -- I'm not sure which post would be most relevant but I know others have used that technique to interface with devices such as cameras. And most of those members check the forum and can give some advice if you get stuck!

Posted on
Fri Jan 03, 2014 9:57 am
jay (support) offline
Site Admin
User avatar
Posts: 18255
Joined: Mar 19, 2008
Location: Austin, Texas

Re: run (php) url as action?

Run Shell Script doesn't currently allow you to specify dynamic parameters. I'd say you want to use Python because It can open the URLs (using the various built-in network API libraries) directly rather than using curl and starting yet another process.

Have you looked through the list of third party plugins? It seems like some of the things that you're looking to do already have plug-ins that might save you some time - like the Sonos plugin and potentially the smartphone radar or the find my iPhone plugins for geolocation.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Jan 03, 2014 1:59 pm
jay (support) offline
Site Admin
User avatar
Posts: 18255
Joined: Mar 19, 2008
Location: Austin, Texas

Re: run (php) url as action?

The next release will include the ability to pass parameters to the shell script and it'll include the standard device state and variable value substitution capabilities - so you can pass state and var values to the script at runtime. I tested with both a standard shell script and a PHP script and they seem to work fine.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest