2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2024-11-22 02:59:49 +00:00

Preparing 4.4: Doc checking and small fixes

git-svn-id: https://svn.fhem.de/fhem/trunk@217 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2008-07-28 12:33:29 +00:00
parent 98c1a04525
commit 58b84edf1d
19 changed files with 292 additions and 215 deletions

View File

@ -414,3 +414,6 @@
- ==DATE== (4.4)
- feature: RM100-2 battery empty warning (mare 23.07.08)
- feature: optimising the pgm2/SVG memory usage
- feature: autoloading FHEM modules
- bugfix: STATE/$value is carrying again the correct value
- feature: enhancing the Makefile and the documentation

View File

@ -203,6 +203,7 @@ FileLog_Get($@)
$h{fh} = new IO::File "> $fname[$i]";
}
$h{re} = $fld[1];
$h{df} = defined($fld[2]) ? $fld[2] : "";
$h{fn} = $fld[3];
$h{didx} = 10 if($fld[3] && $fld[3] eq "delta-d");
@ -210,9 +211,15 @@ FileLog_Get($@)
if($fld[0] =~ m/"(.*)"/) {
$h{col} = $1;
$h{isfix} = 1;
$h{type} = 0;
} else {
$h{col} = $fld[0]-1;
$h{type} = 1;
}
if($h{fn}) {
$h{type} = 4;
$h{type} = 2 if($h{didx});
$h{type} = 3 if($h{fn} eq "int");
}
$h{ret} = "";
$d[$i] = \%h;
@ -225,19 +232,20 @@ FileLog_Get($@)
for my $i (0..int(@a)-1) { # Process each req. field
my $h = $d[$i];
my $re = $h->{re};
next if($re && $l !~ m/$re/); # 20%
next if($h->{re} && $l !~ m/$h->{re}/); # 20%
my $col = $h->{col};
my $line = "";
my $t = $h->{type};
my $line;
if($h->{isfix}) { # Fixed text
$line = "$fld[0] $col";
} elsif(!$h->{fn}) { # The column
$line = "$fld[0] $fld[$col]";
if($t == 0) { # Fixed text
$line = "$fld[0] $col\n";
} elsif($h->{didx}) { # delta-h or delta-d
} elsif($t == 1) { # The column
$line = "$fld[0] $fld[$col]\n";
} elsif($t == 2) { # delta-h or delta-d
my $hd = $h->{didx};
my $ld = substr($fld[0],0,$hd);
@ -248,31 +256,29 @@ FileLog_Get($@)
$ts = "$lda[1]:30:00" if($hd == 13);
my $v = $fld[$col]-$h->{last1};
$v = 0 if($v < 0); # Skip negative delta
$line = sprintf("%s_%s %0.1f", $lda[0],$ts, $v);
$line = sprintf("%s_%s %0.1f\n", $lda[0],$ts, $v);
}
$h->{last1} = $fld[$col];
$h->{last3} = $ld;
}
$h->{last2} = $fld[$col];
$lastdate{$hd} = $fld[0];
next if(!$line);
} elsif($h->{fn} eq "int") { # int function
} elsif($t == 3) { # int function
my $val = $fld[$col];
$line = "$fld[0] $1" if($val =~ m/^([0-9]+).*/);
$line = "$fld[0] $1\n" if($val =~ m/^([0-9]+).*/);
} else {
$line = "$fld[0] " . eval($h->{fn});
} else { # evaluate
$line = "$fld[0] " . eval($h->{fn}) . "\n";
}
next if(!$line);
$h->{count}++;
$line .= "\n";
if($outf eq "-") {
$h->{ret} .= $line;
} else {
my $fh = $h->{fh};
print $fh $line;
$h->{count}++;
}
}
}
@ -292,7 +298,6 @@ FileLog_Get($@)
if($outf eq "-") {
$h->{ret} .= $line;
$h->{count}++;
} else {
my $fh = $h->{fh};
print $fh $line;
@ -300,7 +305,7 @@ FileLog_Get($@)
}
}
if($outf eq "-") {
$h->{ret} .= "$from $h->{df}\n" if(!$h->{count} && $h->{df} ne "");
$h->{ret} .= "$from $h->{df}\n" if(!$h->{ret} && $h->{df} ne "");
$ret .= $h->{ret} if($h->{ret});
$ret .= "#$a[$i]\n";
} else {

View File

@ -305,3 +305,11 @@
Tested with Firefox 3.0.
Todo: Test with IE+Adobe Plugin/Opera.
- feature: HOWTO for webpgm2 (first chapter)
Fri Jul 25 18:14:26 MEST 2008
- Autoloading modules. In order to make module installation easier and
to optimize memory usage, modules are loaded when the first device of a
certain category is defined. Exceptions are the modules prefixed with 99,
these are considered "utility" modules and are loaded at the beginning.
Some of the older 99_x modules were renamed (99_SVG, 99_dummy), and most
contrib modules were moved to the main FHEM directory.

View File

@ -1,30 +1,43 @@
BINDIR=/usr/local/bin
MODDIR=/usr/local/lib
VARDIR=/var/log/fhem
VERS=4.3
DATE=2008-07-12
DIR=fhem-$(VERS)
all:
@echo Nothing to do for all.
@echo To install, check the Makefile, and then \'make install\'
@echo or \'make install-pgm2\' to install a web frontend too.
install:
install:install-base
cp examples/sample_fhem $(VARDIR)/fhem.cfg
@echo
@echo
@echo Edit $(VARDIR)/fhem.cfg then type perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg
install-pgm2:install-base
cp webfrontend/pgm2/* $(MODDIR)/FHEM
cp docs/commandref.html docs/faq.html docs/HOWTO.html $(MODDIR)/FHEM
cp examples/sample_pgm2 $(VARDIR)/fhem.cfg
cd examples; for i in *; do cp $$i $(MODDIR)/FHEM/example.$$i; done
@echo
@echo
@echo Edit $(VARDIR)/fhem.cfg then start perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg
install-base:
cp fhem.pl $(BINDIR)
cp -r FHEM $(MODDIR)
perl -pi -e 's,modpath .,modpath $(MODDIR),' examples/*
install-pgm2:
cp fhem.pl $(BINDIR)
cp -r FHEM $(MODDIR)
cp -r webfrontend/pgm2/* $(MODDIR)
perl -pi -e 's,modpath .,modpath $(MODDIR),' examples/*
mkdir -p $(VARDIR)
perl -pi -e 's,modpath \.,modpath $(MODDIR),' examples/*
perl -pi -e 's,/tmp,$(VARDIR),' examples/*
dist:
@echo Version is $(VERS), Date is $(DATE)
mkdir .f
cp -r CHANGED FHEM HISTORY Makefile README.CVS em1010pc\
TODO contrib docs examples fhem.pl test webfrontend .f
find .f -name CVS -print | xargs rm -rf
find .f -name \*.orig -print | xargs rm -f
find .f -name .#\* -print | xargs rm -f
find .f -type f -print |\

View File

@ -1,4 +1,5 @@
##############################################
# - Use 99_SUNRISE_EL.pm instead of this module
# - Be aware: Installing the DateTime modules might be tedious, one way is:
# perl -MCPAN -e shell
# cpan> install DateTime::Event::Sunrise

View File

@ -166,9 +166,16 @@ make editing of multiline commands transparent.<br><br>
<a name="modpath"></a>
<li>modpath<br>
Specify the path to the modules directory <code>FHEM</code>. The path
should <b>not</b> contain the directory FHEM. Every file there with the
name pattern &lt;number&gt;_&lt;name&gt;.pm will be loaded in the order
of the number.
should <b>not</b> contain the directory FHEM. Upon setting the
attribute, the directory will be scanned for filenames of the form
NN_&lt;NAME&gt;.pm, and make them available for device definition under
&lt;NAME&gt;. If the first device of type &lt;NAME&gt; is defined, the
module will be loaded, and its function with the name
&lt;NAME&gt;_initialize will be called. Exception to this rule are
modules with NN=99, these are considered to be utility modules
containing only perl helper functions, they are loaded at startup (i.e.
modpath attribute definition time).
</li><br>
<a name="pidfilename"></a>
@ -325,7 +332,7 @@ make editing of multiline commands transparent.<br><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
Used by the pgm2 webfrontend to offer gnuplot/SVG 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,
@ -357,13 +364,10 @@ make editing of multiline commands transparent.<br><br>
above, both programs evaluate the same log.
</li>
<li>text<br>
Shows the logfile as it is (plain text).
Shows the logfile as it is (plain text). Not gnuplot definition
is needed.
</li>
</ul>
The corresponding gnuplot files (up to the "text" one) must be
installed, see the fhemweb.pl configuration for the destination
directory.<br>
Example:<br>
attr fhtlog1 logtype ks300_1:Temp/Rain,ks300_2:Hum/Wind,text:Raw-data
</li><br>
@ -385,42 +389,40 @@ make editing of multiline commands transparent.<br><br>
devices:<br>
<ul>
<li>FHT: fht80b</li>
<li>FS20:
fs20hgs
fs20pira
fs20piri
fs20s20
fs20s8
fs20s4
fs20s4a
fs20s4m
fs20s4u
fs20s4ub
fs20sd
fs20sn
fs20sr
fs20ss
fs20str
fs20tfk
fs20tfk
fs20tk
fs20uts
fs20ze
<li>FS20:
<pre>fs20hgs
fs20pira
fs20piri
fs20s20
fs20s8
fs20s4
fs20s4a
fs20s4m
fs20s4u
fs20s4ub
fs20sd
fs20sn
fs20sr
fs20ss
fs20str
fs20tfk
fs20tfk
fs20tk
fs20uts
fs20ze
fs20as1
fs20as4
fs20di
fs20du
fs20ms2
fs20rst
fs20sa
fs20sig
fs20st
fs20sv
fs20sv
fs20usr
</li>
fs20as1
fs20as4
fs20di
fs20du
fs20ms2
fs20rst
fs20sa
fs20sig
fs20st
fs20sv
fs20sv
fs20usr</pre></li>
<li>HMS: hms100-t hms100-tf hms100-wd hms100-mg hms100-tfk rm100-2</li>
<li>KS300: ks300</li>
@ -460,7 +462,7 @@ make editing of multiline commands transparent.<br><br>
Can be applied to FHT devices.<br/>
If the <a href="#fhtsoftbuffer">fhtsoftbuffer</a> attribute is set, then
resend commands <code>retrycount</code> times if after 240 seconds
no confirmation message is rececived from the corresponding FHT
no confirmation message is received from the corresponding FHT
device.<br>
Default is 3.</li><br>
@ -483,10 +485,18 @@ make editing of multiline commands transparent.<br><br>
i.e the default http address is http://localhost:8083/fhem
</li><br>
<a name="refresh"></a>
<li>webname<br/>
Can be applied to FHEMWEB devices. (webfrontend/pgm2)<br/>
If set, a http-equiv="refresh" entry will be genererated with the given
argument (i.e. the browser will reload the page after the given
seconds).
</li><br>
<a name="plotmode"></a>
<li>plotmode<br/>
Can be applied to FHEMWEB devices. (webfrontend/pgm2)<br/>
Specifies ho to generate the plots:
Specifies how to generate the plots:
<ul>
<li>gnuplot<br>
Call the gnuplot script with each logfile. The filename
@ -500,12 +510,20 @@ make editing of multiline commands transparent.<br><br>
logfile, the easier you can navigate. The recommendation is to
store the data for a whole year in one logfile. The data is
converted into an image on the backend with gnuplot.</li>
<li>SVG (TODO)<br>
<li>SVG<br>
The same scrolling as with gnuplot scroll, but the data is sent
as an SVG path specification 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>
</ul>
</li><br>
<a name="plotsize"></a>
<li>plotsize<br/>
Can be applied to FHEMWEB devices. (webfrontend/pgm2)<br/> Specifies
the defult size of the plot, in pixels, separated by comma:
width,height. You can set individual sizes by setting the plotsize of
the weblink.
</li><br>
</li>
</ul>
@ -1148,9 +1166,8 @@ make editing of multiline commands transparent.<br><br>
of the sunset/sunrise functions should be used with the relative
(+) flag</li>
<li>In order to use the sunrise_rel()/sunset_rel() functions, copy the
99_SUNRISE_EL.pm file from the contrib into the modules (FHEM)
directory, and put { sunrise_coord(long, lat, "") } into your
<li>In order to use the sunrise_rel()/sunset_rel() functions,
put { sunrise_coord(long, lat, "") } into your
<a href="#lastinclude">lastinclude</a> file, as in the above example.
If you are not using sunrise_coord, then the coordinates for
Frankfurt am Main, Germany will be used.
@ -1217,10 +1234,8 @@ make editing of multiline commands transparent.<br><br>
href="#list">list</a> output in paranthesis after the device name, or the
string you see when you do a detailed list of the device.</li>
<!--
<li>To use database logging, copy the file contrib/91_DbLog.pm into your
modules directory, and change the $dbconn parameter in the file.</li>
-->
<li>Each undefined device (FS20, HMS, FHT) will be reported with the
device name "UNDEFINED". The % parameter will contain the type (FS20,
@ -1235,8 +1250,8 @@ make editing of multiline commands transparent.<br><br>
<code>define &lt;name&gt; weblink [link|fileplot] &lt;argument&gt;</code>
<br><br>
This is a placeholder used with webpgm2 to be able to integrate links
into it, and to be able to put more than one gnuplot picture on one page.
It has no set or get methods.
into it, and to be able to put more than one gnuplot/SVG picture on one
page. It has no set or get methods.
Examples:
<ul>
@ -1248,13 +1263,11 @@ make editing of multiline commands transparent.<br><br>
Notes:
<ul>
<li>Normally you won't have to define fileplot weblinks manually, as
fhemweb.pl (webpgm2) makes it easy for you, just plot a logfile (see
FHEMWEB makes it easy for you, just plot a logfile (see
<a href="#logtype">logtype</a>) and convert it to weblink. Now you
can group these weblinks by putting them into rooms. If you convert
the current logfile to a weblink, it will always refer to the current
file (and not the one you originally specified).</li>
<li>The <b>99_weblink.pm</b> module is in the contrib directory, you have
to "install" it manually by copying it into the FHEM directory. </li>
</ul>
</ul>
@ -1271,11 +1284,6 @@ make editing of multiline commands transparent.<br><br>
<code>define myvar dummy</code><br>
<code>set myvar 7</code><br>
</ul>
Notes:
<ul>
<li>The <b>99_dummy.pm</b> module is in the contrib directory, you have
to "install" it manually by copying it into the FHEM directory.</li>
</ul>>
</ul>
</ul>
@ -2221,8 +2229,8 @@ Send buffer:<br/> 2007-10-19 00:31:24 desired-temp 22.5
</li>
<li>
If you add the 99_SUNRISE_EL.pm from the contrib directory to your module
directory, then you have access to the following functions: <br>
By using the 99_SUNRISE_EL.pm module, you have access to the following
functions: <br>
<ul>
sunset_rel()<br>
sunset_abs()<br>

View File

@ -48,11 +48,8 @@ me?</a><br><br>
<a href="#faq12">13. I'd like to see directly in the Web frontend if a window is open. How to do that?</a><br><br>
<br>
<br>
<br>
<br>
<br>
<br/>
<br/>
<a name="faq1"></a>
<b>1. I am using fhem.pl with an fhz1000.pl config file and fhem.pl won't
@ -123,9 +120,11 @@ start</b>
<a name="faq5"></a>
<b>5. I have the code for my devices in the ELV notation, which contains 1,2,3
and 4, but you require a hex code.<br> How should I convert it?</b>
and 4, but fhem requires a hex code. How should I convert it?</b>
<ul>
Note: current fhem versions accept FS20 codes in ELV notation.<br/><br/>
The code used by ELV is in the "quaternal" (?) system plus one added to each
digit, so you can even use the 4 button remote for programming. To convert,
you have two choices: the program four2hex in the contrib directory, or the
@ -154,7 +153,7 @@ and 4, but you require a hex code.<br> How should I convert it?</b>
<a name="faq6"></a>
<b>6. I replaced my FHZ1X00PC, now the FHT80b's does not work anymore.<br>
<b>6. I replaced my FHZ1X00PC, now the FHT80b's does not work anymore.
Help me!</b>
<ul>
The FHT80b's are talking to a single FHZ1XXX device, which has a unique
@ -174,8 +173,8 @@ Help me!</b>
<a name="faq7"></a>
<b>7. I can specify an optional ml/raincounter for a KS300.<br>
Why do you think that 255 should be the default?</b>
<b>7. I can specify an optional ml/raincounter for a KS300. Why do you think
that 255 should be the default?</b>
<ul>
The manual talks about 0.3l resolution, but I wanted to calibrate my device.
So I filled a plastic bottle with 0.5 liter water from the measuring cup,
@ -195,7 +194,7 @@ Why do you think that 255 should be the default?</b>
<a name="faq8"></a>
<b>8. The time specification of the builtin at command is not very
flexible.<br> Please add day/month/weekday to it.</b>
flexible. Please add day/month/weekday to it.</b>
<ul>
I think the command is complex and flexible enough. Use a perl expression
for this functionality like (described in the commandref.html):
@ -230,22 +229,18 @@ by fhem.pl?</b>
<a name="faq11"></a>
<b>11. I'd like to use this sunrise/sunset stuff, can you help me?</b>
<ul>
Copy contrib/99_SUNRISE_EL.pm into your FHEM directory.
Next look for the geographic coordinates of your home, e.g with a GPS
Look for the geographic coordinates of your home, e.g with a GPS
receiver or with googleearth. Compute the latitude/longitude as needed, and
enter them in your lastinclude file with the command:
<pre>{sunrise_coord("<latitude>", "<longitude>", "") }</pre>
If everything is ok, typing
<pre>{ sunrise_abs() }</pre>
in the telnet prompt, will return the time of the sunrise today, in a
HH:MM:SS format.<br><br>
After restart, { sunrise_abs() } will return the time of the sunrise today,
in a HH:MM:SS format.<br><br>
99_SUNRISE_EL.pm is the ExtraLight version of the original 99_SUNRISE.pm,
which needs the DateTime::Event::Sunrise perl module, which in turn is
usually difficult to install. If you still want to use the original module,
then the initialization string will be slightly different:
Note: 99_SUNRISE_EL.pm is the ExtraLight version of the original
99_SUNRISE.pm, which needs the DateTime::Event::Sunrise perl module, which
in turn is usually difficult to install. If you still want to use the
original module, then the initialization string will be slightly different:
<pre>{sunrise_coord("<latitude>", "<longitude>", "Europe/Berlin") }</pre>
</ul>
<a name="faq12"></a>

View File

@ -13,8 +13,11 @@
GPL'd server to access devices like FHZ1000/FHZ1300,EM1010PC,WS300,SCIVT.
Formerly known as fhz1000.pl
<br/><br/>
Current Version: (as of =DATE=) is <a href="http://www.koeniglich.de/fhem/fhem-=VERS=.tar.gz">=VERS=</a>
See the <a href="CHANGED">CHANGED</a> file for current changes.
Current Version: (as of =DATE=) is <a
href="http://www.koeniglich.de/fhem/fhem-=VERS=.tar.gz">=VERS=</a>
See the <a href="CHANGED">CHANGED</a> file for current changes, or the <a
href="#webfrontends"/>webfrontends</a> section for screenshots.
<h2>Description</h2>
<ul>
@ -45,7 +48,8 @@ Currently implemented features:<br>
<li>reading EM1000WZ/EM1000EM/EM1000GZ data via an attached EM1010PC</li>
<li>reading attached SCIVT devices</li>
<li>reading attached M232 devices</li>
<li>reading attached WS2000/WS25000 devices, also via raw network converters(xport)</li>
<li>reading attached WS2000/WS25000 devices, also via raw network
converters(xport)</li>
<li>extract sensor data from IPWE networked weather data receiver</li>
<li>logging events to files or databases, with regexp filters</li>
<li>notifying external programs or internal modules when receiving certain
@ -55,8 +59,8 @@ Currently implemented features:<br>
<li>different web frontends, choose your favorite</li>
<br>
</ul>
See <a href="commandref.html">commandref.html</a> for a detailed command
description and <a href="faq.html">faq.html</a> for the F.A.Q.
See <a href="HOWTO.html">HOWTO.html</a>, <a href="commandref.html">commandref.html</a>
and <a href="faq.html">faq.html</a> for more documentation.
</ul>
<h2>Links:</h2>
@ -123,37 +127,25 @@ description and <a href="faq.html">faq.html</a> for the F.A.Q.
<h3>Server installation on Unix</h3>
<ul>
<li>Copy the file <code>fhem.pl</code> into your path (e.g.
<code>/usr/local/bin</code>), and the FHEM directory e.g. to
<code>/usr/local/lib</code>. </li>
<li>Copy additional modules from the contrib directory
(like 99_SUNRISE_EL.pm)</li>
<li>Make sure that you can access the serial USB
device (e.g. <code>/dev/tts/USB0</code>).</li>
<li>Create a configuration file (see the examples directory and
docs/commandref.html), change at least the modpath
(<code>/usr/local/lib</code>) and define FHZ FHZ (<code>/dev/tts/USB0</code>)
parameters.</li>
<li>Check the Makefile for the installation path, then type make install.</li>
<li>Create a configuration file (see the examples directory or
docs/commandref.html).</li>
<li>Start the server with <code>fhem.pl &lt;configfile&gt;</code></li>
</ul>
<h3>Server installation on Windows</h3>
If you are using cygwin for your perl installation you can follow the guidelines for Unix.
<ul>
<li>be sure you have perl.exe in your path (%PATH%)</li>
<li>unpack distribution in a directory of your choice </li>
<li>Copy additional modules from the contrib directory
(like 99_SUNRISE_EL.pm)</li>
<li>Make sure that you can access the serial USB
device via virtual COM-Port or via socket(e.g. <code>COMX or xport:10001</code>).</li>
<li>Be sure you have perl.exe in your path (%PATH%)</li>
<li>Make sure that you can access the serial USB device via virtual COM-Port
or via socket(e.g. <code>COMX or xport:10001</code>).</li>
<li>Create a configuration file (see the examples directory and
docs/commandref.html), change at least the modpath
(<code>your_install_dir</code>) and define FHZ FHZ (<code>COM10</code>)
parameters.</li>
docs/commandref.html)</li>
<li>Start the server with <code>fhem.pl &lt;configfile&gt;</code></li>
</ul>
<a name="webfrontends"/>
<h3>General Notes for Webfrontends:</h3>
<ul>
<li>You don't have to install all of them, one is probably more than
@ -171,10 +163,15 @@ If you are using cygwin for your perl installation you can follow the guidelines
displaying logfiles as text or plot (SVG builtin or PNG by gnuplot),
navigating/zooming in the plots. <br/>
Screenshots: <a href="pgm2-1.png">overview</a>, <a href="pgm2-2.png">detail</a>,
<a href="pgm2-3.png">SVG-plots</a>.
Screenshots: <a href="pgm2-1.png">overview</a>, <a
href="pgm2-2.png">detail</a>, <a href="pgm2-3.png">SVG-plots</a>.
<br><br>
For installation see the webpgm/pgm2/README file.<br>
Installation: make install-pgm2 &amp;&amp; perl fhem.pl <br>
Connect to fhem via <a
href="http://localhost:8083/fhem">http://localhost:8083/fhem</a>. See the
Howto there on how to continue.
</ul>
<h3>Web frontend 3 (webfrontend/pgm3)</h3>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -143,7 +143,7 @@ my %intAt; # Internal at timer hash.
my $intAtCnt=0;
my $reread_active = 0;
my $AttrList = "room comment";
my $cvsid = '$Id: fhem.pl,v 1.48 2008-07-25 14:14:24 rudolfkoenig Exp $';
my $cvsid = '$Id: fhem.pl,v 1.49 2008-07-28 12:33:29 rudolfkoenig Exp $';
$init_done = 0;
@ -633,7 +633,7 @@ CommandInclude($$)
my $bigcmd = "";
$rcvdquit = 0;
while(my $l = <$fh>) {
chomp($l);
$l =~ s/[\r\n]//g;
if($l =~ m/^(.*)\\$/) { # Multiline commands
$bigcmd .= "$1\\\n";
} else {
@ -1004,7 +1004,7 @@ AssignIoPort($)
my ($hash) = @_;
# Set the I/O device
for my $p (sort { $defs{$b}{NR} cmp $defs{$a}{NR} } keys %defs) {
for my $p (sort { $defs{$b}{NR} <=> $defs{$a}{NR} } keys %defs) {
my $cl = $modules{$defs{$p}{TYPE}}{Clients};
if(defined($cl) && $cl =~ m/:$hash->{TYPE}:/) {
$hash->{IODev} = $defs{$p};
@ -1369,7 +1369,8 @@ GlobalAttr($$)
foreach my $m (sort readdir(DH)) {
next if($m !~ m/^([0-9][0-9])_(.*)\.pm$/);
$modules{$2}{ORDER} = $1;
CommandReload(undef, $m) if($1 eq "99"); # Alway load util functions
CommandReload(undef, $m) # Always load utility modules
if($1 eq "99" && $modules{$2} && !$modules{$2}{LOADED});
$counter++;
}
closedir(DH);
@ -1772,7 +1773,9 @@ DoTrigger($$)
} elsif(!defined($defs{$dev}{CHANGED})) {
return "";
}
$defs{$dev}{STATE} = $defs{$dev}{CHANGED}[0];
# Done by the modules to be able to ignore unimportant messages
#$defs{$dev}{STATE} = $defs{$dev}{CHANGED}[0];
# STATE && {READINGS}{state} should be the same
my $r = $defs{$dev}{READINGS};

View File

@ -27,6 +27,7 @@ sub FHEMWEB_checkDirs();
sub FHEMWEB_digestCgi($);
sub FHEMWEB_doDetail($);
sub FHEMWEB_fileList($);
sub FHEMWEB_getAttr($$);
sub FHEMWEB_makeTable($$$$$$$$);
sub FHEMWEB_parseXmlList($);
sub FHEMWEB_showRoom();
@ -64,6 +65,7 @@ my $__SF; # Short for submit form
my $__ti; # Tabindex for all input fields
my @__zoom; # "qday", "day","week","month","year"
my %__zoom; # the same as @__zoom
my $__wname; # Web instance name
my $__plotmode; # Current plotmode
my $__plotsize; # Size for a plot
my $__data; # Filecontent from browser when editing a file
@ -81,8 +83,7 @@ FHEMWEB_Initialize($)
$hash->{DefFn} = "FHEMWEB_Define";
$hash->{UndefFn} = "FHEMWEB_Undef";
$hash->{AttrFn} = "FHEMWEB_Attr";
$hash->{AttrList}= "loglevel:0,1,2,3,4,5,6 webname plotmode:gnuplot,gnuplot-scroll,SVG plotsize";
$hash->{AttrList}= "loglevel:0,1,2,3,4,5,6 webname plotmode:gnuplot,gnuplot-scroll,SVG plotsize refresh";
}
#####################################
@ -123,22 +124,10 @@ sub
FHEMWEB_Undef($$)
{
my ($hash, $arg) = @_;
close($hash->{PORT});
close($hash->{PORT}) if(defined($hash->{PORT})); # Clients do not have PORT
return undef;
}
#####################################
sub
FHEMWEB_Attr(@)
{
my @a = @_;
if($a[0] eq "set" && $a[2] eq "plotmode" && $a[3] eq "SVG" &&
!$modules{SVG}{LOADED}) {
CommandReload(undef, "98_SVG");
}
}
#####################################
sub
FHEMWEB_Read($)
@ -175,11 +164,11 @@ FHEMWEB_Read($)
}
my $name = $hash->{SNAME};
my $ll = GetLogLevel($name,4);
$__wname = $hash->{SNAME};
my $ll = GetLogLevel($__wname,4);
$FHEMWEBdir = "$attr{global}{modpath}/FHEM";
$__ME = "/" . (($attr{$name} && $attr{$name}{webname}) ?
$attr{$name}{webname} : "fhem");
$__ME = "/" . FHEMWEB_getAttr("webname", "fhem");
$FHEMWEB_reldoc = "$__ME/commandref.html";
$__SF = "<form method=\"get\" action=\"$__ME\">";
@ -196,16 +185,20 @@ FHEMWEB_Read($)
}
$hash->{BUF} .= $buf;
#Log(1, "Got: >$hash->{BUF}<");
return if($hash->{BUF} !~ m/\n\n$/ && $hash->{BUF} !~ m/\r\n\r\n$/);
#Log(0, "Got: >$hash->{BUF}<");
my @lines = split("[\r\n]", $hash->{BUF});
my ($mode, $arg, $method) = split(" ", $lines[0]);
$hash->{BUF} = "";
Log($ll, "HTTP $hash->{NAME} GET $arg");
$__plotmode = $attr{$name}{plotmode} ? $attr{$name}{plotmode} : "SVG";
$__plotsize = $attr{$name}{plotsize} ? $attr{$name}{plotsize} : "800,200";
$__plotmode = FHEMWEB_getAttr("plotmode", "SVG");
$__plotsize = FHEMWEB_getAttr("plotsize", "800,200");
if($__plotmode eq "SVG" && !$modules{SVG}{LOADED}) {
my $ret = CommandReload(undef, "98_SVG");
Log 0, $ret if($ret);
}
my $cacheable = FHEMWEB_AnswerCall($arg);
@ -235,12 +228,13 @@ FHEMWEB_AnswerCall($)
$__ti = 1;
# Lets go:
if($arg =~ m,^${__ME}/(.*html)$, || $arg =~ m,^${__ME}/(.*svg)$,) {
if($arg =~ m,^${__ME}/(.*html)$, || $arg =~ m,^${__ME}/(example.*)$,) {
my $f = $1;
$f =~ s,/,,g; # little bit of security
open(FH, "$FHEMWEBdir/$f") || return;
pO join("", <FH>);
close(FH);
$__RETTYPE = "text/html; charset=ISO-8859-1" if($f =~ m/\.*html$/);
$__RETTYPE = "text/plain; charset=ISO-8859-1" if($f !~ m/\.*html$/);
return 1;
} elsif($arg =~ m,^$__ME/(.*).css,) {
open(FH, "$FHEMWEBdir/$1.css") || return;
@ -292,6 +286,8 @@ FHEMWEB_AnswerCall($)
}
pO "<html>\n<head>\n<title>$__title</title>\n";
my $rf = FHEMWEB_getAttr("refresh", "");
pO "<meta http-equiv=\"refresh\" content=\"$rf\">\n" if($rf);
pO "<link href=\"$__ME/style.css\" rel=\"stylesheet\"/>\n";
pO "</head>\n<body name=\"$__title\">\n";
@ -618,8 +614,11 @@ FHEMWEB_roomOverview($)
pO " <tr><td>\n";
pO " <table class=\"room\" summary=\"Help/Configuration\">\n";
pO " <tr><td><a href=\"$__ME/HOWTO.html\">Howto</a></td></tr>\n";
pO " <tr><td><a href=\"$__ME/faq.html\">FAQ</a></td></tr>\n";
pO " <tr><td><a href=\"$__ME/commandref.html\">Details</a></td></tr>\n";
my $sel = ($cmd =~ m/^style/) ? " class=\"sel\"" : "";
my $sel = ($cmd =~ m/examples/) ? " class=\"sel\"" : "";
pO " <tr$sel><td><a href=\"$__ME?cmd=style examples\">Examples</a></td></tr>\n";
$sel = ($cmd =~ m/list/) ? " class=\"sel\"" : "";
pO " <tr$sel><td><a href=\"$__ME?cmd=style list\">Edit files</a></td></tr>\n";
pO " </table>\n";
pO " </td></tr>\n";
@ -870,7 +869,10 @@ FHEMWEB_showLogWrapper($)
my $path = "$1/$file";
$path = $__devs{$d}{ATTR}{archivedir}{VAL} . "/$file" if(!-f $path);
open(FH, $path) || return FHEMWEB_fatal("$path: $!");
if(!open(FH, $path)) {
pO "$path: $!";
return;
}
my $cnt = join("", <FH>);
close(FH);
$cnt =~ s/</&lt;/g;
@ -1265,11 +1267,15 @@ FHEMWEB_style($$)
if($a[1] eq "list") {
my @fl = FHEMWEB_fileList("$FHEMWEBdir/.*.css");
my @fl;
push(@fl, "fhem.cfg");
push(@fl, "<br>");
push(@fl, FHEMWEB_fileList("$FHEMWEBdir/.*.css"));
push(@fl, "<br>");
push(@fl, FHEMWEB_fileList("$FHEMWEBdir/.*.gplot"));
push(@fl, "<br>");
push(@fl, FHEMWEB_fileList("$FHEMWEBdir/.*html"));
pO "<div id=\"right\">\n";
pO " <table><tr><td>\n";
pO " $msg<br/><br/>\n" if($msg);
@ -1284,15 +1290,38 @@ FHEMWEB_style($$)
pO " </td></tr></table>\n";
pO "</div>\n";
} elsif($a[1] eq "examples") {
my @fl = FHEMWEB_fileList("$FHEMWEBdir/example.*");
pO "<div id=\"right\">\n";
pO " <table><tr><td>\n";
pO " $msg<br/><br/>\n" if($msg);
pO " <table class=\"at\">\n";
my $row = 0;
foreach my $file (@fl) {
pO "<tr class=\"" . ($row?"odd":"even") . "\">";
pO "<td><a href=\"$__ME/$file\">$file</a></td></tr>";
$row = ($row+1)%2;
}
pO " </table>\n";
pO " </td></tr></table>\n";
pO "</div>\n";
} elsif($a[1] eq "edit") {
open(FH, "$FHEMWEBdir/$a[2]") || return FHEMWEB_fatal("$a[2]: $!");
$a[2] =~ s,/,,g; # little bit of security
my $f = ($a[2] eq "fhem.cfg" ? $attr{global}{configfile} :
"$FHEMWEBdir/$a[2]");
if(!open(FH, $f)) {
pO "$f: $!";
return;
}
my $data = join("", <FH>);
close(FH);
pO "<div id=\"right\">\n";
pO " <form>";
pO FHEMWEB_submit("save", "Save $a[2]") . "<br/><br/>";
pO FHEMWEB_submit("save", "Save $f") . "<br/><br/>";
pO FHEMWEB_hidden("cmd", "style save $a[2]");
pO "<textarea name=\"data\" cols=\"80\" rows=\"30\">" .
"$data</textarea>";
@ -1301,11 +1330,19 @@ FHEMWEB_style($$)
} elsif($a[1] eq "save") {
open(FH, ">$FHEMWEBdir/$a[2]") || return FHEMWEB_fatal("$a[2]: $!");
$a[2] =~ s,/,,g; # little bit of security
my $f = ($a[2] eq "fhem.cfg" ? $attr{global}{configfile} :
"$FHEMWEBdir/$a[2]");
if(!open(FH, ">$f")) {
pO "$f: $!";
return;
}
print FH $__data;
close(FH);
FHEMWEB_style("style list", "Saved file $a[2]");
FHEMWEB_style("style list", "Saved file $f");
$f = ($a[2] eq "fhem.cfg" ? $attr{global}{configfile} : $a[2]);
fC("rereadcfg") if($a[2] eq "fhem.cfg");
}
}
@ -1337,11 +1374,18 @@ fC($)
my $oll = $attr{global}{verbose};
$attr{global}{verbose} = 0 if($cmd ne "save");
my $ret = AnalyzeCommand(undef, $cmd);
if($cmd !~ m/attr.*global.*verbose/) {
$attr{global}{verbose} = $oll;
}
$attr{global}{verbose} = $oll if($cmd !~ m/attr.*global.*verbose/);
return $ret;
}
sub
FHEMWEB_getAttr($$)
{
my ($aname, $def) = @_;
return $attr{$__wname}{$aname}
if($attr{$__wname} && defined($attr{$__wname}{$aname}));
return $def;
}
1;

View File

@ -1,9 +1,8 @@
############################
# Display the power reported by the EM1010
# Corresponding FileLog definition:
# define ememlog FileLog /var/log/fhem/emem-%Y.log emem:power.*
#=================
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time

View File

@ -1,8 +1,8 @@
#
############################
# Display the measured temp and the actuator.
# FileLog definition:
# define FileLog fhtlog1 fht1:.*(temp|actuator).* /var/log/fht1-%Y-%U.log
#
# Corresponding FileLog definition:
# define fhtlog1 FileLog /var/log/fhem/fht1-%Y-%U.log fht1:.*(temp|actuator).*
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time

View File

@ -1,8 +1,8 @@
#
############################
# Display the on and off values off an FS20 device
# FileLog definition:
# define FileLog fs20log fs20dev /var/log/fs20dev-%Y-%U.log
#
# Corresponding FileLog definition:
# define fs20log FileLog /var/log/fhem/fs20dev-%Y-%U.log fs20dev
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time

View File

@ -1,8 +1,8 @@
#
# Display the Temperature and the humidity values of a KS300.
# FileLog definition:
# define FileLog ks300log ks300:.*H:.* /var/log/ks300-%Y-%U.log
#
############################
# Display the temperature and the humidity values of a KS300.
# Corresponding FileLog definition:
# define ks300log FileLog /var/log/fhem/ks300-%Y-%U.log ks300:.*H:.*
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time

View File

@ -1,8 +1,8 @@
#
############################
# Display the Wind and the Rain values of a KS300.
# FileLog definition:
# define FileLog ks300log ks300:.*H:.* /var/log/ks300-%Y-%U.log
#
# Corresponding FileLog definition:
# define ks300log FileLog /var/log/fhem/ks300-%Y-%U.log ks300:.*H:.*
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time

View File

@ -1,8 +1,8 @@
#
############################
# Display the Temperature and the humidity values of a KS300.
# FileLog definition:
# define FileLog ks300log ks300:.*H:.* /var/log/ks300-%Y-%U.log
#
# Corresponding FileLog definition:
# define ks300log FileLog /var/log/fhem/ks300-%Y-%U.log ks300:.*H:.*
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time

View File

@ -1,8 +1,9 @@
#
# Display a piri log with multiple units logging into the same file
# define pirilog FileLog /var/log/piri-%Y-%m-%d.log piri.*
############################
# Display a piri log with multiple units logging into the same file.
# Corresponding FileLog definition:
# define pirilog FileLog /var/log/fhem/piri-%Y-%m-%d.log piri.*
# The devices are called piri.sz, piri.flo, piri.flu, prir.wz1 and piri.wz2
#
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time

View File

@ -1,8 +1,8 @@
#
# Display the on and off values off an FS20 device
############################
# Display the on and off values for a single FS20 device
# FileLog definition:
# define FileLog fs20log fs20dev /var/log/fs20dev-%Y-%U.log
#
# define fs20log FileLog /var/log/fhem/fs20dev-%Y-%U.log fs20dev
set terminal png transparent size <SIZE> crop
set output '<OUT>.png'
set xdata time