diff --git a/CHANGED b/CHANGED index d42ae0d5d..abfd6ce33 100644 --- a/CHANGED +++ b/CHANGED @@ -536,4 +536,5 @@ - bugfix: loosing data when sending FS20 messages in a group - bugfix: better handling of disconnected CUN - feature: softfhtbuffer added to CUL - - bugfix: pgm3: Pulldown-Menu without selected FHTDEV not possible any more + - bugfix: pgm3: Pulldown-Menu without selected FHTDEV not possible any more + - feature: duplicate buffer added for multi-cul/-fhz setups diff --git a/FHEM/00_CUL.pm b/FHEM/00_CUL.pm index b463dd2d6..b84c94866 100755 --- a/FHEM/00_CUL.pm +++ b/FHEM/00_CUL.pm @@ -73,7 +73,7 @@ CUL_Initialize($) $hash->{GetFn} = "CUL_Get"; $hash->{SetFn} = "CUL_Set"; $hash->{StateFn} = "CUL_SetState"; - $hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 filtertimeout " . + $hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 " . "showtime:1,0 model:CUL,CUR loglevel:0,1,2,3,4,5,6 " . "CUR_id_list fhtsoftbuffer:1,0"; $hash->{ShutdownFn} = "CUL_Shutdown"; @@ -573,6 +573,8 @@ CUL_Write($$$) } elsif($fn eq "04" && substr($msg,0,6) eq "010101") { # FS20 $fn = "F"; + AddDuplicate($hash->{NAME}, + "0101a001" . substr($msg, 6, 6) . "00" . substr($msg, 12)); $msg = substr($msg,6); } elsif($fn eq "04" && substr($msg,0,6) eq "020183") { # FHT @@ -759,8 +761,9 @@ CUL_Read($) if($foundp) { foreach my $d (@{$foundp}) { next if(!$defs{$d}); - $defs{$d}{RSSI} = $rssi if($rssi); + $defs{$d}{"RSSI_$name"} = $rssi if($rssi); $defs{$d}{RAWMSG} = $rmsg; + $defs{$d}{"MSGCNT_$name"}++; } } diff --git a/FHEM/00_FHZ.pm b/FHEM/00_FHZ.pm index 893a33c84..f99dfbb95 100755 --- a/FHEM/00_FHZ.pm +++ b/FHEM/00_FHZ.pm @@ -79,7 +79,7 @@ FHZ_Initialize($) $hash->{GetFn} = "FHZ_Get"; $hash->{SetFn} = "FHZ_Set"; $hash->{StateFn} = "FHZ_SetState"; - $hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 filtertimeout repeater:1,0 " . + $hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 " . "showtime:1,0 model:fhz1000,fhz1300 loglevel:0,1,2,3,4,5,6 ". "fhtsoftbuffer:1,0"; } @@ -542,6 +542,16 @@ FHZ_Write($$$) return; } + ############### + # insert value into the msghist. At the moment this only makes sense for FS20 + # devices. As the transmitted value differs from the received one, we have to + # recompute. + if($fn eq "04" && substr($msg,0,6) eq "010101") { + AddDuplicate($hash->{NAME}, + "0101a001" . substr($msg, 6, 6) . "00" . substr($msg, 12)); + } + + my $bstring = FHZ_CompleteMsg($fn, $msg); Log 5, "Sending " . unpack('H*', $bstring); @@ -689,6 +699,7 @@ FHZ_Read($) foreach my $d (@{$foundp}) { next if(!$defs{$d}); $defs{$d}{RAWMSG} = $dmsg; + $defs{$d}{"MSGCNT_$name"}++; } } diff --git a/FHEM/09_BS.pm b/FHEM/09_BS.pm index 620a9e4bc..ccf9ef441 100644 --- a/FHEM/09_BS.pm +++ b/FHEM/09_BS.pm @@ -89,8 +89,6 @@ BS_Parse($$) my $name= $def->{NAME}; - return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); - my $t= TimeNow(); my $flags= hex(substr($msg, 24, 1)) & 0xdc; diff --git a/FHEM/09_USF1000.pm b/FHEM/09_USF1000.pm index d88feb982..658ea1d7f 100644 --- a/FHEM/09_USF1000.pm +++ b/FHEM/09_USF1000.pm @@ -98,9 +98,6 @@ USF1000_Parse($$) my $def= $defptr{$dev}; my $name= $def->{NAME}; - return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); - - my $t= TimeNow(); # Msg format: diff --git a/FHEM/10_FS20.pm b/FHEM/10_FS20.pm index 34058a2ef..0923b6352 100755 --- a/FHEM/10_FS20.pm +++ b/FHEM/10_FS20.pm @@ -354,7 +354,6 @@ FS20_Parse($$) my @list; foreach my $n (keys %{ $def }) { my $lh = $def->{$n}; - return "" if($lh->{IODev} && $lh->{IODev}{NAME} ne $hash->{NAME}); $lh->{CHANGED}[0] = $v; $lh->{STATE} = $v; $lh->{READINGS}{state}{TIME} = TimeNow(); diff --git a/FHEM/11_FHT.pm b/FHEM/11_FHT.pm index 0b42c85e4..4e6b6ee46 100755 --- a/FHEM/11_FHT.pm +++ b/FHEM/11_FHT.pm @@ -167,8 +167,6 @@ FHT_Set($@) if($a[$i] eq "time") { my @t = localtime; splice(@a,$i,1,("hour",$t[2],"minute",$t[1])); - IOWrite($hash, "", sprintf("T04%x", $t[0])) # CUL hack - if($hash->{IODev} && $hash->{IODev}->{TYPE} eq "CUL"); } } @@ -348,8 +346,6 @@ FHT_Parse($$) my $def = $defptr{$dev}; my $name = $def->{NAME}; - return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); - # Short message if(length($msg) < 26) { Log 4,"FHT Short message. Device $name, Message: $msg"; diff --git a/FHEM/12_HMS.pm b/FHEM/12_HMS.pm index b8c4f30ba..d2afa224d 100755 --- a/FHEM/12_HMS.pm +++ b/FHEM/12_HMS.pm @@ -106,7 +106,6 @@ HMS_Parse($$) } my $def = $defptr{$dev}; - return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); my (@v, @txt); diff --git a/FHEM/13_KS300.pm b/FHEM/13_KS300.pm index a1815393f..3ceaa739b 100755 --- a/FHEM/13_KS300.pm +++ b/FHEM/13_KS300.pm @@ -89,8 +89,6 @@ KS300_Parse($$) my $haverain = 0; my $name= $def->{NAME}; - return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); - my @v; my @txt = ( "rain_raw", "rain", "wind", "humidity", "temperature", "israining", "unknown1", "unknown2", "unknown3"); diff --git a/FHEM/14_CUL_WS.pm b/FHEM/14_CUL_WS.pm index 10ea89fab..2bb1e805e 100755 --- a/FHEM/14_CUL_WS.pm +++ b/FHEM/14_CUL_WS.pm @@ -95,10 +95,6 @@ CUL_WS_Parse($$) return "UNDEFINED CUL_WS: $cde"; } - # It's not our device - return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); - - my $tm=TimeNow(); $hash = $def; diff --git a/FHEM/15_CUL_EM.pm b/FHEM/15_CUL_EM.pm index 3e602a61e..6096e3040 100755 --- a/FHEM/15_CUL_EM.pm +++ b/FHEM/15_CUL_EM.pm @@ -107,7 +107,6 @@ CUL_EM_Parse($$) if($defptr{$cde}) { my $def = $defptr{$cde}; - return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); $hash = $defptr{$cde}; diff --git a/FHEM/20_X10.pm b/FHEM/20_X10.pm index e6c102293..985f74d26 100755 --- a/FHEM/20_X10.pm +++ b/FHEM/20_X10.pm @@ -348,7 +348,6 @@ X10_Parse($$) foreach my $unitcode (@unitcodes) { my $h= $devices{$housecode}{$unitcode}; if($h) { - return "" if($h->{IODev} && $h->{IODev}{NAME} ne $hash->{NAME}); my $name= $h->{NAME}; $h->{CHANGED}[0] = $value; $h->{STATE} = $value; diff --git a/HISTORY b/HISTORY index 2d78bb16a..ccebbd7ec 100644 --- a/HISTORY +++ b/HISTORY @@ -431,8 +431,16 @@ - bugfix: missing blank in attribute list for FHT; exclude report from lazy - typos and anchors in documentation corrected - - Sun Oct11 2009 (Boris) +- Sun Oct 11 2009 (Boris) - finalized 09_BS.pm and documentation -- Tue Nov10 2009 (Martin Haas) - - Bugfix: pgm3: Pulldown-Menu without selected FHTDEV not possible any more +- Tue Nov 10 2009 (Martin Haas) + - Bugfix: pgm3: Pulldown-Menu without selected FHTDEV not possible any more + +- Thu Nov 12 2009 (Rudi) + - The duplicate pool added. The check routine is called from the Dispatch + routine (so it will affecc CUL/FHZ and CM11), and for FS20 calls from + the CUL and FHZ Write function. + Duplicates within 0.5 seconds are filtered if they are not reported by the + same IO Unit. Existing check for IODev removed from BS USF1000 FS20 FHT HMS + KS300 CUL_WS CUL_EM X10. diff --git a/TODO b/TODO index 558de035e..4effbef11 100644 --- a/TODO +++ b/TODO @@ -1,11 +1,6 @@ FHEM: -- RAWTIME - -- Remote serial device via IP (for the FHZ1300 WLAN) -- Common buffer for parallel use of two devices: CUL+FHZ, (WS300/EM1000PC?) - fhem-to-fhem module - CUR built-in MENU creation support -- Remove or reimplement repeater attribute (cul/fhz/doc) Webpgm2 - plot data from multiple files in a single picture diff --git a/fhem.pl b/fhem.pl index 8c45888ea..d5df6260b 100755 --- a/fhem.pl +++ b/fhem.pl @@ -39,12 +39,14 @@ use Time::HiRes qw(gettimeofday); ################################################## # Forward declarations # +sub AddDuplicate($$); sub AnalyzeCommand($$); sub AnalyzeCommandChain($$); sub AnalyzeInput($); sub AssignIoPort($); sub CallFn(@); sub CommandChain($$); +sub CheckDuplicate($$); sub DoClose($); sub Dispatch($$); sub FmtDateTime($); @@ -151,7 +153,9 @@ my %defaultattr; # Default attributes my %intAt; # Internal at timer hash. my $nextat; # Time when next timer will be triggered. my $intAtCnt=0; -my $cvsid = '$Id: fhem.pl,v 1.81 2009-11-08 14:18:06 rudolfkoenig Exp $'; +my %duplicate; # Pool of received msg for multi-fhz/cul setups +my $duplidx=0; # helper for the above pool +my $cvsid = '$Id: fhem.pl,v 1.82 2009-11-12 19:08:00 rudolfkoenig Exp $'; my $namedef = "where is either:\n" . "- a single device name\n" . @@ -175,7 +179,7 @@ $modules{_internal_}{AttrFn} = "GlobalAttr"; "?" => { Fn=>"CommandHelp", Hlp=>",get this help" }, "attr" => { Fn=>"CommandAttr", - Hlp=>" [],set attribute for " }, + Hlp=>" [],set attribute for "}, "define" => { Fn=>"CommandDefine", Hlp=>" ,define a device/at/notify entity" }, "deleteattr" => { Fn=>"CommandDeleteAttr", @@ -2041,6 +2045,9 @@ Dispatch($$) Log 5, "$name dispatch $dmsg"; + my ($isdup, $idx) = CheckDuplicate($name, $dmsg); + return $duplicate{$idx}{FND} if($isdup); + my @found; my $last_module; foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} } @@ -2056,6 +2063,7 @@ Dispatch($$) $last_module = $m; last if(int(@found)); } + if(!int(@found)) { my $h = $iohash->{MatchList}; if(defined($h)) { @@ -2088,6 +2096,44 @@ Dispatch($$) DoTrigger($found, undef); } } + $duplicate{$idx}{FND} = \@found; return \@found; } + +sub +CheckDuplicate($$) +{ + my ($ioname, $msg) = @_; + + # Store only the "relevant" part, as the CUL won't compute the checksum + $msg = substr($msg, 8) if($msg =~ m/^81/ && length($msg) > 8); + + my $now = gettimeofday(); + my $lim = $now-0.5; + + foreach my $oidx (keys %duplicate) { + if($duplicate{$oidx}{TIM} < $lim) { + delete($duplicate{$oidx}); + + } elsif($duplicate{$oidx}{MSG} eq $msg && + $duplicate{$oidx}{ION} ne $ioname) { + return (1, $oidx); + + } + } + $duplicate{$duplidx}{ION} = $ioname; + $duplicate{$duplidx}{MSG} = $msg; + $duplicate{$duplidx}{TIM} = $now; + $duplidx++; + return (0, $duplidx-1); +} + +sub +AddDuplicate($$) +{ + $duplicate{$duplidx}{ION} = shift; + $duplicate{$duplidx}{MSG} = shift; + $duplicate{$duplidx}{TIM} = gettimeofday(); + $duplidx++; +}