2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

Fhemweb.pl fixes

git-svn-id: https://svn.fhem.de/fhem/trunk@34 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2007-03-27 14:50:04 +00:00
parent 07161ce44b
commit d5b4420c33
12 changed files with 163 additions and 18 deletions

View File

@ -316,5 +316,10 @@
- disable attribute for at/notify/filelog
See HISTORY for details and reasoning
- added rename command
- webpgm2 adapted to the new syntax, added device specific attribute
and "set" support, gnuplot files are configurable, links to the
documentation added.
support.
- TODO: bugfix: more thorough serial line initialization

View File

@ -68,12 +68,12 @@ my %models = (
fs20tk => 'sender',
fs20uts => 'sender',
fs20ze => 'sender',
fs20ms2 => 'sender',
fs20as1 => 'simple',
fs20as4 => 'simple',
fs20di => 'dimmer',
fs20du => 'dimmer',
fs20ms2 => 'simple',
fs20rst => 'simple',
fs20sa => 'simple',
fs20sig => 'simple',

View File

@ -55,3 +55,12 @@
in the same format. This data is contained in the xmllist.
- disable attribute for at/notify/filelog
- rename added
- Rudi, Tue Mar 27 20:43:15 MEST 2007
fhemweb.pl (webpgm2) changes:
- adopted to the new syntax
- better commandline support (return <pre> formatted)
- FileLog attribute logtype added, and 4 logtypes (== gnuplot files)
defined: fs20, fht, ks300_1, ks300_2
- links in the commandref.html file added
- device dependent attribute and set support

View File

@ -250,6 +250,49 @@ split in multiple lines<br><br>
this in turn makes your logfile unreadable. These messages will not be
generated if the FHZ attribute loglevel is set to 6.</li><br>
<a name="logtype"></a>
<li>logtype<br>
Can be applied to FileLog devices.<br>
Used by the pgm2 webfrontend to offer gnuplot images made from the
logs. The string is made up of tokens separated by comma (,), each
token specifies a different gnuplot program. The token may contain a
colon (:), the part before the colon defines the name of the program,
the part after is the string displayed in the web frontend. Currently
following types of gnuplot programs are implemented:<br>
<ul>
<li>fs20<br>
Plots on as 1 and off as 0. The corresponding filelog definition
for the device fs20dev is:<br>
define FileLog fslog fs20dev /var/log/fs20dev-%Y-%U.log
</li>
<li>fht<br>
Plots the measured-temp/desired-temp/actuator lines. The
corresponding filelog definitions (for the FHT device named
fht1) looks like:<br>
define FileLog fhtlog1 fht1:.*(temp|actuator).*
/var/log/fht1-%Y-%U.log
</li>
<li>ks300_1<br>
Plots the temperature and humidity of a ks300. The
corresponding filelog definitions (for the KS300 device named
ks300) looks like:<br>
define FileLog ks300log ks300:.*H:.*
/var/log/ks300-%Y-%U.log
</li>
<li>ks300_2<br>
Plots the rain (per hour and per day) and wind values of a
ks300. The corresponding filelog definition is the same as
above, both programs evaluate the same log.
</li>
</ul>
The corresponding gnuplot files must be installed, see the fhemweb.pl
configuration for the destination directory.<br>
Example:<br>
attr fhtlog1 logtype ks300_1:Temp/Hum,ks300_2:Rain/Wind
</li><br>
<a name="model"></a>
<li>model<br>
Can be applied to FHZ/FS20/FHT/HMS/KS300/WS300 devices.<br>
@ -267,7 +310,6 @@ split in multiple lines<br><br>
<ul>
<li>FHT: fht80b</li>
<li>FS20:
fs20hgs
fs20hgs
fs20pira
fs20piri
@ -339,7 +381,7 @@ split in multiple lines<br><br>
Notes:<br>
</ul>
<li>See <a href="#delattr">delattr</a> to delete attributes.</li>
<ul>
</ul>
</ul>
<a name="defattr"></a>
@ -967,6 +1009,7 @@ split in multiple lines<br><br>
Instead of &lt;name&gt; you can also use an enumeration (separated by comma)
or ranges (separated by -), see the FS20 examples.
<a name="FHZset"></a>
<h4>Type FHZ:</h4>
<ul>
<code>set FHZ &lt;variable&gt; [&lt;value&gt]</code>
@ -1000,6 +1043,7 @@ split in multiple lines<br><br>
</ul>
<a name="FH20set"></a>
<h4>Type FS20:</h4>
<ul>
<code>set &lt;name&gt; &lt;value&gt; [&lt;time&gt]</code>
@ -1082,6 +1126,7 @@ split in multiple lines<br><br>
</ul>
<a name="FHTset"></a>
<h4>Type FHT:</h4>
<ul>
<code>set &lt;name&gt; &lt;valuetype&gt; &lt;value&gt;</code>
@ -1148,6 +1193,7 @@ split in multiple lines<br><br>
</ul>
</ul>
<a name="WS300set"></a>
<h4>Type WS300:</h4>
<ul>
<code>set WS300Device &lt;interval(min.)&gt; &lt;height(m)&gt; &lt;rainvalume(ml)&gt;

View File

@ -130,18 +130,19 @@ description and <a href="faq.html">faq.html</a> for the F.A.Q.
and <a href="pgm2-2.png">temperature logs</a><br><br>
<ul>
<li>Copy the file <code>fhemweb.pl</code> to your cgi-bin directory
(/home/httpd/cgi-bin), and all the icons (*.gif) to your httpd icons
directory (/home/httpd/icons).<br>
<li>Copy the file fhemweb.pl and *.gplot 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).<br>
Note: The program looks for icons in the following order:
&lt;device-name&gt;.&lt;state&gt;, &lt;device-name&gt;,
&lt;device-type&gt;.&lt;state&gt;, &lt;device-type&gt;<br>
</li>
<li>Edit <code>fhemweb.pl</code>, and check the "Config" section.</li>
<li>If you want to have access to the FHT temperature logs, then
make sure that gnuplot is installed and you log the temperatures like
in example/04_log. Note: There is still a bug with displaying empty
logfiles.</li>
<li>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).
</li>
<li>Call &lt;your-site&gt;/cgi-bin/fhemweb.pl
</ul>
For special features like assigning devices to rooms see the README file.

View File

@ -19,9 +19,13 @@ define ks1 KS300 1234 250 # type KS300, with 250ml rain / counter
# Log temperature and actuator changes into a file, its name changes weekly
define wzlog FileLog /var/tmp/wz-%Y-%U.log wz:.*(temp|actuator).*
# Make it accessible from fhemweb.pl (webpgm2)
attr wzlog logtype fht:Temp
# ks300 log
define kslog FileLog /var/log/wz-%Y-%U.log ks1:.*H:.*
define avglog FileLog /var/log/avg.log ks1:.*avg.*
attr kslog logtype ks300_1:Temp/Hum,ks300_2:Rain/Wind
##############################
# Alternative log method. It does the same, but it is somewhat slower as it

View File

@ -135,11 +135,11 @@ my $reread_active = 0;
my $AttrList = "room";
$modules{Internal}{ORDER} = -1;
$modules{Internal}{AttrList} = "configfile logfile modpath " .
"pidfilename port statefile userattr verbose:1,2,3,4,5 version";
$modules{_internal_}{ORDER} = -1;
$modules{_internal_}{AttrList} = "configfile logfile modpath " .
"pidfilename port statefile title userattr " .
"verbose:1,2,3,4,5 version";
doGlobalDef($ARGV[0]);
my %cmds = (
"?" => { Fn=>"CommandHelp",
@ -200,6 +200,8 @@ if(int(@ARGV) != 1 && int(@ARGV) != 2) {
exit(1);
}
doGlobalDef($ARGV[0]);
###################################################
# Client code
if(int(@ARGV) == 2) {
@ -1584,8 +1586,8 @@ doGlobalDef($)
$devcount = 0;
$defs{global}{NR} = $devcount++;
$defs{global}{TYPE} = "Internal";
$defs{global}{STATE} = "Internal";
$defs{global}{TYPE} = "_internal_";
$defs{global}{STATE} = "<no definition>";
$defs{global}{DEF} = "<no definition>";
CommandAttr(undef, "global verbose 3");

View File

@ -1,13 +1,13 @@
See the main doc (fhem.html) for the first documentation and installation.
If you want to show anly 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
room attribute in the config file:
attr ks300 room garden
attr ks300-log room garden
The attribute of the FHZ 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
"hidden" will not be shown. Devices without a room attribute go
to the room "misc".

View File

@ -0,0 +1,22 @@
#
# Display the measured temp and the actuator.
# FileLog definition:
# define FileLog fhtlog1 fht1:.*(temp|actuator).* /var/log/fht1-%Y-%U.log
#
set terminal png
set output '<OUT>.png'
set xdata time
set timefmt "%Y-%m-%d_%H:%M:%S"
set xlabel " "
set ytics nomirror
set y2tics
set title '<IN>'
set grid
set ylabel "Temperature (Celsius)"
set y2label "Actuator (%)"
plot \
"< awk '/measured/{print $1, $4; s=1}' <IN>"\
using 1:2 axes x1y1 title 'Measured temperature' with lines,\
"< awk '/actuator/ {print $1, $4+0; have=1} /measured/ {s=$1} END { if(!have) print (s, 0)}' <IN>"\
using 1:2 axes x1y2 title 'Actuator (%)' with lines

View File

@ -0,0 +1,17 @@
#
# Display the on and off values off an FS20 device
# FileLog definition:
# define FileLog fs20log fs20dev /var/log/fs20dev-%Y-%U.log
#
set terminal png
set output '<OUT>.png'
set xdata time
set timefmt "%Y-%m-%d_%H:%M:%S"
set xlabel " "
set ytics nomirror
set title '<IN>'
set grid
set yrange [-0.2:1.2]
plot "< awk '{print $1, $3==\"on\"? 1 : 0; }' <IN>"\
using 1:2 title 'On/Off' with steps

View File

@ -0,0 +1,19 @@
#
# Display the Temperature and the humidity values of a KS300.
# FileLog definition:
# define FileLog ks300log ks300:.*H:.* /var/log/ks300-%Y-%U.log
#
set terminal png
set output '<OUT>.png'
set xdata time
set timefmt "%Y-%m-%d_%H:%M:%S"
set xlabel " "
set ytics nomirror
set y2tics
set title '<IN>'
set grid
set ylabel "Temperature (Celsius)"
set y2label "Humidity (%)"
plot "<IN>" using 1:4 axes x1y1 title 'Temperature' with lines,\
"<IN>" using 1:6 axes x1y2 title 'Rel. Humidity (%)' with lines

View File

@ -0,0 +1,20 @@
#
# Display the Wind and the Rain values of a KS300.
# FileLog definition:
# define FileLog ks300log ks300:.*H:.* /var/log/ks300-%Y-%U.log
#
set terminal png
set output '<OUT>.png'
set xdata time
set timefmt "%Y-%m-%d_%H:%M:%S"
set xlabel " "
set ytics nomirror
set y2tics
set title '<IN>'
set grid
set ylabel "Wind (Km/h)"
set y2label "Rain (l/m2)"
plot "<IN>" using 1:8 axes x1y1 title 'Wind' with lines,\
"<grep -v avg_ <IN> | perl -ane '@a = split(\"[_:]\", $F[0]); if(defined($lh) && $lh ne $a[1]) { printf(\"${ld}_$lh:30:00 %f\n\", $hv); $hv = 0; } if($lv) { $hv += ($F[9]-$lv); } $lh = $a[1]; $ld = $a[0]; $lv = $F[9]; END { printf(\"${ld}_$lh:30:00 %f\n\", $hv) }'" using 1:2 axes x1y2 title 'Rain/h' with histeps,\
"<grep -v avg_ <IN> | perl -ane '@a = split(\"[_]\", $F[0]); if(defined($ld) && $ld ne $a[0]) { printf(\"${ld}_12:00:00 %f\n\", $dv); $dv = 0; } if($lv) { $dv += ($F[9]-$lv); } $ld = $a[0]; $lv = $F[9]; END {printf(\"${ld}_12:00:00 %f\n\", $dv)}'" using 1:2 axes x1y2 title 'Rain/day' with histeps