Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

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

Questions and comments specific to a particular plugin should go here.
Post Reply
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

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

Post 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?
Filandre
Posts: 10
Joined: Sat Mar 28, 2015 8:27 pm

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

Post 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/.
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

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

Post 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:
Post Reply