From d5b4420c337747335157d537e6613c88206c419f Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 27 Mar 2007 14:50:04 +0000 Subject: [PATCH] Fhemweb.pl fixes git-svn-id: https://svn.fhem.de/fhem/trunk@34 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 5 +++ fhem/FHEM/10_FS20.pm | 2 +- fhem/HISTORY | 9 ++++++ fhem/docs/commandref.html | 50 +++++++++++++++++++++++++++-- fhem/docs/fhem.html | 15 +++++---- fhem/examples/04_log | 4 +++ fhem/fhem.pl | 14 ++++---- fhem/webfrontend/pgm2/README | 4 +-- fhem/webfrontend/pgm2/fht.gplot | 22 +++++++++++++ fhem/webfrontend/pgm2/fs20.gplot | 17 ++++++++++ fhem/webfrontend/pgm2/ks300_1.gplot | 19 +++++++++++ fhem/webfrontend/pgm2/ks300_2.gplot | 20 ++++++++++++ 12 files changed, 163 insertions(+), 18 deletions(-) create mode 100644 fhem/webfrontend/pgm2/fht.gplot create mode 100644 fhem/webfrontend/pgm2/fs20.gplot create mode 100644 fhem/webfrontend/pgm2/ks300_1.gplot create mode 100644 fhem/webfrontend/pgm2/ks300_2.gplot diff --git a/fhem/CHANGED b/fhem/CHANGED index f2524b017..21998b2cf 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -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 diff --git a/fhem/FHEM/10_FS20.pm b/fhem/FHEM/10_FS20.pm index 0e7540b3d..8bb105a15 100755 --- a/fhem/FHEM/10_FS20.pm +++ b/fhem/FHEM/10_FS20.pm @@ -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', diff --git a/fhem/HISTORY b/fhem/HISTORY index b64744389..c5141e548 100644 --- a/fhem/HISTORY +++ b/fhem/HISTORY @@ -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
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 diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index fa2c28d0a..4933c8ee2 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -250,6 +250,49 @@ split in multiple lines
this in turn makes your logfile unreadable. These messages will not be generated if the FHZ attribute loglevel is set to 6.
+ +
set FHZ <variable> [<value>]
@@ -1000,6 +1043,7 @@ split in multiple linesset <name> <value> [<time>]
@@ -1082,6 +1126,7 @@ split in multiple linesset <name> <valuetype> <value>
@@ -1148,6 +1193,7 @@ split in multiple linesset WS300Device <interval(min.)> <height(m)> <rainvalume(ml)>
diff --git a/fhem/docs/fhem.html b/fhem/docs/fhem.html
index 8881fa2a6..bac7fef72 100644
--- a/fhem/docs/fhem.html
+++ b/fhem/docs/fhem.html
@@ -130,18 +130,19 @@ description and faq.html for the F.A.Q.
and temperature logs
- - Copy the file
fhemweb.pl
to your cgi-bin directory
- (/home/httpd/cgi-bin), and all the icons (*.gif) to your httpd icons
- directory (/home/httpd/icons).
+ - 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).
Note: The program looks for icons in the following order:
<device-name>.<state>, <device-name>,
<device-type>.<state>, <device-type>
- Edit
fhemweb.pl
, and check the "Config" section.
- - 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.
+ - 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).
+
- Call <your-site>/cgi-bin/fhemweb.pl
For special features like assigning devices to rooms see the README file.
diff --git a/fhem/examples/04_log b/fhem/examples/04_log
index 10d98ab9a..e6d9c1003 100644
--- a/fhem/examples/04_log
+++ b/fhem/examples/04_log
@@ -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
diff --git a/fhem/fhem.pl b/fhem/fhem.pl
index 726687ebb..0cc4bd82b 100755
--- a/fhem/fhem.pl
+++ b/fhem/fhem.pl
@@ -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} = "";
$defs{global}{DEF} = "";
CommandAttr(undef, "global verbose 3");
diff --git a/fhem/webfrontend/pgm2/README b/fhem/webfrontend/pgm2/README
index 5a1921e95..8116e7579 100644
--- a/fhem/webfrontend/pgm2/README
+++ b/fhem/webfrontend/pgm2/README
@@ -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".
diff --git a/fhem/webfrontend/pgm2/fht.gplot b/fhem/webfrontend/pgm2/fht.gplot
new file mode 100644
index 000000000..5376a6545
--- /dev/null
+++ b/fhem/webfrontend/pgm2/fht.gplot
@@ -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 '.png'
+set xdata time
+set timefmt "%Y-%m-%d_%H:%M:%S"
+set xlabel " "
+set ytics nomirror
+set y2tics
+set title ''
+set grid
+
+set ylabel "Temperature (Celsius)"
+set y2label "Actuator (%)"
+plot \
+ "< awk '/measured/{print $1, $4; s=1}' "\
+ 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)}' "\
+ using 1:2 axes x1y2 title 'Actuator (%)' with lines
diff --git a/fhem/webfrontend/pgm2/fs20.gplot b/fhem/webfrontend/pgm2/fs20.gplot
new file mode 100644
index 000000000..4e74de65a
--- /dev/null
+++ b/fhem/webfrontend/pgm2/fs20.gplot
@@ -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 '.png'
+set xdata time
+set timefmt "%Y-%m-%d_%H:%M:%S"
+set xlabel " "
+set ytics nomirror
+set title ''
+set grid
+set yrange [-0.2:1.2]
+
+plot "< awk '{print $1, $3==\"on\"? 1 : 0; }' "\
+ using 1:2 title 'On/Off' with steps
diff --git a/fhem/webfrontend/pgm2/ks300_1.gplot b/fhem/webfrontend/pgm2/ks300_1.gplot
new file mode 100644
index 000000000..9315476b5
--- /dev/null
+++ b/fhem/webfrontend/pgm2/ks300_1.gplot
@@ -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 '.png'
+set xdata time
+set timefmt "%Y-%m-%d_%H:%M:%S"
+set xlabel " "
+set ytics nomirror
+set y2tics
+set title ''
+set grid
+
+set ylabel "Temperature (Celsius)"
+set y2label "Humidity (%)"
+plot "" using 1:4 axes x1y1 title 'Temperature' with lines,\
+ "" using 1:6 axes x1y2 title 'Rel. Humidity (%)' with lines
diff --git a/fhem/webfrontend/pgm2/ks300_2.gplot b/fhem/webfrontend/pgm2/ks300_2.gplot
new file mode 100644
index 000000000..06e51f036
--- /dev/null
+++ b/fhem/webfrontend/pgm2/ks300_2.gplot
@@ -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 '.png'
+set xdata time
+set timefmt "%Y-%m-%d_%H:%M:%S"
+set xlabel " "
+set ytics nomirror
+set y2tics
+set title ''
+set grid
+
+set ylabel "Wind (Km/h)"
+set y2label "Rain (l/m2)"
+plot "" using 1:8 axes x1y1 title 'Wind' with lines,\
+ " | 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,\
+ " | 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