Olaf Droegehorn's Web-FrontEnd

(based on CGI)
Updated Version 1.3; Minor error Corrections & Documentation


git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@270 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
odroegehorn
2008-11-27 11:12:17 +00:00
parent 85fee9c9b0
commit 8e0c2a4df0
3 changed files with 229 additions and 71 deletions

View File

@@ -1,3 +1,6 @@
#(c) Olaf Droegehorn
# o.droegehorn@dhs-computertechnik.de
# www.dhs-computertechnik.de
############################################## ##############################################
package main; package main;

View File

@@ -0,0 +1,155 @@
Description of the 02_FHEMRENDERER Module:
(c) Olaf Droegehorn
o.droegehorn@dhs-computertechnik.de
www.dhs-computertechnik.de
General Description:
The FHEMRENDERER module is intended to render (draw) graphics based on the FHEM Log-Files.
This can be done either based on a timer (used in the module) or based on a direct call of GET.
The rendered graphics will be stored in a pre-defined directory with a predefined prefix of the files.
The FHEMRENDERER uses attributes to control the behaviour:
plotmode gnuplot
plotsize 800,200
refresh 00:10:00
room Unsorted
status off
tmpfile /tmp/
These attributes have the following meaning:
plotmode, plotsize: Control gnuplot and the desired output
refresh: type HH:MM:SS, is the time-interval in which the re-rendering is done
status: Tells if the timer-based re-rendering is on/off
tmpfile: Is the path (and prefix, if given) of the graphic-files, that will be rendered
NOTE: The timer-based rendering renders ONLY those fileplots, for which you have defined a WebLink !
See WebLink for more details on how to define.
NOTE: At the moment the renderer supports only GNUPLOT, meaning gnuplot is used to draw the graphics. The supported
modes are (gnuplot and gnuplot-scroll).
Supported commands are:
define/set/get/attributes
DEFINE
define <name> <type> <type-specific>
Define a device. You need devices if you want to manipulate them (e.g. set on/off).
Use "define <name> ?" to get a list of possible types.
Type FHEMRENDERER
define <name> FHEMRENDERER [global]
This defines a new "device", that is of type FHEMRENDERER. The option 'global' can be used if needed for sorting reasons.
Otherwise this option has no real meaning for FHEMRENDERER.
As a side-effect of defining this "device" the following attributes will be set for this "device":
plotmode gnuplot
plotsize 800,200
refresh 00:10:00
room Unsorted
status off
tmpfile /tmp/
NOTE: The Logfile will report (with LogLevel 2) that the FHEMRENDERER has been defined.
Examples:
define renderer FHEMRENDERER
SET
set <name> <type-specific>
Set parameters of a device / send signals to a device. You can get a list of possible commands by
set <name> ?
Type FHEMRENDERER:
set FHEMRENDERER on/off
This switches the timer-based rendering on/off. The attribute 'status' will be modified accordingly.
NOTE: only WebLink based graphics will be rendered.
GET
get <name> <type-specific>
Ask a value directly from the device, and wait for an answer. In general, you can get a list of possible commands by
get <device> ?
Type FHEMRENDERER:
get FHEMRENDERER [[file-name] device type logfile [pos=zoom=XX&off=YYY]]
the get function supports different sets of arguments:
Arguments:
NONE: all WebLink based FilePlots will be rerendered
The resulting filename will be '<attr-tmpfile><weblinkname>.png'
THREE: '<device> <type> <logfile>'
In this case only one specific graphic will be rendered:
A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile'
The resulting filename will be '<attr-tmpfile>logfile.png'
FOUR: '<file-name> <device> <type> <logfile>'
In this case only one specific graphic will be rendered:
A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile'
The resulting filename will be '<attr-tmpfile><file-name>.png'
FIVE: '<file-name> <device> <type> <logfile> pos=zoom=XX&off=YYY'
In this case only one specific graphic will be rendered assuming that plotmode is 'gnuplot-scroll':
A graphic will be rendered for 'device', where device is a FileLog, based on the type 'type' based on the given 'logfile'
The 'zoom' will be either qday/day/week/month/year (same as used in FHEMWEB).
The offset 'off' is either 0 (then the second part can be omitted, or -1/-2.... to jump back in time.
The resulting filename will be '<attr-tmpfile><file-name>.png'
NOTE: If you want to use zoom AND offset then you have to concatenate via '&' !!
NOTE: combinations are possible in limited ranges:
meaning: you can add the 'pos=zoom=XX&off=YY' to any of the first three sets.
This may e.g. result in rendering all WebLinks with a specific zoom or offset
(if you just pass the 'pos=zoom=xx&off=yy' parameter);
Any rendered image (one or all WebLinks) will be stored in <attr-tmpfile> followed by a filename'.png'. The filename will be
either derived (from weblink-name or logfile-name) or, for single files, can be assigend.
Examples:
get FHEMRENDERER
get FHEMRENDERER pos=zoom=week&off=-1
get FHEMRENDERER azlog fht az-2008-38.log pos=zoom=0
get FHEMRENDERER livingroomgraphics wzlog fht wz-2008-38.log pos=zoom=0
ATTR
attr <name> <attrname> <value>
Set an attribute to something defined by define.
Use "attr <name> ?" to get a list of possible attributes.
Type FHEMRENDERER:
attr FHEMRENDERER <attrname> <value>
Attributes: <Values>
plotmode gnuplot / gnuplot-scroll
plotsize Dimension of graphic e.g. 800,200
refresh Timer-Interval for rerendering (HH:MM:SS)
status Status of the Timer (off/on)
tmpfile Path and prefix of for the rendered graphics (e.g. /tmp/)
Installation:
Copy the file pgm5/02_FHEMRENDERER.pm to the installed FHEM directory.
This gives you a graphic rendering engine (gnuplot & gnuplot-scroll at the moment), which can be configured to renderer images in intervals.
The *.gplot files should be reused from the built-in FHEMWEB and should reside in the installed FHEM directory. Here we don't provide specific *.gplot files as the mechanisms are exactly the same.
If you want to have access to plotted logs, then make sure that gnuplot is installed and set the logtype for the FileLog device (see commandref.html and example/04_log).
Copy the file contrib/99_weblink.pm to the installed FHEM directory.

View File

@@ -1,71 +1,71 @@
Web frontend 5 (webfrontend/pgm5) (known upto FHEM 4.2 as pgm2): Description of the pgm5 webfrontend:
This frontend is CGI/CSS based. It has support for rooms, and FHT/KS300 logs. (c) Olaf Droegehorn
o.droegehorn@dhs-computertechnik.de
This webfrontend is an update of the former know pgm2 (up to 4.2): www.dhs-computertechnik.de
It resides in YOUR HTTP server, and doesn't provide an own, like the FHEMWEB module does.
General description:
Why to use this:
1) If you want to stick with your Web-Servers (due to restrictions, Web frontend 5 (webfrontend/pgm5) (known upto FHEM 4.2 as pgm2):
ports or any other reason)
2) If you have a NAS (Network attached storage) and limited CPU-Power. This frontend is CGI/CSS based. It has support for rooms, and FHT/KS300 logs.
This frontend can render the graphics in the background (in
intervals) and sends only the rendered graphics to the HTML-Page. This webfrontend is an update of the former know pgm2 (up to 4.2):
3) If you need the FHEMRENDERER to render the images for other/own It resides in YOUR HTTP server, and doesn't provide an own, like the FHEMWEB module does.
pages.
Why to use this:
How it works: 1) If you want to stick with your Web-Servers (due to restrictions,
The WebFrontend works as usual and well known from before. ports or any other reason)
Main difference: 2) If you have a NAS (Network attached storage) and limited CPU-Power.
It creates and uses an instance of FHEMRENDERER (called renderer). This frontend can render the graphics in the background (in
The renderer has plotmode, plotsize, tmpfile, status, refresh as attributes. intervals) and sends only the rendered graphics to the HTML-Page.
With this you can control, how it works (and when in renders: refresh: 00:15:00 means every 15 minutes it will render an update). 3) If you need the FHEMRENDERER to render the images for other/own
pages.
What will be rendered: All FileLogs for which you have set a WebLink will be rendered in the given intervals.
How it works:
The GET method of the renderer is also able to render specific graphics only for single use on request. The WebFrontend works as usual and well known from before.
Main difference:
Supported methods of renderer: It creates and uses an instance of FHEMRENDERER (called renderer).
DEFINE, SET, GET, ATTR The renderer has plotmode, plotsize, tmpfile, status, refresh as attributes.
DEFINE: defines the renderer With this you can control, how it works (and when in renders: refresh: 00:15:00 means every 15 minutes it will render an update).
SET: Set renderer ON/OFF toggels interval based rendering
GET: renders graphics, based on given parameters What will be rendered: All FileLogs for which you have set a WebLink will be rendered in the given intervals.
ATTR: defines attributes, but all attributes will be set during define The GET method of the renderer is also able to render specific graphics only for single use on request.
to default values.
The PGM5 webfrontend does all this for you, but if you want to use the FHEMRENDERER for own things, you can use it directly.
The PGM5 webfrontend does all this for you, but if you want to use the FHEMRENDERER for own things, you can use it directly.
Installation: INSTALLATION:
Copy the file fhemweb.pl and *.css to your cgi-bin directory (/home/httpd/cgi-bin), the icons (*.gif) to your httpd icons (/home/httpd/icons), and commandref.html to the html directory (/home/httpd/html) (or also to cgi-bin directory). Copy the file fhemweb.pl and *.css to your cgi-bin directory (/home/httpd/cgi-bin), the icons (*.gif) to your httpd icons (/home/httpd/icons), and commandref.html to the html directory (/home/httpd/html) (or also to cgi-bin directory).
The *.gplot files should be reused from the built-in FHEMWEB and should reside in the installed FHEM directory. Here we don't provide specific *.gplot files as the mechanisms are exactly the same. The *.gplot files should be reused from the built-in FHEMWEB and should reside in the installed FHEM directory. Here we don't provide specific *.gplot files as the mechanisms are exactly the same.
Note: The program looks for icons in the following order: Note: The program looks for icons in the following order:
<device-name>.<state>, <device-name>, <device-type>.<state>, <device-type> <device-name>.<state>, <device-name>, <device-type>.<state>, <device-type>
If you want to have access to plotted logs, then make sure that gnuplot is installed and set the logtype for the FileLog device (see commandref.html and example/04_log). If you want to have access to plotted logs, then make sure that gnuplot is installed and set the logtype for the FileLog device (see commandref.html and example/04_log).
Copy the file contrib/99_weblink.pm to the installed FHEM directory. Copy the file contrib/99_weblink.pm to the installed FHEM directory.
Copy the file pgm5/02_FHEMRENDERER.pm to the installed FHEM directory. Copy the file pgm5/02_FHEMRENDERER.pm to the installed FHEM directory.
This gives you a grphic rendering engine (gnuplot & gnuplot-scroll at the moment), which can be configured to renderer images in intervals. This gives you a grphic rendering engine (gnuplot & gnuplot-scroll at the moment), which can be configured to renderer images in intervals.
Call <your-site>/cgi-bin/fhemweb.pl Call <your-site>/cgi-bin/fhemweb.pl
If you want to show only a part of your devices on a single screen If you want to show only a part of your devices on a single screen
(i.e divide them into separate rooms), then assign each device the (i.e divide them into separate rooms), then assign each device the
room attribute in the config file: room attribute in the config file:
attr ks300 room garden attr ks300 room garden
attr ks300-log room garden attr ks300-log room garden
The attribute title of the global device will be used as title on the first The attribute title of the global device will be used as title on the first
screen, which shows the list of all rooms. Devices in the room screen, which shows the list of all rooms. Devices in the room
"hidden" will not be shown. Devices without a room attribute go "hidden" will not be shown. Devices without a room attribute go
to the room "misc". to the room "misc".
To configure the absicondir and relicondir correctly, look into the To configure the absicondir and relicondir correctly, look into the
httpd.conf file (probably /etc/httpd/conf/httpd.conf), and check the httpd.conf file (probably /etc/httpd/conf/httpd.conf), and check the
line which looks like: line which looks like:
Alias /icons/ "/home/httpd/icons/" Alias /icons/ "/home/httpd/icons/"
relicondir will then be /icons, and absicondir /home/httpd/icons. relicondir will then be /icons, and absicondir /home/httpd/icons.