Indigo v2.0 FAQ - All Things Web Related

Posted on
Thu Dec 07, 2006 2:11 pm
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

Indigo v2.0 FAQ - All Things Web Related

(note: edited by support to fill in some details)

I figured this might be a good place to share 'all things discovered' about the new web functionality built into Indigo v2.0.

The web server is based on the Python CherryPy project, with modifications to the http digest authentication code. All Python source files are included in the Web Server home directory: /Library/Application Support/Perceptive Automation/Indigo 2/IndigoWebServer.

The web server HTML pages are rendered using the Python Cheetah an open source template engine and code generation tool. All Cheetah template files are in IndigoWebServer/templates.

Various Javascript libraries are also used to help provide real time updates of Control Page elements and for rendering of some HTML controls and dialogs.

Dave
Last edited by DaveGee on Thu Dec 07, 2006 4:27 pm, edited 3 times in total.

Posted on
Thu Dec 07, 2006 2:38 pm
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

(No subject)

Continued:

Making Changes:
------------------------

1 - DON'T DO THIS
2 - REALLY DON'T DO THIS
3 - STUBBORN EH?
4 - OKAY DON'T SAY YOU WEREN'T WARNED

First things first BACKUP - BACKUP - BACKUP I can't stress this enough and once again WARNING do this AT YOUR OWN PERIL. Really, it's not for the faint of heart at bare minimum you should have a 'more than comfortable' working knowledge of unix AND scripting languages. Now, if you plan on getting anywhere with modifying or adding to the Indigo python web code you'll need Python + Cheetah + CherryPy *AND* OOP experience or a REAL sense of adventure (and humor).

With basic html/css skills, you can add your own or change the existing CSS (web page style definitions) by adding/changing files in the css/ directory (located under/in the web home directory specified above)

With basic html/css skills (plus scripting knowledge) you should be able to modify the various templates that when combined together (done by Indigos Python web app) make up the various pages you see in the web interface. Those pages are located in the templates/ directory (again under web-home) - Also note that those HTML templates are NOT always PURE HTML. Much of the time they also contain 'markers' that the Indigo Python Web Server App uses to know where to put things that are generated 'on the fly' things like the light and fan icons (etc) and their current status (on/off). If you see something that doesn't look like HTML then leave it alone (or modify at your own risk).

All but the anointed (see warning above) should stay clear of Indigos web application (written in Python/CherryPy) is located in the indigo/ directory (under web-home) - most of it... The 'main' app is located in the web-home directory and is called IndigoWebServer.py

With basic html/javascript skills you can modify the Javascript scripts that are located in js/ (under web-home) you can add new files and/or modify existing files.

The artists among us can modify any Images or icons that are in the images/ directory - you MAY need to pay attention to size since making this smaller or larger could effect the web page behavior (since the author may be expecting a 16x16 pixel image and if it gets a 32x32 things may not look or act right). Best advice is to experiment and report back with any findings you've learned.

Dave

Posted on
Thu Dec 07, 2006 2:39 pm
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

(No subject)

(note: edited by support to fill in some details)

Continued:

Things I've learned thus far:
---------------------------------

Please correct any misinformation you see....

----------------------
- Image Files
----------------------

- Changing EXISTING files

o No computer restart necessary to see the change.
o No an Indigo Server restart is not necessary to see the change.

- Adding NEW files

o No computer restart necessary to see the add.
o No an Indigo Server restart is not necessary to see the add.

You many need to clear your browser cache and/or do a forced-page-reload but the server shouldn't need any prodding to start using the changed or added files.

----------------------
- CSS Include Files
----------------------

- Changing EXISTING files

o No computer restart necessary to see the change.
o No an Indigo Server restart is not necessary to see the change.

- Adding NEW files

o No computer restart necessary to see the add.
o No an Indigo Server restart is not necessary to see the add.

These can be added or changed pretty much any time and the server SHOULD send the changes (you may have to clear your browser cache but once you do any changes are reflected).

--------------
- JavaScript
--------------

- Changing EXISTING files

o No computer restart necessary to see the change?
o No an Indigo Server restart is not necessary to see the change?

- Adding NEW files

o No computer restart necessary to see the add?
o No an Indigo Server restart is not necessary to see the add?

These should be the same as CSS but I haven't tested so if anyone knows for sure please reply so I can change this.

--------------------
- HTML Templates
--------------------

- Changing EXISTING files

o No computer restart necessary to see the change.
o No an Indigo Server restart is not necessary to see the change.

Support note: the templates are cached internally, so if a template file has been viewed you will need to stop/restart the IndigoServer to see the change.

- Adding NEW files

o Yes a computer restart is necessary to see the add???

Support note: the templates are cached internally, so if a template file has been viewed you will need to stop/restart the IndigoServer to see the change. Computer restart should not be needed.

This files can be modified any time you like **BUT** the only way I would see the changes was to STOP and then RESTART the Indigo Server (from the File menu in the main GUI Indigo App)

---------------
- Python Files
---------------

o (as near as I can tell) Yes a computer restart is necessary to add/change/delete of any python code.

I may be wrong but the only way I would see the changes made to the *.py files was to RESTART THE COMPUTER. IIRC I don't even think logging out and then logging back in did the trick.

Support note: the Python files should automatically recompile when you stop and restart the server. I've never had to reboot the computer. It may be possible that when you stopped the IndigoServer that the python web server process kept running for some reason, which caused you to need a reboot to see the changes. But stopping the IndigoServer should also stop the web server, so I'm not sure why it didn't work.

Note: If you happen to do 'something really bad(tm)' in Indigo's web server python scripts there's a pretty darn good chance that the server will fail to load! How do I know this.... well lets just say I usually learn by making mistakes. :lol:

---------------------------------------------------------------

Server Caching Summary:

IMAGES - Not cached, except maybe locally by browser.
CSS - Not cached, except maybe locally by browser.
HTML - Cached by the server when the page is accessed.
PYTHON - Compiled and server launch time.

Dave
Last edited by DaveGee on Thu Dec 07, 2006 3:26 pm, edited 4 times in total.

Posted on
Thu Dec 07, 2006 2:41 pm
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

(No subject)

Continued:

Reserved for adding detailed python related answers (see questions in next post)


Cool Links
-------------

These links are geared towards potential Python code hackers:


----------------------
Picket - The Picket filter is a simple CherryPy filter for processing XSLT as a template language. It uses 4Suite to do the job.

Confirmed Usable With Indigo: Not yet.

Link: http://trac.defuze.org/wiki/Picket
----------------------
WSGI is a specification for connecting HTTP servers (like Apache, IIS, or CherryPy's builtin HTTP server) with web applications and frameworks (like CherryPy), so you can mix and match them.

Confirmed Usable With Indigo: Not yet.

Link: http://www.cherrypy.org/wiki/WSGI
----------------------
Running CherryPy behind Apache - this could be quite useful for may of us if it work with Indigo's setup!

Confirmed Usable With Indigo: Not yet.

Link: http://www.cherrypy.org/wiki/BehindApache
----------------------
Connecting your CherryPy server to a database. There are a number of python modules for most databases (MySql, PostgreSql, Oracle, Sybase, ...). To connect your CherryPy server to one of these databases, all you have to do is import the corresponding module in your code and use that module.

Confirmed Usable With Indigo: Not yet.

Link: http://www.cherrypy.org/wiki/CherryPyDatabase
Link: http://www.cherrypy.org/wiki/SQLObjectT ... Connection
----------------------

Dave
Last edited by DaveGee on Thu Dec 07, 2006 4:23 pm, edited 6 times in total.

Posted on
Thu Dec 07, 2006 3:00 pm
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

(No subject)

Continued:

Now the things that I'd like to know....

(all info discoverd will be added above)

What's the best way to create 'non indigo control pages' where the page wouldn't contain any standard Indigo control items.

What's the best way to create a 'hybrid indigo control pages' where the page would contain things like weather, sports, tv listings, etc, etc, etc along with potentially having standard Indigo control items.

Where and how would it be best to add your own custom python code (to accomplish the things above) that the Indigo web server would then run when needed (to grab data such as weather, sports, tv listings, headlines etc, etc, etc).

How would it be best to fire/call a python event/script just on 'initial page load' and not re-run on subsequent page refreshes (this would be for procedures that would grab data that doesn't (need to) change 'every second').

How would it be best to fire/call a python event/script where it would constantly refresh for custom things we might add that need up to the minute/second updates - kinda like the lighting status and/or the 'whats playing now' itunes status.

-----

Sure I know I can just arbitrarily drop code wherever 'I can get it to work' but that's not something I'd really want to do if at all possible.

I also hope I'm not the only one interested in this stuff cause I can see all sorts of cool things that could be done.

How about things like:

- Throwing a popup or 'hovering DIV' with the Caller ID info of the person who is ringing the phone. (provided you have a way to grab that info)

- Throwing a popup with a video feed of the front door when the doorbell rings or the driveway sensor gets tripped or the pool alarm goes off or whatever...

- Current weather, sports scores, tv listings, news headlines

Lots and lots of stuff is all doable now... and hopefully this thread will be 'the pace to go' for getting answers to 'all things web server' related.

Dave

Posted on
Thu Dec 07, 2006 5:35 pm
nsosnicki offline
Posts: 168
Joined: Nov 14, 2004
Location: Boston, MA, US

QTSS

If you are running Quicktime Streaming Server on the same box as your Indigo server, you need to be aware that the default, established ports used by QTSS are 8000 and 8001. Therefore, you should run your Indigo server on an alternate port. 8002 works well for me.

Posted on
Fri Dec 08, 2006 11:03 am
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

(No subject)

With the lack of any assistance and/or comments I guess this is something I'm just wasting my time with.

Maybe I should just keep this stuff all to myself and let others fin for themselves - after all when it comes to Mac software development that mentality seems to be quite common.... :cry:

It's too bad really, in the Windows world I can get example source written by random folks from all over the net that can be a starting point to developing INSTEON applications... Well applications might be too strong a word but 'mini apps' that can do specific and useful things on/to your INSTEON devices.

On the Mac OS side of the coin....

We have one commercial (closed source) application (a very good one) but all the same it's still the only game in town if you want to do anything INSTEON.

I like many others fall into the 'hacker - programmer' category. Not anywhere close to being considered a 'real programmer' but all the same I do know Cocoa as well as a boat load of other languages (mostly scripting) and given source code examples as a starting point we can usually whip something sorta resembling an application or more to the point 'mini-app'.

Could we churn out a USB device driver that can handshake with the INSTEON PowerLinc? Not by a longshot.... Nor would we even know how to begin doing so. Could we (given some example code to get us started) churn out an App that lists all the links of a device or lets you program an INSTEON ControlLinc - yea probably so...

I guess in this case Smarthome is really the party I should be mad at since they don't provide any help driver assistance or programming help to Mac programmers but they don't do it for Linux folks either and yet they (thanks to Neil Cherry & others) have the ball rolling with some basic INSTEON source code.

Well now I've totally sidetracked my own thread with this random rant (that I'm sure I regret later) so I'll stop, shut up and try not to bother anyone.

Posted on
Fri Dec 08, 2006 11:10 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

DaveGee wrote:
With the lack of any assistance and/or comments I guess this is something I'm just wasting my time with.

Definitely not. I've got quite a few comments I'd like to make on your useful postings, as I imagine others will as well. That said, you posted the original thread less than 24 hours ago. I absolutely must get a beta of Indigo out that supports the EZRain first. I've got folks that haven't watered their yards in weeks because they've already installed the EZRain and I haven't delivered yet on the promised sprinkler supported beta. ;-) Not to mention a queue of other support questions I haven't answered yet.

So, give it a few days and I'm sure you'll see some followup posts. You definitely will from me.

Regards,
Matt

Posted on
Fri Dec 08, 2006 12:43 pm
DPattee offline
Posts: 453
Joined: Jan 14, 2004
Location: Redmond, WA

(No subject)

DaveGee wrote:
Well now I've totally sidetracked my own thread with this random rant (that I'm sure I regret later) so I'll stop, shut up and try not to bother anyone.


Yea, i think you're going to regret it ;) You posted a ton of stuff, I haven't had time to read it all. And since my RSS folder currently has everything upside down this rant is the first message I read - and it was a real turn-off.

I'm interested in mixing control page stuff in with my regular Apache-server webpages (where I already have some webcams and other mess all mixed together). My main web server has multiple vhosts on it, and I'm trying to get everything as integrated (or tunneled) as possible so I can get back to only have a single machine accessible from the Internet rather than having multiple holes in my firewall.

So please keep posting things, but also stay calm.

Posted on
Fri Dec 08, 2006 6:54 pm
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

(No subject)

Yes I knew I'd regret it.... and I do.

Never post when something else already got yourself into a snit.
Never post when something else already got yourself into a snit.
Never post when something else already got yourself into a snit.

:oops:

I'd go up their and delete that post but I think I'll leave it just to teach myself a lesson....

Oh and its good to know others are interested in this stuff.... I've got some more stuff I'm working on but it still needs some going over.

Dave

Posted on
Fri Dec 08, 2006 6:59 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

(No subject)

DaveGee wrote:
I've got some more stuff I'm working on but it still needs some going over.

As I mentioned I'll post more in a day or so, but I would like to mention something critical before I forget and someone loses work they've done. If you make any customizations to the Python files (*.py) or any of the template files, then MAKE SURE YOU BACKUP YOUR CHANGES before you run the Indigo installer. It will most definitely stomp all over your changes and they'll be lost. We need to come up with a long term solution to this, like having a directory with .py files that contain hook/callout functions that the Indigo installer never touches, but in the mean time remember to always backup your changes before running the installer.

Regards,
Matt

Posted on
Fri Dec 08, 2006 8:18 pm
Alexander offline
Posts: 60
Joined: Sep 06, 2005

(No subject)

Keep in mind that the Windows side has the "benefit" of the (atrocious) SmartHome Device Manager thingy, which does a little bit of the PowerLinc interfacing for you.

But yeah, if you're going to be doing low-level Insteon stuff, you really have to get an Insteon developer forums account.

Posted on
Sat Dec 09, 2006 8:22 am
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

(No subject)

What Matt said!

I've been doing all of my work in a subdirectory of my home directory and then copy (NOT just move) the files from there to the Indigo web server folders located in the /Library/Application\ Support/Perceptive\ Automation/Indigo\ 2/IndigoWebServer/ area.

I also keep a virgin copy (as installed by the installer) of that same subdirectory for the times when things don't go as planned and I need to compare the stuff I changed to the originals.

Makes life just a tad bit easier...

Dave

Posted on
Sat Dec 09, 2006 8:25 am
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

(No subject)

Alexander wrote:
Keep in mind that the Windows side has the "benefit" of the (atrocious) SmartHome Device Manager thingy, which does a little bit of the PowerLinc interfacing for you.

But yeah, if you're going to be doing low-level Insteon stuff, you really have to get an Insteon developer forums account.


Yep that's true... and while it SDM may be atrocious the fact is we Mac users don't even get even THAT from Smarthome and for simple hack type projects even an atrocious SDM would be fine by me - just so I could start to play with things.

Dave

Posted on
Sat Dec 09, 2006 9:01 am
DaveGee offline
Posts: 60
Joined: Nov 01, 2005

(No subject)

Here was one idea I was kicking about when it comes to packaging and distributing and installing any 3rd party type plug-ins. This is just a rough idea but I think it's nice and clean and makes for pretty easy backup and installs with everything being self contained and located in the web servers 'home' directory in a subdirectory called /plugins or /plugs as in the example below.

Code: Select all
/Library/Application Support/Perceptive\ Automation/Indigo 2/IndigoWebServer

- /css
- /images
- /indigoflash
- /indigopy
- /js
- /plugs -|
          |
          |
          | /weather --| /css       (directory for css files)
          |            | /html      (directory for html/template files)
          |            | /images    (directory for image files)
          |            | /js        (directory for js files)
          |            | /py        (directory for py files)
          |            |
          |            | config.cfg (? ALL the user changable settings for the plugin )
          |            | indigo.cfg (? details & settings of the plugin - For use by indigoweb)
          |            | INSTALL    (? INSTALL Instructions)
          |            | README     (? README File)
          |
          |
          | /tvguide --| /css       (directory for css files)
                       | /html      (directory for html/template files)
                       | /images    (directory for image files)
                       | /js        (directory for js files)
                       | /py        (directory for py files)
                       |
                       | config.cfg (? ALL the user changable settings for the plugin )
                       | indigo.cfg (? details & settings of the plugin - For use by indigoweb)
                       | INSTALL    (? INSTALL Instructions)
                       | README     (? README File)


I figured I should get it down on paper...

Random but associated ideas:

indigo.cfg
=======
Could be used by the indigopy server to gain 'info' about the plugin
-
- Plugin Name?
- Plugin Version?
- Plugin Release Date?
-
- Catagory or Type of plugin?
- Minimum Indigo web-server version needed to run?
-
- Plugin Author?
- Plugin Web Site (aka the authors web site)?
-
- 'Key Word' or 'Variable Word' that indigopy uses to 'activates' it?
- Plugins different 'functions' if any... and their expected parameters and maybe defaults??

config.cfg
=======

Plugin should be written with the idea that ALL user settable variables will be read from this SINGLE file. This will make things easy for potential installers and will be good discipline for hopeful plugin developers. :lol:

It would be nice if it were in a STANDARD (dunno what? XML??) format so maybe one day a future version of Indigo would allow for changing plugin settings from directly within the program itself. Either that or perhaps someone else could write a standalone 'settings editor' that would parse the plug directory reading all of the different config.cfg files and then display some nice GUI front end to edit ALL of the different settings.

INSTALL and README

Self explanatory especially since NOBODY reads them anyhow. :lol:

Python code:

- All (python based) plugin code must be in the plugins /py directory
- All (python based) 'main' python project file must be called {plugin_name}.py

So for example a plugin named weather would have a file called weather/py/weather.py as it's main script and/or object file. If the plugin requires any other project source files it would be up to the developer to make all the needed includes from within THAT {plugin_name}.py script file.

Plugin concepts:

Should they set variables the would be used by indigopy for variable substitution on the standard indigopy html template files?

Things Like:

plug.js = an array of file names to include in the java-script include area of the main HTML template page indigo would append the '/plug/{plugin_name}/js/' automatically

plug.css = an array of file names to include in the css include area of the main HTML template page indigo would append the '/plug/{plugin_name}/css/' automatically

plug.floatingdivs = an array of ZERO or MORE self contained HTML DIVs the css include above would have to tell how/where to position them.

plug.body = ZERO or ONE HTML code snippet that would be used in the BODY area of the indigopy HTML template file

plug.background = optional if the plug-in needs it's own unique background (discouraged since the user should be able to use the one he/she created)

Others??

Dave
Last edited by DaveGee on Sat Dec 09, 2006 10:05 am, edited 7 times in total.

Who is online

Users browsing this forum: No registered users and 1 guest