Page 1 of 1

Are there any examples for tables used in Webserver Plug-in?

Posted: Mon Apr 27, 2015 7:19 pm
by Mastiff
Assuming that it's possible, of course. I have a bunch of tables in EG that keeps track of temperatures from the sensors in the house. So the rooms are numbered from 1-13 (plus a few sensors in the refridgerator, the walk in-refridgerator and the freezer), and I have a HTML table that shows each room, the current temp, the time this temp came in, signal of the sensor, the heater status (on/off), the set temperature that I'm trying to keep in that room (where half a degree above turns off the heater, and half a degree below turns it on), and finally the alarm temperature (frost guard for regular rooms, high temp for frezer and fridges). In addition to that I have a couple of frames with the weather forecast for the next 24 hours and the next 7 days. The code is something like this:

Code: Select all

  <tr>
    <td align="left" nowrap><span style="font-family:arial;font-size:200%;color:black;text-align:left"> <a href="http://my_website_for_climate-reports.com/indoors.html">{{eg.globals.Rom[1]}}</a></span></td>
    <td align="center" nowrap><div align="center"><span style="font-family:arial;font-size:200%;color:black;text-align:left">{{eg.globals.Romtemperatur['1']}}</span></div></td>
    <td nowrap><span style="font-family:arial;font-size:200%;color:black;text-align:left"> {{eg.globals.Tid['1']}}</span></td>
    <td align="center"><div align="center"><span style="font-family:arial;font-size:200%;color:black;text-align:left">{{eg.globals.Signal['1']}}</span></div></td>
    <td align="center"><span style="font-family:arial;font-size:200%;color:black;text-align:left"><img src="{{eg.globals.NettsideOvn['1']}}" alt="" width="25" height="25"></span></td>
    <td align="center"><span style="font-family:arial;font-size:200%;color:black;text-align:left">{{eg.globals.Termostatemperatur['1']}}</span></td>
    <td align="center"><span style="font-family:arial;font-size:200%;color:black;text-align:left">{{eg.globals.Alarmtemperatur1['1']}}</span></td>
  </tr>
So I have this chunk of code for every room. Is it possible to make this into a dynamic table created by the EG webserver, so I can only define the line, and then the different variables are filled for all the rooms that are in the table?

Re: Are there any examples for tables used in Webserver Plug

Posted: Wed Apr 29, 2015 6:28 pm
by Filandre
You can use "Jinja2" statements to make this, with simple loops as {% for...%}<TD>{{eg.globals....}}</TD>{% endfor %} for example.
But you must learn a bit of this powerfull language at http://jinja.pocoo.org/docs/dev/.

Re: Are there any examples for tables used in Webserver Plug

Posted: Thu Apr 30, 2015 6:58 am
by Mastiff
Wow... OK, thanks! Seems like I will keep to the same way of doing it, I must admit I'm struggling enough with Lua, Python and a bit of HTML, so learning a new languague probably isn't the smartest thing I can do! :oops: I can't code myself out of a brown paper bag without help! :lol: