Page 1 of 1

Indigo Web Server Public Folder

PostPosted: Tue May 01, 2018 9:59 am
by jay (support)
In Indigo 7.1, we added a public folder from which you can serve static files (images, json, html, etc.) via HTTP without requiring any authentication. Warning: if someone knows the URL of your reflector, they will have access to all files that are in this directory, so use wisely.

The location on your Indigo Server is:

Code: Select all
/Library/Application Support/Perceptive Automation/Indigo 7/IndigoWebServer/public/


Here is the URL pattern:

Code: Select all
https://MYREFLECTOR.indigodomo.net/public/README.txt


If accessing within your local network, you can use:

Code: Select all
http://INDIGOSERVERIP/public/README.txt


It should serve up any type of file with the appropriate mime types based on the file extension. Subdirectories are
also allowed so you can create hierarchy:

Code: Select all
https://MYREFLECTOR.indigodomo.net/public/somedirectory/somefile.html
https://MYREFLECTOR.indigodomo.net/public/images/somepict.jpg


As with the /images/ folder, any files and/or directories in the /public/ folder will need to be moved over when you upgrade to a new
major version (the installer WILL NOT move them automatically).

Re: Indigo Web Server Public Folder

PostPosted: Mon Sep 23, 2019 12:27 pm
by Alain
Hi,
Can we "publish" a control page to this directory?
I'm looking for a way to publish some Indigo state data to a web page that would not require authentication. This solution would be great, if I can populate the web page with data from Indigo.
Thanks
Alain

Re: Indigo Web Server Public Folder

PostPosted: Mon Sep 23, 2019 1:45 pm
by jay (support)
Not a control page that you design in Indigo. You can, however, have a script generate a static webpage.

Re: Indigo Web Server Public Folder

PostPosted: Mon Sep 23, 2019 1:47 pm
by Alain
That would be great. Any examples for me to mimic?

Re: Indigo Web Server Public Folder

PostPosted: Mon Sep 23, 2019 4:00 pm
by jay (support)
Alain wrote:
That would be great. Any examples for me to mimic?


I don't know of anyone who's done it before, so you would be blazing a new trail!

Re: Indigo Web Server Public Folder

PostPosted: Tue Oct 01, 2019 8:16 am
by mundmc
@Alain-
This is on my to-do list. I have a garage bar, and I want to have a way to indicate it is open, what’s playing on Sonos or TV, etc..

My plan was to just use python to write an old fashioned html file to the /Public folder. Keep us posted on your endeavours!

Re: Indigo Web Server Public Folder

PostPosted: Sat Oct 05, 2019 7:53 am
by Alain
So it looks like I have been successful generating a publicly-accessible webpage that contains dynamically-changing data from my home automation system.

I use triggers to update variables when the data of interest changes, and the same trigger updates the html file using the new variable data.

The html file is generated in the public folder using a python script.

***I am certain there is a much more efficient way to create this very simple html file - I am still very novice at python and I'm learning. But it seems to work.

Here's the code - feel free to let me know of better or more efficient ways to generate the html file using python. Enjoy!
Code: Select all
line1 = "<!DOCTYPE html>"
line2 = "<html>"
line3 = "<head>"
line4 = "   <title></title>"
line5 = "</head>"
line6 = "<body style=\"background-color:black;\">"
line7 = "<table style=\"font-family:verdana; width:425px; font-size:140%; color:white; border-spacing:10px;\">"
line8 = "  <tr>"
line9 = "    <td>Solar Production (W)</td>"
line11 = "  </tr>"
line12 = "  <tr>"
line13 = "    <td>Production 7 Days (Wh)</td>"
line15 = "  </tr>"
line16 = "  <tr>"
line17 = "    <td>Pool Temperature (C)</td>"
line19 = "  </tr>"
line20 = "  <tr>"
line21 = "    <td>Pool Salt Level (ppm)</td>"
line23 = "  </tr>"
line24 = "  <tr>"
line25 = "    <td>Tesla Battery Level (%)</td>"
line27 = "  </tr>"
line28 = "</table>"
line29 = "</body>"
line30 = "</html>"
solar = indigo.variables[1009408147] # "MMproduction"
seven = indigo.variables[691404004] # "MMproduction7days"
pooltemp = indigo.variables[42588647] # "MMpoolTemp"
poolsalt = indigo.variables[1592456202] # "MMpoolSalt"
teslabatt = indigo.variables[1956311472] # "MMteslaCharge"
line10 = "    <td style=\"text-align:right;\">%s</td>" % solar.value
line14 = "    <td style=\"text-align:right;\">%s</td>" % seven.value
line18 = "    <td style=\"text-align:right;\">%s</td>" % pooltemp.value
line22 = "    <td style=\"text-align:right;\">%s</td>" % poolsalt.value
line26 = "    <td style=\"text-align:right;\">%s</td>" % teslabatt.value
lines = line1 + "\n" + line2 + "\n" + line3 + "\n" + line4 + "\n" + line5 + "\n" + line6 + "\n" + line7 + "\n" + line8 + "\n" + line9 + "\n" + line10 + "\n" + line11 + "\n" + line12 + "\n" + line13 + "\n" + line14 + "\n" + line15 + "\n" + line16 + "\n" + line17 + "\n" + line18 + "\n" + line19 + "\n" + line20 + "\n" + line21 + "\n" + line22 + "\n" + line23 + "\n" + line24 + "\n" + line25 + "\n" + line26 + "\n" + line27 + "\n" + line28 + "\n" + line29 + "\n" + line30 + "\n"
with open('/Library/Application Support/Perceptive Automation/Indigo 7.3/IndigoWebServer/public/magic1.html', 'w') as f:
    f.write(lines)