From 443f0de25f0586970d459c3507bfcf8cac587537 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Thu, 24 May 2007 11:30:25 +0000 Subject: [PATCH] Added FS20S8, removed stty_parmrk (Debian does not have it), FileLog Archiving continued. git-svn-id: https://svn.fhem.de/fhem/trunk@62 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/00_FHZ.pm | 2 +- fhem/FHEM/10_FS20.pm | 2 +- fhem/FHEM/92_FileLog.pm | 49 ++++++++++++++++++++++++++++++++++++--- fhem/docs/commandref.html | 16 ++++++++++--- fhem/docs/faq.html | 14 +++++++++-- fhem/docs/raw-codes | 5 +++- fhem/test/fhem.save | 4 ++-- 8 files changed, 80 insertions(+), 13 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 095b2564e..698779944 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -330,3 +330,4 @@ - feature: The "-" in the name is not allowed any more - bugfix: disabled notify causes "uninitialized value" (STefan, 1.5) - bugfix: deleted FS20 items are still logging (zombie) (Gerhard, 16.5) + - bugfix: added FS20S8, removed stty_parmrk (Martin, 24.5) diff --git a/fhem/FHEM/00_FHZ.pm b/fhem/FHEM/00_FHZ.pm index 5af76e7e9..ab19199b9 100755 --- a/fhem/FHEM/00_FHZ.pm +++ b/fhem/FHEM/00_FHZ.pm @@ -227,7 +227,7 @@ FHZ_Define($$) # settings. Device::SerialPort is nice: if the flag is not defined for your # OS then it will be ignored. $po->stty_icanon(0); - $po->stty_parmrk(0); + #$po->stty_parmrk(0); # The debian standard install does not have it $po->stty_icrnl(0); $po->stty_echoe(0); $po->stty_echok(0); diff --git a/fhem/FHEM/10_FS20.pm b/fhem/FHEM/10_FS20.pm index d52580eb9..b088f10b2 100755 --- a/fhem/FHEM/10_FS20.pm +++ b/fhem/FHEM/10_FS20.pm @@ -100,7 +100,7 @@ FS20_Initialize($) $hash->{DefFn} = "FS20_Define"; $hash->{UndefFn} = "FS20_Undef"; $hash->{ParseFn} = "FS20_Parse"; - $hash->{AttrList} = "follow-on-for-timer:1,0 do_not_notify:1,0 dummy:1,0 showtime:1,0 model;fs20hgs,fs20hgs,fs20pira,fs20piri,fs20s20,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 loglevel:0,1,2,3,4,5,6"; + $hash->{AttrList} = "follow-on-for-timer:1,0 do_not_notify:1,0 dummy:1,0 showtime:1,0 model;fs20hgs,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 loglevel:0,1,2,3,4,5,6"; } diff --git a/fhem/FHEM/92_FileLog.pm b/fhem/FHEM/92_FileLog.pm index 42c3edba3..d4b361463 100755 --- a/fhem/FHEM/92_FileLog.pm +++ b/fhem/FHEM/92_FileLog.pm @@ -15,7 +15,8 @@ FileLog_Initialize($) $hash->{UndefFn} = "FileLog_Undef"; $hash->{NotifyFn} = "FileLog_Log"; $hash->{AttrFn} = "FileLog_Attr"; - $hash->{AttrList} = "disable:0,1 logtype nrarchive archivedir"; + # logtype is used by the frontend + $hash->{AttrList} = "disable:0,1 logtype nrarchive archivedir archivecmd"; } @@ -59,6 +60,47 @@ sub HandleArchiving($) { my ($log) = @_; + my $ln = $log->{NAME}; + return if(!$attr{$ln}); + + # If there is a command, call that + my $cmd = $attr{$ln}{archivecmd}; + if($cmd) { + $cmd =~ s/%/$log->{CURRENT}/g; + Log 2, "Archive: calling $cmd"; + system($cmd); + return; + } + + my $nra = $attr{$ln}{nrarchive}; + my $ard = $attr{$ln}{archivedir}; + return if(!defined($nra)); + + # If nrarchive is set, then check the last files: + # Get a list of files: + + my ($dir, $file); + if($log->{FILENAME} =~ m,^(.+)/([^/]+)$,) { + ($dir, $file) = ($1, $2); + } else { + ($dir, $file) = (".", $log->{FILENAME}); + } + + $file =~ s/%./.+/g; + return if(!opendir(DH, $dir)); + my @files = sort grep {/^$file$/} readdir(DH); + closedir(DH); + + my $max = int(@files)-$nra; + for(my $i = 0; $i < $max; $i++) { + if($ard) { + Log 2, "Moving $files[$i] to $ard"; + rename("$dir/$files[$i]", "$ard/$files[$i]"); + } else { + Log 2, "Deleting $files[$i]"; + unlink("$dir/$files[$i]"); + } + } } ##################################### @@ -74,11 +116,12 @@ FileLog_Log($$) my $n = $dev->{NAME}; my $re = $log->{REGEXP}; my $max = int(@{$dev->{CHANGED}}); - for (my $i = 0; $i < $max; $i++) { my $s = $dev->{CHANGED}[$i]; +Log 1, "FL: Checking $n:$s against $re"; $s = "" if(!defined($s)); if($n =~ m/^$re$/ || "$n:$s" =~ m/^$re$/) { +Log 1, "FL: Logging"; my $t = TimeNow(); $t = $dev->{CHANGETIME}[$i] if(defined($dev->{CHANGETIME}[$i])); $t =~ s/ /_/; # Makes it easier to parse with gnuplot @@ -88,8 +131,8 @@ FileLog_Log($$) my $cn = ResolveDateWildcards($log->{FILENAME}, @t); if($cn ne $log->{CURRENT}) { # New logfile - HandleArchiving($log); $fh->close(); + HandleArchiving($log); $fh = new IO::File ">>$cn"; if(!defined($fh)) { Log(0, "Can't open $cn"); diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index c239205ea..e7b4f008d 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -144,8 +144,11 @@ split in multiple lines

If this attribute is set, then the last command of the generated configfile (see the save command) will be
include <lastinclude-value>
- This file can contain not configurable information, e.g. - setting the FHTcode. + This file is needed, as the save command will write only defines and + attributes to the config file, any other commands / includes will be + lost. E.g. it makes sense to set the FHTcode in + this file or the coordinates of your house via + sunrise_coord
@@ -354,6 +357,7 @@ split in multiple lines

fs20pira fs20piri fs20s20 + fs20s8 fs20s4 fs20s4a fs20s4m @@ -1054,7 +1058,13 @@ split in multiple lines



Save first the statefile, then the configfile information. If a parameter is specified, - it will be used instead the global configfile attribute.
+ it will be used instead the global configfile attribute.

+ Notes: + diff --git a/fhem/docs/faq.html b/fhem/docs/faq.html index d51edd5c0..15638c22f 100644 --- a/fhem/docs/faq.html +++ b/fhem/docs/faq.html @@ -112,7 +112,7 @@ start @@ -251,7 +251,17 @@ by fhem.pl? restart the program. If everything is ok, typing
{ sunrise_abs() }
in the telnet prompt, will return the time of the sunrise today, in a - HH:MM:SS format. + HH:MM:SS format.

+ + Note: As fhem.cfg will be overwritten if you use the save command, + it is better to put the sunrise_coord command in the "lastinclude" file, + e.g. /home/fhem/fhem.cfg.static. This file will be read, if you set the + lastinclude attribute:

+ + attr global lastinclude /home/fhem/fhem.cfg.static


+ + and will not be overwritten by save. + diff --git a/fhem/docs/raw-codes b/fhem/docs/raw-codes index ae160117a..e0bd46f9d 100644 --- a/fhem/docs/raw-codes +++ b/fhem/docs/raw-codes @@ -1,5 +1,8 @@ On the telnet prompt do: - {FhzDecode("")} + {FS20_Parse(undef, "");} +e.g. + {FS20_Parse(undef, "81xx04xx0101a0011234030011")} + where is one of: 81xx04xx0101a0011234030011 FS20 dev: 1234 button: 03 on (11) diff --git a/fhem/test/fhem.save b/fhem/test/fhem.save index 3081d36de..364074cf9 100644 --- a/fhem/test/fhem.save +++ b/fhem/test/fhem.save @@ -1,10 +1,10 @@ -#Tue May 1 17:03:03 2007 +#Sat May 19 18:46:13 2007 setstate FHZ fhtbuf: 1c setstate FHZ 2006-02-12 14:03:39 fhtbuf 23 setstate FHZ 2006-03-26 08:47:36 init2 deadbeefdeadbe setstate FHZ 2006-03-26 08:47:36 serial deadbeef setstate btn4 on -setstate btn4 2006-04-12 15:19:33 state on +setstate btn4 2007-05-17 16:58:46 state on setstate cellar on-for-timer 2 setstate cellar 2007-04-22 14:04:12 state on-for-timer 2 setstate fl measured-temp: 21.6 (Celsius)