mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-13 17:26:34 +00:00
FHEMWEB cleanup, some small additional fixes/additions
git-svn-id: https://svn.fhem.de/fhem/trunk@230 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
34a74bc0c0
commit
7f0b72c6b8
@ -411,7 +411,7 @@
|
|||||||
- feature: webpgm2 generates SVG's from logs: no need for gnuplot
|
- feature: webpgm2 generates SVG's from logs: no need for gnuplot
|
||||||
- bugfix: examples corrected to work with current syntax
|
- bugfix: examples corrected to work with current syntax
|
||||||
|
|
||||||
- ==DATE== (4.4)
|
- 2008-08-04 (4.4)
|
||||||
- feature: RM100-2 battery empty warning (mare 23.07.08)
|
- feature: RM100-2 battery empty warning (mare 23.07.08)
|
||||||
- feature: optimising the pgm2/SVG memory usage
|
- feature: optimising the pgm2/SVG memory usage
|
||||||
- feature: autoloading FHEM modules
|
- feature: autoloading FHEM modules
|
||||||
@ -421,3 +421,6 @@
|
|||||||
- feature: HMS100-FIT added (01.01.08 by Peter and 22.01.08 by Juergen)
|
- feature: HMS100-FIT added (01.01.08 by Peter and 22.01.08 by Juergen)
|
||||||
- feature: 91_watchdog added to handle the HMS100-FIT
|
- feature: 91_watchdog added to handle the HMS100-FIT
|
||||||
- feature: cum_kWh/cum_m3 added to EMWZ/EMGZ (11.01.08 by Peter)
|
- feature: cum_kWh/cum_m3 added to EMWZ/EMGZ (11.01.08 by Peter)
|
||||||
|
|
||||||
|
- ==DATE== (4.5)
|
||||||
|
- feature: further 01_FHEMWEB cleanup
|
||||||
|
@ -41,7 +41,7 @@ FileLog_Define($@)
|
|||||||
my @t = localtime;
|
my @t = localtime;
|
||||||
my $f = ResolveDateWildcards($a[2], @t);
|
my $f = ResolveDateWildcards($a[2], @t);
|
||||||
$fh = new IO::File ">>$f";
|
$fh = new IO::File ">>$f";
|
||||||
return "Can't open $f" if(!defined($fh));
|
return "Can't open $f: $!" if(!defined($fh));
|
||||||
|
|
||||||
$hash->{FH} = $fh;
|
$hash->{FH} = $fh;
|
||||||
$hash->{REGEXP} = $a[3];
|
$hash->{REGEXP} = $a[3];
|
||||||
@ -226,6 +226,7 @@ FileLog_Get($@)
|
|||||||
}
|
}
|
||||||
|
|
||||||
my %lastdate;
|
my %lastdate;
|
||||||
|
my $d; # Used by eval functions
|
||||||
while(my $l = <$ifh>) {
|
while(my $l = <$ifh>) {
|
||||||
last if($l gt $to);
|
last if($l gt $to);
|
||||||
my @fld = split("[ \r\n]+", $l); # 40%
|
my @fld = split("[ \r\n]+", $l); # 40%
|
||||||
@ -263,7 +264,6 @@ FileLog_Get($@)
|
|||||||
}
|
}
|
||||||
$h->{last2} = $fld[$col];
|
$h->{last2} = $fld[$col];
|
||||||
$lastdate{$hd} = $fld[0];
|
$lastdate{$hd} = $fld[0];
|
||||||
next if(!$line);
|
|
||||||
|
|
||||||
} elsif($t == 3) { # int function
|
} elsif($t == 3) { # int function
|
||||||
my $val = $fld[$col];
|
my $val = $fld[$col];
|
||||||
@ -272,6 +272,7 @@ FileLog_Get($@)
|
|||||||
} else { # evaluate
|
} else { # evaluate
|
||||||
$line = "$fld[0] " . eval($h->{fn}) . "\n";
|
$line = "$fld[0] " . eval($h->{fn}) . "\n";
|
||||||
}
|
}
|
||||||
|
next if(!$line);
|
||||||
|
|
||||||
if($outf eq "-") {
|
if($outf eq "-") {
|
||||||
$h->{ret} .= $line;
|
$h->{ret} .= $line;
|
||||||
@ -318,7 +319,7 @@ FileLog_Get($@)
|
|||||||
}
|
}
|
||||||
if($internal) {
|
if($internal) {
|
||||||
$internal_data = \$ret;
|
$internal_data = \$ret;
|
||||||
return "OK";
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($outf eq "-") ? $ret : join(" ", @fname);
|
return ($outf eq "-") ? $ret : join(" ", @fname);
|
||||||
|
@ -225,6 +225,14 @@
|
|||||||
<li>Start httpd with the startssl option (SSL or the like must be set in
|
<li>Start httpd with the startssl option (SSL or the like must be set in
|
||||||
one of your system files, look at /etc/init.d/httpd).</li>
|
one of your system files, look at /etc/init.d/httpd).</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
To display "foreign" (non fhem) files as a plot or a just as plain text,
|
||||||
|
configure a fake logfile with the correct filename and an unused regexp,
|
||||||
|
e.g.<br><pre>
|
||||||
|
define messages FileLog /var/log/messages fakelog
|
||||||
|
</pre>
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -515,17 +515,25 @@ fs20usr</pre></li>
|
|||||||
as an SVG script to the frontend, which will compute
|
as an SVG script to the frontend, which will compute
|
||||||
the image: no need for gnuplot on the backend.</li>
|
the image: no need for gnuplot on the backend.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
See also the attribute fixedrange.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
<a name="plotsize"></a>
|
<a name="plotsize"></a>
|
||||||
<li>plotsize<br/>
|
<li>plotsize<br/>
|
||||||
Can be applied to FHEMWEB devices. (webfrontend/pgm2)<br/> Specifies
|
Can be applied to FHEMWEB devices. (webfrontend/pgm2)<br/> Specifies
|
||||||
the defult size of the plot, in pixels, separated by comma:
|
the default size of the plot, in pixels, separated by comma:
|
||||||
width,height. You can set individual sizes by setting the plotsize of
|
width,height. You can set individual sizes by setting the plotsize of
|
||||||
the weblink.
|
the weblink.
|
||||||
</li><br>
|
</li><br>
|
||||||
</li>
|
|
||||||
</ul>
|
<a name="fixedrange"></a>
|
||||||
|
<li>fixedrange<br/>
|
||||||
|
Can be applied to weblink devices (FHEMWEB).<br/>
|
||||||
|
Contains two time specs in the form YYYY-MM-DD separated by a space.
|
||||||
|
In plotmode gnuplot-scroll or SVG the given time-range will be used,
|
||||||
|
and no scrolling for this weblinks will be possible. Needed e.g. for
|
||||||
|
looking at last-years data without scrolling.
|
||||||
|
</li><br> </li> </ul>
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -10,3 +10,6 @@ attr global modpath . # where our FHEM directory is
|
|||||||
|
|
||||||
define WEB FHEMWEB 8083
|
define WEB FHEMWEB 8083
|
||||||
attr WEB plotmode SVG
|
attr WEB plotmode SVG
|
||||||
|
|
||||||
|
# Fake logfile, to access the global log
|
||||||
|
define Logfile FileLog /tmp/fhem-%Y-%m.log fakelog
|
||||||
|
23
fhem/fhem.pl
23
fhem/fhem.pl
@ -143,7 +143,7 @@ my $nextat; # Time when next timer will be triggered.
|
|||||||
my $intAtCnt=0;
|
my $intAtCnt=0;
|
||||||
my $reread_active = 0;
|
my $reread_active = 0;
|
||||||
my $AttrList = "room comment";
|
my $AttrList = "room comment";
|
||||||
my $cvsid = '$Id: fhem.pl,v 1.51 2008-08-04 14:34:53 rudolfkoenig Exp $';
|
my $cvsid = '$Id: fhem.pl,v 1.52 2008-08-08 10:46:25 rudolfkoenig Exp $';
|
||||||
|
|
||||||
$init_done = 0;
|
$init_done = 0;
|
||||||
|
|
||||||
@ -1187,10 +1187,7 @@ CommandXmlList($$)
|
|||||||
$lt = $t;
|
$lt = $t;
|
||||||
|
|
||||||
my $a1 = XmlEscape($p->{STATE});
|
my $a1 = XmlEscape($p->{STATE});
|
||||||
my $a2 = CommandSet(undef, "$d ?");
|
my $a2 = XmlEscape(getAllSets($d));
|
||||||
$a2 =~ s/.*choose one of //;
|
|
||||||
$a2 = "" if($a2 =~ /^No set implemented for/);
|
|
||||||
$a2 = XmlEscape($a2);
|
|
||||||
my $a3 = XmlEscape(getAllAttr($d));
|
my $a3 = XmlEscape(getAllAttr($d));
|
||||||
|
|
||||||
$str .= "\t\t<$t name=\"$d\" state=\"$a1\" sets=\"$a2\" attrs=\"$a3\">\n";
|
$str .= "\t\t<$t name=\"$d\" state=\"$a1\" sets=\"$a2\" attrs=\"$a3\">\n";
|
||||||
@ -1308,6 +1305,17 @@ getAllAttr($)
|
|||||||
return $list;
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
sub
|
||||||
|
getAllSets($)
|
||||||
|
{
|
||||||
|
my $d = shift;
|
||||||
|
my $a2 = CommandSet(undef, "$d ?");
|
||||||
|
$a2 =~ s/.*choose one of //;
|
||||||
|
$a2 = "" if($a2 =~ /^No set implemented for/);
|
||||||
|
return $a2;
|
||||||
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
GlobalAttr($$)
|
GlobalAttr($$)
|
||||||
{
|
{
|
||||||
@ -1831,6 +1839,11 @@ CallFn(@)
|
|||||||
{
|
{
|
||||||
my $d = shift;
|
my $d = shift;
|
||||||
my $n = shift;
|
my $n = shift;
|
||||||
|
if(!$defs{$d}{TYPE}) {
|
||||||
|
Log 0, "Removing $d, has no TYPE";
|
||||||
|
delete($defs{$d});
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
my $fn = $modules{$defs{$d}{TYPE}}{$n};
|
my $fn = $modules{$defs{$d}{TYPE}}{$n};
|
||||||
return "" if(!$fn);
|
return "" if(!$fn);
|
||||||
no strict "refs";
|
no strict "refs";
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -117,6 +117,7 @@ SVG_render($$$$$$$)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
($d, $v) = split(" ", $l);
|
($d, $v) = split(" ", $l);
|
||||||
|
|
||||||
$d = ($tmul ? int((time_to_sec($d)-$fromsec)*$tmul) : $d);
|
$d = ($tmul ? int((time_to_sec($d)-$fromsec)*$tmul) : $d);
|
||||||
if($ld ne $d || $lv ne $v) { # Saves a lot on year zoomlevel
|
if($ld ne $d || $lv ne $v) { # Saves a lot on year zoomlevel
|
||||||
$ld = $d; $lv = $v;
|
$ld = $d; $lv = $v;
|
||||||
|
@ -11,7 +11,7 @@ weblink_Initialize($)
|
|||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
$hash->{DefFn} = "weblink_Define";
|
$hash->{DefFn} = "weblink_Define";
|
||||||
$hash->{AttrList}= "fixedrange noscroll";
|
$hash->{AttrList}= "fixedrange plotmode plotsize label";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
27
fhem/webfrontend/pgm2/cpulog.gplot
Normal file
27
fhem/webfrontend/pgm2/cpulog.gplot
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
############################
|
||||||
|
# Display a CPU temperature log of the form
|
||||||
|
# 2008-02-29_09:48:30 CPU 39.0 SYS 39.0 CORE 57.0 CPU_FAN 1068 CASE_FAN 0 HD_TEMP 46
|
||||||
|
# We need a fake FileLog definition:
|
||||||
|
# define cpulog FileLog test2/temperature-history cpufake
|
||||||
|
|
||||||
|
set terminal png transparent size <SIZE> crop
|
||||||
|
set output '<OUT>.png'
|
||||||
|
set xdata time
|
||||||
|
set timefmt "%Y-%m-%d_%H:%M:%S"
|
||||||
|
set xlabel " "
|
||||||
|
set ytics nomirror
|
||||||
|
set y2tics
|
||||||
|
set title '<TL>'
|
||||||
|
set grid xtics y2tics
|
||||||
|
|
||||||
|
set ylabel "Temperature in C"
|
||||||
|
|
||||||
|
#FileLog 3:CPU:0:
|
||||||
|
#FileLog 5:SYS:0:
|
||||||
|
#FileLog 7:CORE:0:
|
||||||
|
#FileLog 13:HD_TEMP:0:
|
||||||
|
|
||||||
|
plot "<IN>" using 1:3 title 'CPU' with lines,\
|
||||||
|
"<IN>" using 1:5 title 'SYS' with lines,\
|
||||||
|
"<IN>" using 1:7 title 'CORE' with lines,\
|
||||||
|
"<IN>" using 1:13 title 'HDTEMP' with lines
|
35
fhem/webfrontend/pgm2/garden.gplot
Normal file
35
fhem/webfrontend/pgm2/garden.gplot
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
############################
|
||||||
|
# Display irrigation times, the log must be of the form
|
||||||
|
# 2008-04-29_19:00:06 GVent5 365 365 187
|
||||||
|
# 2008-04-29_19:00:06 Total time is 365
|
||||||
|
|
||||||
|
set terminal png transparent size <SIZE> crop
|
||||||
|
set output '<OUT>.png'
|
||||||
|
set xdata time
|
||||||
|
set timefmt "%Y-%m-%d_%H:%M:%S"
|
||||||
|
set xlabel " "
|
||||||
|
set ytics nomirror
|
||||||
|
set y2tics
|
||||||
|
set title '<TL>'
|
||||||
|
set grid xtics y2tics
|
||||||
|
|
||||||
|
set ylabel "Minutes"
|
||||||
|
set y2label "Minutes"
|
||||||
|
|
||||||
|
#FileLog 3:GVent1:0:$d=$fld[2];$d/60
|
||||||
|
#FileLog 3:GVent2:0:$d+=$fld[2];$fld[2]?$d/60:0
|
||||||
|
#FileLog 3:GVent3:0:$d+=$fld[2];$fld[2]?$d/60:0
|
||||||
|
#FileLog 3:GVent4:0:$d+=$fld[2];$fld[2]?$d/60:0
|
||||||
|
#FileLog 3:GVent5:0:$d+=$fld[2];$fld[2]?$d/60:0
|
||||||
|
#FileLog 3:GVent6:0:$d+=$fld[2];$fld[2]?$d/60:0
|
||||||
|
#FileLog 3:GVent7:0:$d+=$fld[2];$fld[2]?$d/60:0
|
||||||
|
#FileLog 3:GVent8:0:$d+=$fld[2];$fld[2]?$d/60:0
|
||||||
|
|
||||||
|
plot "<IN>" using 1:3 title 'Lb west' with points,\
|
||||||
|
"<IN>" using 1:3 title 'Rasen Sued' with points,\
|
||||||
|
"<IN>" using 1:3 title 'Lb ost' with points,\
|
||||||
|
"<IN>" using 1:3 title 'Rasen Haus' with points,\
|
||||||
|
"<IN>" using 1:3 title 'Eingang' with points,\
|
||||||
|
"<IN>" using 1:3 title 'Rasen West' with points,\
|
||||||
|
"<IN>" using 1:3 title 'Stichstr.' with points,\
|
||||||
|
"<IN>" using 1:3 title 'Beete' with points
|
@ -1,4 +1,4 @@
|
|||||||
body { color: black; background: #FFFFD7; }
|
body { color: black; background: #FFFFE7; }
|
||||||
|
|
||||||
table { -moz-border-radius:8px; }
|
table { -moz-border-radius:8px; }
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ polyline { stroke:black; stroke-width:1px; fill:none; }
|
|||||||
.l1 { stroke:green; } text.l1 { stroke:none; fill:green; }
|
.l1 { stroke:green; } text.l1 { stroke:none; fill:green; }
|
||||||
.l2 { stroke:blue; } text.l2 { stroke:none; fill:blue; }
|
.l2 { stroke:blue; } text.l2 { stroke:none; fill:blue; }
|
||||||
.l3 { stroke:magenta; } text.l3 { stroke:none; fill:magenta; }
|
.l3 { stroke:magenta; } text.l3 { stroke:none; fill:magenta; }
|
||||||
.l4 { stroke:cyan; } text.l4 { stroke:none; fill:cyan; }
|
.l4 { stroke:brown; } text.l4 { stroke:none; fill:brown; }
|
||||||
.l5 { stroke:black; } text.l5 { stroke:none; fill:black; }
|
.l5 { stroke:black; } text.l5 { stroke:none; fill:black; }
|
||||||
.l6 { stroke:olive; } text.l6 { stroke:none; fill:olive; }
|
.l6 { stroke:olive; } text.l6 { stroke:none; fill:olive; }
|
||||||
.l7 { stroke:gray; } text.l7 { stroke:none; fill:gray; }
|
.l7 { stroke:gray; } text.l7 { stroke:none; fill:gray; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user