From 848bd8d90228ef0ad16dbc6f93f6a9f0e532f7d6 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Fri, 9 Jan 2009 17:31:44 +0000 Subject: [PATCH] IODev attribute added git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@315 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 1 + FHEM/00_CM11.pm | 68 +++------------------------------ FHEM/00_CUL.pm | 90 ++++++-------------------------------------- FHEM/00_FHZ.pm | 84 ++--------------------------------------- FHEM/10_FS20.pm | 3 +- FHEM/11_FHT.pm | 4 +- FHEM/12_HMS.pm | 5 ++- FHEM/13_KS300.pm | 4 +- FHEM/14_CUL_WS.pm | 4 +- FHEM/15_CUL_EM.pm | 5 ++- FHEM/20_X10.pm | 4 +- FHEM/61_EMWZ.pm | 2 +- FHEM/62_EMEM.pm | 2 +- FHEM/63_EMGZ.pm | 2 +- HISTORY | 4 ++ docs/commandref.html | 22 ++++++++++- fhem.pl | 59 ++++++++++++++++++++++++++++- 17 files changed, 127 insertions(+), 236 deletions(-) diff --git a/CHANGED b/CHANGED index b0756e757..f59543230 100644 --- a/CHANGED +++ b/CHANGED @@ -475,4 +475,5 @@ - feature: 00_CUL: Answer CUR requests (status/time/fht) - bugfix: support for second correction factor for EMWZ in 15_CUL_EM added - feature: CUL further sets/gets added + - feature: Removed msghist for multiple FHZ handling, IODev attribute added - bugfix: cut off string "(counter)" from fallback value in 13_KS300.pm diff --git a/FHEM/00_CM11.pm b/FHEM/00_CM11.pm index 086f55a63..083d3308a 100755 --- a/FHEM/00_CM11.pm +++ b/FHEM/00_CM11.pm @@ -78,10 +78,6 @@ my %sets = ( "test" => "xxx", ); -my $def; -my %msghist; # Used when more than one CUL is attached -my $msgcount = 0; - ##################################### @@ -413,61 +409,6 @@ CM11_SetInterfaceTime($) return 1; } -##################################### -sub -CM11_Dispatch($$$$) -{ - my ($hash,$housecode,$unitcodes,$x10func)= @_; - - my $prefix= "CM11 device " . $hash->{NAME} . ":"; - my $iohash = $modules{$hash->{TYPE}}; # Our (CM11) module pointer - - $unitcodes= "" unless(defined($unitcodes)); - my $dmsg= "X10:$housecode;$unitcodes;$x10func"; - Log 5, "$prefix dispatch $dmsg"; - - my @found; - my $last_module; - my $nfound; - foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} } - grep {defined($modules{$_}{ORDER});}keys %modules) { - next if($iohash->{Clients} !~ m/:$m:/); - - # Module is not loaded or the message is not for this module - next if(!$modules{$m}{Match} || $dmsg !~ m/$modules{$m}{Match}/i); - - no strict "refs"; - @found = &{$modules{$m}{ParseFn}}($hash,$dmsg); - use strict "refs"; - $last_module = $m; - $nfound= int(@found); - last if($nfound); - } - # if the function was not evaluated, undef was returned - if(!$nfound) { - Log 1, "Unknown message $dmsg, help me!"; - return; - } - - foreach my $found (@found) { - if($found =~ m/^(UNDEFINED) ([^ ]*) (.*)$/) { - # The trigger needs a device: we create a minimal temporary one - my $d = $1; - $defs{$d}{NAME} = $1; - $defs{$d}{TYPE} = $last_module; - DoTrigger($d, "$2 $3"); - CommandDelete(undef, $d); # Remove the device - $nfound--; - } else { - DoTrigger($found, undef); - } - } - - Log 5, "$prefix $nfound devices addressed"; - return @found; - -} - ##################################### sub CM11_Read($) @@ -622,9 +563,12 @@ CM11_Read($) Log 5, "$prefix $housecode_func: " . $hash->{$housecode_func}; # dispatch message to clients - CM11_Dispatch($hash, $housecode, - $hash->{$housecode_unit}, - $hash->{$housecode_func}); + + my $hu = $hash->{$housecode_unit}; + $hu= "" unless(defined($hu)); + my $hf = $hash->{$housecode_func}; + my $dmsg= "X10:$housecode;$hu;$hf"; + Dispatch($hash, $dmsg); } else { # data byte is unitcode # if a command was executed before, clear unitcode list diff --git a/FHEM/00_CUL.pm b/FHEM/00_CUL.pm index fda7ee6d9..79d8d0b7c 100755 --- a/FHEM/00_CUL.pm +++ b/FHEM/00_CUL.pm @@ -14,8 +14,6 @@ sub CUL_Ready($); sub CUL_HandleCurRequest($$); my $initstr = "X21"; # Only translated messages + RSSI -my %msghist; # Used when more than one CUL is attached -my $msgcount = 0; my %gets = ( "version" => "V", "raw" => "", @@ -424,17 +422,6 @@ CUL_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 "F" || $fn eq "T") { - $msghist{$msgcount}{TIME} = gettimeofday(); - $msghist{$msgcount}{NAME} = $hash->{NAME}; - $msghist{$msgcount}{MSG} = "$fn$msg"; - $msgcount++; - } - Log 5, "CUL sending $fn$msg"; my $bstring = "$fn$msg\n"; @@ -490,7 +477,6 @@ CUL_Read($) my ($hash) = @_; my $buf = $hash->{PortObj}->input(); - my $iohash = $modules{$hash->{TYPE}}; # Our (CUL) module pointer my $name = $hash->{NAME}; ########### @@ -558,41 +544,15 @@ CUL_Read($) goto NEXTMSG; } - ############### - # check for duplicate msg from different CUL's - my $now = gettimeofday(); - my $skip; - my $meetoo = ($attr{$name}{repeater} ? 1 : 0); - - my $to = 0.3; - if(defined($attr{$name}) && defined($attr{$name}{filtertimeout})) { - $to = $attr{$name}{filtertimeout}; - } - foreach my $oidx (keys %msghist) { - if($now-$msghist{$oidx}{TIME} > $to) { - delete($msghist{$oidx}); - next; - } - if($msghist{$oidx}{MSG} eq $dmsg && - ($meetoo || $msghist{$oidx}{NAME} ne $name)) { - Log 5, "Skipping $msghist{$oidx}{MSG}"; - $skip = 1; - } - } - goto NEXTMSG if($skip); - $msghist{$msgcount}{TIME} = $now; - $msghist{$msgcount}{NAME} = $name; - $msghist{$msgcount}{MSG} = $dmsg; - $msgcount++; - - if($initstr =~ m/X2/ && $dmsg =~ m/[FEHT]([A-F0-9][A-F0-9])+$/) { # RSSI + my $rssi; + if($initstr =~ m/X2/ && $dmsg =~ m/[FEHTK]([A-F0-9][A-F0-9])+$/) { # RSSI my $l = length($dmsg); - my $rssi = hex(substr($dmsg, $l-2, 2)); + $rssi = hex(substr($dmsg, $l-2, 2)); $dmsg = substr($dmsg, 0, $l-2); $rssi = ($rssi>=128 ? (($rssi-256)/2-74) : ($rssi/2-74)); - Log GetLogLevel($name,4), "CUL: $dmsg $rssi"; + Log GetLogLevel($name,4), "$name: $dmsg $rssi"; } else { - Log GetLogLevel($name,4), "CUL: $dmsg"; + Log GetLogLevel($name,4), "$name: $dmsg"; } ########################################### @@ -639,42 +599,14 @@ CUL_Read($) goto NEXTMSG; } - - my @found; - my $last_module; - foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} } - grep {defined($modules{$_}{ORDER});}keys %modules) { - next if($iohash->{Clients} !~ m/:$m:/); - - # Module is not loaded or the message is not for this module - next if(!$modules{$m}{Match} || $dmsg !~ m/$modules{$m}{Match}/i); - - no strict "refs"; - @found = &{$modules{$m}{ParseFn}}($hash,$dmsg); - use strict "refs"; - $last_module = $m; - last if(int(@found)); - } - if(!int(@found)) { - Log GetLogLevel($name,3), "Unknown code $dmsg, help me!"; - goto NEXTMSG; + my @found = Dispatch($hash, $dmsg); + if($rssi) { + foreach my $d (@found) { + next if(!$defs{$d}); + $defs{$d}{RSSI} = $rssi; + } } - goto NEXTMSG if($found[0] eq ""); # Special return: Do not notify - - # The trigger needs a device: we create a minimal temporary one - if($found[0] =~ m/^(UNDEFINED) ([^ ]*) (.*)$/) { - my $d = $1; - $defs{$d}{NAME} = $1; - $defs{$d}{TYPE} = $last_module; - DoTrigger($d, "$2 $3"); - CommandDelete(undef, $d); # Remove the device - goto NEXTMSG; - } - - foreach my $found (@found) { - DoTrigger($found, undef); - } NEXTMSG: } $hash->{PARTIAL} = $culdata; diff --git a/FHEM/00_FHZ.pm b/FHEM/00_FHZ.pm index b198b2f0a..1f34e30bd 100755 --- a/FHEM/00_FHZ.pm +++ b/FHEM/00_FHZ.pm @@ -48,10 +48,6 @@ my %codes = ( "^8501..\$" => "fhtbuf", ); -my $def; -my %msghist; # Used when more than one FHZ is attached -my $msgcount = 0; - ##################################### # Note: we are a data provider _and_ a consumer at the same time sub @@ -355,7 +351,7 @@ FHZ_Parse($$) if(!$type) { Log 4, "FHZ $name unknown: $omsg"; - $def->{CHANGED}[0] = "$msg"; + $hash->{CHANGED}[0] = "$msg"; return $hash->{NAME}; } @@ -365,7 +361,7 @@ FHZ_Parse($$) } Log 4, "FHZ $name $type: $msg"; - $def->{CHANGED}[0] = "$type: $msg"; + $hash->{CHANGED}[0] = "$type: $msg"; return $hash->{NAME}; } @@ -498,18 +494,6 @@ 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") { - my $nmsg = "0101a001" . substr($msg, 6, 6) . "00" . substr($msg, 12); - $msghist{$msgcount}{TIME} = gettimeofday(); - $msghist{$msgcount}{NAME} = $hash->{NAME}; - $msghist{$msgcount}{MSG} = unpack('H*', FHZ_CompleteMsg($fn, $nmsg)); - $msgcount++; - } - my $bstring = FHZ_CompleteMsg($fn, $msg); Log 5, "Sending " . unpack('H*', $bstring); @@ -652,70 +636,8 @@ FHZ_Read($) $fhzdata = substr($fhzdata, 2); next; } + my @found = Dispatch($hash, $dmsg); - ############### - # check for duplicate msg from different FHZ's - my $now = gettimeofday(); - my $skip; - my $meetoo = ($attr{$name}{repeater} ? 1 : 0); - - my $to = 3; - if(defined($attr{$name}) && defined($attr{$name}{filtertimeout})) { - $to = $attr{$name}{filtertimeout}; - } - foreach my $oidx (keys %msghist) { - if($now-$msghist{$oidx}{TIME} > $to) { - delete($msghist{$oidx}); - next; - } - if($msghist{$oidx}{MSG} eq $dmsg && - ($meetoo || $msghist{$oidx}{NAME} ne $name)) { - Log 5, "Skipping $msghist{$oidx}{MSG}"; - $skip = 1; - } - } - goto NEXTMSG if($skip); - $msghist{$msgcount}{TIME} = $now; - $msghist{$msgcount}{NAME} = $name; - $msghist{$msgcount}{MSG} = $dmsg; - $msgcount++; - - - my @found; - my $last_module; - foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} } - grep {defined($modules{$_}{ORDER});}keys %modules) { - next if($iohash->{Clients} !~ m/:$m:/); - - # Module is not loaded or the message is not for this module - next if(!$modules{$m}{Match} || $dmsg !~ m/$modules{$m}{Match}/i); - - no strict "refs"; - @found = &{$modules{$m}{ParseFn}}($hash,$dmsg); - use strict "refs"; - $last_module = $m; - last if(int(@found)); - } - if(!int(@found)) { - Log 1, "Unknown code $dmsg, help me!"; - goto NEXTMSG; - } - - goto NEXTMSG if($found[0] eq ""); # Special return: Do not notify - - # The trigger needs a device: we create a minimal temporary one - if($found[0] =~ m/^(UNDEFINED) ([^ ]*) (.*)$/) { - my $d = $1; - $defs{$d}{NAME} = $1; - $defs{$d}{TYPE} = $last_module; - DoTrigger($d, "$2 $3"); - CommandDelete(undef, $d); # Remove the device - goto NEXTMSG; - } - - foreach my $found (@found) { - DoTrigger($found, undef); - } NEXTMSG: $fhzdata = substr($fhzdata, $len); diff --git a/FHEM/10_FS20.pm b/FHEM/10_FS20.pm index 0baa37eae..5cdb524a4 100755 --- a/FHEM/10_FS20.pm +++ b/FHEM/10_FS20.pm @@ -101,7 +101,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,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,fs20usr loglevel:0,1,2,3,4,5,6"; + $hash->{AttrList} = "IODev 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,fs20usr loglevel:0,1,2,3,4,5,6"; } @@ -345,6 +345,7 @@ 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 587fc80a7..e21a994c7 100755 --- a/FHEM/11_FHT.pm +++ b/FHEM/11_FHT.pm @@ -143,7 +143,7 @@ FHT_Initialize($) $hash->{DefFn} = "FHT_Define"; $hash->{UndefFn} = "FHT_Undef"; $hash->{ParseFn} = "FHT_Parse"; - $hash->{AttrList} = "do_not_notify:0,1 model;fht80b dummy:0,1 " . + $hash->{AttrList} = "IODev do_not_notify:0,1 model;fht80b dummy:0,1 " . "showtime:0,1 loglevel:0,1,2,3,4,5,6 retrycount minfhtbuffer"; } @@ -320,6 +320,8 @@ 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 1fc78b609..ad87ddb9e 100755 --- a/FHEM/12_HMS.pm +++ b/FHEM/12_HMS.pm @@ -39,7 +39,7 @@ HMS_Initialize($) $hash->{DefFn} = "HMS_Define"; $hash->{UndefFn} = "HMS_Undef"; $hash->{ParseFn} = "HMS_Parse"; - $hash->{AttrList} = "do_not_notify:0,1 showtime:0,1 model;hms100-t,hms100-tf,hms100-wd,hms100-mg,hms100-tfk,rm100-2,hms100-co,hms100-fit loglevel:0,1,2,3,4,5,6"; + $hash->{AttrList} = "IODev do_not_notify:0,1 showtime:0,1 model;hms100-t,hms100-tf,hms100-wd,hms100-mg,hms100-tfk,rm100-2,hms100-co,hms100-fit loglevel:0,1,2,3,4,5,6"; } ##################################### @@ -78,6 +78,8 @@ HMS_Parse($$) my $dev = substr($msg, 16, 4); my $cde = substr($msg, 11, 1); + 012345678901234567890123456789 +# 810e047f0214a001a81f000001000000 HMS100TFK my $val = substr($msg, 24, 8) if(length($msg) == 32); my $type = ""; @@ -103,6 +105,7 @@ HMS_Parse($$) } my $def = $defptr{$dev}; + return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); my (@v, @txt, @sfx); diff --git a/FHEM/13_KS300.pm b/FHEM/13_KS300.pm index 2f0aa8f44..7bbd01f6f 100755 --- a/FHEM/13_KS300.pm +++ b/FHEM/13_KS300.pm @@ -20,7 +20,7 @@ KS300_Initialize($) $hash->{DefFn} = "KS300_Define"; $hash->{UndefFn} = "KS300_Undef"; $hash->{ParseFn} = "KS300_Parse"; - $hash->{AttrList} = "do_not_notify:0,1 showtime:0,1 model:ks300 loglevel:0,1 rainadjustment:0,1"; + $hash->{AttrList} = "IODev do_not_notify:0,1 showtime:0,1 model:ks300 loglevel:0,1 rainadjustment:0,1"; } ##################################### @@ -89,6 +89,8 @@ 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 95c7d9508..c72077e18 100755 --- a/FHEM/14_CUL_WS.pm +++ b/FHEM/14_CUL_WS.pm @@ -27,7 +27,7 @@ CUL_WS_Initialize($) $hash->{DefFn} = "CUL_WS_Define"; $hash->{UndefFn} = "CUL_WS_Undef"; $hash->{ParseFn} = "CUL_WS_Parse"; - $hash->{AttrList} = "do_not_notify:0,1 showtime:0,1 model:S300TH,KS300 loglevel"; + $hash->{AttrList} = "IODev do_not_notify:0,1 showtime:0,1 model:S300TH,KS300 loglevel"; } @@ -85,6 +85,8 @@ CUL_WS_Parse($$) Log 1, "CUL_WS UNDEFINED $type sensor detected, code $cde"; return "UNDEFINED CUL_WS: $cde"; } + my $def = $defptr{$cde}; + return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); $hash = $defptr{$cde}; my $name = $hash->{NAME}; diff --git a/FHEM/15_CUL_EM.pm b/FHEM/15_CUL_EM.pm index 43ebdf76e..c95caa0d0 100755 --- a/FHEM/15_CUL_EM.pm +++ b/FHEM/15_CUL_EM.pm @@ -19,7 +19,7 @@ CUL_EM_Initialize($) $hash->{DefFn} = "CUL_EM_Define"; $hash->{UndefFn} = "CUL_EM_Undef"; $hash->{ParseFn} = "CUL_EM_Parse"; - $hash->{AttrList} = "do_not_notify:0,1 showtime:0,1 model:EMEM,EMWZ,EMGZ loglevel"; + $hash->{AttrList} = "IODev do_not_notify:0,1 showtime:0,1 model:EMEM,EMWZ,EMGZ loglevel"; } ##################################### @@ -101,6 +101,9 @@ CUL_EM_Parse($$) $seqno, $total_cnt, $current_cnt, $peak_cnt); if($defptr{$cde}) { + my $def = $defptr{$cde}; + return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); + $hash = $defptr{$cde}; my $tn = TimeNow(); # current time diff --git a/FHEM/20_X10.pm b/FHEM/20_X10.pm index fb2f02aef..0777f6d88 100755 --- a/FHEM/20_X10.pm +++ b/FHEM/20_X10.pm @@ -104,8 +104,7 @@ X10_Initialize($) $hash->{DefFn} = "X10_Define"; $hash->{UndefFn} = "X10_Undef"; $hash->{ParseFn} = "X10_Parse"; - $hash->{AttrList} = "follow-on-for-timer:1,0 do_not_notify:1,0 dummy:1,0 -showtime:1,0 model:lm12,lm15,am12,tm13 loglevel:0,1,2,3,4,5,6"; + $hash->{AttrList} = "IODev follow-on-for-timer:1,0 do_not_notify:1,0 dummy:1,0 showtime:1,0 model:lm12,lm15,am12,tm13 loglevel:0,1,2,3,4,5,6"; } @@ -349,6 +348,7 @@ X10_Parse($$) foreach my $unitcode (@unitcodes) { my $h= $devices{$housecode}{$unitcode}; if($h) { + return "" if($h->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME}); my $name= $h->{NAME}; $h->{CHANGED}[0] = $value; $h->{STATE} = $value; diff --git a/FHEM/61_EMWZ.pm b/FHEM/61_EMWZ.pm index aa794c688..2396daec0 100755 --- a/FHEM/61_EMWZ.pm +++ b/FHEM/61_EMWZ.pm @@ -20,7 +20,7 @@ EMWZ_Initialize($) $hash->{SetFn} = "EMWZ_Set"; $hash->{DefFn} = "EMWZ_Define"; - $hash->{AttrList} = "dummy:1,0 model;EM1000WZ loglevel:0,1,2,3,4,5,6"; + $hash->{AttrList} = "IODev dummy:1,0 model;EM1000WZ loglevel:0,1,2,3,4,5,6"; } diff --git a/FHEM/62_EMEM.pm b/FHEM/62_EMEM.pm index ac465bb46..a30a260c8 100755 --- a/FHEM/62_EMEM.pm +++ b/FHEM/62_EMEM.pm @@ -18,7 +18,7 @@ EMEM_Initialize($) $hash->{GetFn} = "EMEM_Get"; $hash->{DefFn} = "EMEM_Define"; - $hash->{AttrList} = "dummy:1,0 model;EM1000EM loglevel:0,1,2,3,4,5,6"; + $hash->{AttrList} = "IODev dummy:1,0 model;EM1000EM loglevel:0,1,2,3,4,5,6"; } ################################### diff --git a/FHEM/63_EMGZ.pm b/FHEM/63_EMGZ.pm index e2cb41399..6ec588fc5 100644 --- a/FHEM/63_EMGZ.pm +++ b/FHEM/63_EMGZ.pm @@ -20,7 +20,7 @@ EMGZ_Initialize($) $hash->{SetFn} = "EMGZ_Set"; $hash->{DefFn} = "EMGZ_Define"; - $hash->{AttrList} = "dummy:1,0 model;EM1000GZ loglevel:0,1,2,3,4,5,6"; + $hash->{AttrList} = "IODev dummy:1,0 model;EM1000GZ loglevel:0,1,2,3,4,5,6"; } diff --git a/HISTORY b/HISTORY index eddeeb038..6a61519ce 100644 --- a/HISTORY +++ b/HISTORY @@ -367,3 +367,7 @@ is sent back. The CUR must have reception enabled. Right now status/set time/set FHT desired temp are implemented. +- Fri Jan 9 + - Added a unified dispatch for CUL/FHZ and CM11, since all of them used the + same code. + - Addedd IODev attribute to FS20/FHT/HMS/KS300/CUL_WS/CUL/EMWZ/EMGZ/EMEM diff --git a/docs/commandref.html b/docs/commandref.html index a10a78191..b7a8ad754 100644 --- a/docs/commandref.html +++ b/docs/commandref.html @@ -1134,17 +1134,27 @@ A line ending with \ will be concatenated with the next one, so long lines Get
+ Attributes @@ -1588,6 +1600,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • showtime

  • loglevel

  • model (S300,KS300,WS7000)

  • +
  • IODev


  • @@ -1628,6 +1641,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • showtime

  • loglevel

  • model (EMEM,EMWZ,EMGZ)

  • +
  • IODev


  • @@ -1744,6 +1758,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • model (EM1000WZ)
  • dummy
  • loglevel
  • +
  • IODev


  • @@ -1797,6 +1812,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • model (EM1000GZ)
  • dummy
  • loglevel
  • +
  • IODev


  • @@ -1843,6 +1859,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • model (EM1000EM)
  • dummy
  • loglevel
  • +
  • IODev


  • @@ -2052,6 +2069,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • showtime

  • model (lm12,lm15,am12,tm13)

  • loglevel
  • +
  • IODev


  • diff --git a/fhem.pl b/fhem.pl index de872d654..7512f1a80 100755 --- a/fhem.pl +++ b/fhem.pl @@ -46,6 +46,7 @@ sub AssignIoPort($); sub CallFn(@); sub CommandChain($$); sub DoClose($); +sub Dispatch($$); sub FmtDateTime($); sub FmtTime($); sub GetLogLevel(@); @@ -148,7 +149,7 @@ my %intAt; # Internal at timer hash. my $nextat; # Time when next timer will be triggered. my $intAtCnt=0; my $AttrList = "room comment"; -my $cvsid = '$Id: fhem.pl,v 1.62 2009-01-03 12:30:29 rudolfkoenig Exp $'; +my $cvsid = '$Id: fhem.pl,v 1.63 2009-01-09 17:31:43 rudolfkoenig Exp $'; my $namedef = "where is either:\n" . "- a single device name\n" . @@ -1415,6 +1416,11 @@ CommandAttr($$) next; } + if($a[1] eq "IODev" && (!$a[2] || !defined($defs{$a[2]}))) { + push @rets,"Unknown IODev specified"; + next; + } + $a[0] = $sdev; $ret = CallFn($sdev, "AttrFn", "set", @a); if($ret) { @@ -1427,6 +1433,7 @@ CommandAttr($$) } else { $attr{$sdev}{$a[1]} = "1"; } + $defs{$sdev}{IODev} = $defs{$a[2]} if($a[1] eq "IODev"); } return join("\n", @rets); @@ -1942,3 +1949,53 @@ HandleArchiving($) } } +##################################### +# Call a logical device (FS20) ParseMessage with data from a physical device +# (FHZ) +sub +Dispatch($$) +{ + my ($hash, $dmsg) = @_; + my $iohash = $modules{$hash->{TYPE}}; # The phyiscal device module pointer + my $name = $hash->{NAME}; + + Log 5, "$name dispatch $dmsg"; + + my @found; + my $last_module; + foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} } + grep {defined($modules{$_}{ORDER});}keys %modules) { + next if($iohash->{Clients} !~ m/:$m:/); + + # Module is not loaded or the message is not for this module + next if(!$modules{$m}{Match} || $dmsg !~ m/$modules{$m}{Match}/i); + + no strict "refs"; + @found = &{$modules{$m}{ParseFn}}($hash,$dmsg); + use strict "refs"; + $last_module = $m; + last if(int(@found)); + } + if(!int(@found)) { + Log GetLogLevel($name,3), "$name: Unknown code $dmsg, help me!"; + return ""; + } + + return if($found[0] eq ""); # Special return: Do not notify + + foreach my $found (@found) { + if($found =~ m/^(UNDEFINED) ([^ ]*) (.*)$/) { + # The trigger needs a device: we create a minimal temporary one + my $d = $1; + $defs{$d}{NAME} = $1; + $defs{$d}{TYPE} = $last_module; + DoTrigger($d, "$2 $3"); + CommandDelete(undef, $d); # Remove the device + goto NEXTMSG; + } else { + DoTrigger($found, undef); + } + } + + return @found; +}