2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

IODev attribute added

git-svn-id: https://svn.fhem.de/fhem/trunk@315 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2009-01-09 17:31:44 +00:00
parent 0a3aa137ce
commit df50881fc7
17 changed files with 127 additions and 236 deletions

View File

@ -475,4 +475,5 @@
- feature: 00_CUL: Answer CUR requests (status/time/fht) - feature: 00_CUL: Answer CUR requests (status/time/fht)
- bugfix: support for second correction factor for EMWZ in 15_CUL_EM added - bugfix: support for second correction factor for EMWZ in 15_CUL_EM added
- feature: CUL further sets/gets 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 - bugfix: cut off string "(counter)" from fallback value in 13_KS300.pm

View File

@ -78,10 +78,6 @@ my %sets = (
"test" => "xxx", "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; 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 sub
CM11_Read($) CM11_Read($)
@ -622,9 +563,12 @@ CM11_Read($)
Log 5, "$prefix $housecode_func: " . Log 5, "$prefix $housecode_func: " .
$hash->{$housecode_func}; $hash->{$housecode_func};
# dispatch message to clients # dispatch message to clients
CM11_Dispatch($hash, $housecode,
$hash->{$housecode_unit}, my $hu = $hash->{$housecode_unit};
$hash->{$housecode_func}); $hu= "" unless(defined($hu));
my $hf = $hash->{$housecode_func};
my $dmsg= "X10:$housecode;$hu;$hf";
Dispatch($hash, $dmsg);
} else { } else {
# data byte is unitcode # data byte is unitcode
# if a command was executed before, clear unitcode list # if a command was executed before, clear unitcode list

View File

@ -14,8 +14,6 @@ sub CUL_Ready($);
sub CUL_HandleCurRequest($$); sub CUL_HandleCurRequest($$);
my $initstr = "X21"; # Only translated messages + RSSI my $initstr = "X21"; # Only translated messages + RSSI
my %msghist; # Used when more than one CUL is attached
my $msgcount = 0;
my %gets = ( my %gets = (
"version" => "V", "version" => "V",
"raw" => "", "raw" => "",
@ -424,17 +422,6 @@ CUL_Write($$$)
return; 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"; Log 5, "CUL sending $fn$msg";
my $bstring = "$fn$msg\n"; my $bstring = "$fn$msg\n";
@ -490,7 +477,6 @@ CUL_Read($)
my ($hash) = @_; my ($hash) = @_;
my $buf = $hash->{PortObj}->input(); my $buf = $hash->{PortObj}->input();
my $iohash = $modules{$hash->{TYPE}}; # Our (CUL) module pointer
my $name = $hash->{NAME}; my $name = $hash->{NAME};
########### ###########
@ -558,41 +544,15 @@ CUL_Read($)
goto NEXTMSG; goto NEXTMSG;
} }
############### my $rssi;
# check for duplicate msg from different CUL's if($initstr =~ m/X2/ && $dmsg =~ m/[FEHTK]([A-F0-9][A-F0-9])+$/) { # RSSI
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 $l = length($dmsg); 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); $dmsg = substr($dmsg, 0, $l-2);
$rssi = ($rssi>=128 ? (($rssi-256)/2-74) : ($rssi/2-74)); $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 { } else {
Log GetLogLevel($name,4), "CUL: $dmsg"; Log GetLogLevel($name,4), "$name: $dmsg";
} }
########################################### ###########################################
@ -639,42 +599,14 @@ CUL_Read($)
goto NEXTMSG; goto NEXTMSG;
} }
my @found = Dispatch($hash, $dmsg);
my @found; if($rssi) {
my $last_module; foreach my $d (@found) {
foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} } next if(!$defs{$d});
grep {defined($modules{$_}{ORDER});}keys %modules) { $defs{$d}{RSSI} = $rssi;
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;
} }
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: NEXTMSG:
} }
$hash->{PARTIAL} = $culdata; $hash->{PARTIAL} = $culdata;

View File

@ -48,10 +48,6 @@ my %codes = (
"^8501..\$" => "fhtbuf", "^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 # Note: we are a data provider _and_ a consumer at the same time
sub sub
@ -355,7 +351,7 @@ FHZ_Parse($$)
if(!$type) { if(!$type) {
Log 4, "FHZ $name unknown: $omsg"; Log 4, "FHZ $name unknown: $omsg";
$def->{CHANGED}[0] = "$msg"; $hash->{CHANGED}[0] = "$msg";
return $hash->{NAME}; return $hash->{NAME};
} }
@ -365,7 +361,7 @@ FHZ_Parse($$)
} }
Log 4, "FHZ $name $type: $msg"; Log 4, "FHZ $name $type: $msg";
$def->{CHANGED}[0] = "$type: $msg"; $hash->{CHANGED}[0] = "$type: $msg";
return $hash->{NAME}; return $hash->{NAME};
} }
@ -498,18 +494,6 @@ FHZ_Write($$$)
return; 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); my $bstring = FHZ_CompleteMsg($fn, $msg);
Log 5, "Sending " . unpack('H*', $bstring); Log 5, "Sending " . unpack('H*', $bstring);
@ -652,70 +636,8 @@ FHZ_Read($)
$fhzdata = substr($fhzdata, 2); $fhzdata = substr($fhzdata, 2);
next; 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: NEXTMSG:
$fhzdata = substr($fhzdata, $len); $fhzdata = substr($fhzdata, $len);

View File

@ -101,7 +101,7 @@ FS20_Initialize($)
$hash->{DefFn} = "FS20_Define"; $hash->{DefFn} = "FS20_Define";
$hash->{UndefFn} = "FS20_Undef"; $hash->{UndefFn} = "FS20_Undef";
$hash->{ParseFn} = "FS20_Parse"; $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; my @list;
foreach my $n (keys %{ $def }) { foreach my $n (keys %{ $def }) {
my $lh = $def->{$n}; my $lh = $def->{$n};
return "" if($lh->{IODev} && $lh->{IODev}{NAME} ne $hash->{NAME});
$lh->{CHANGED}[0] = $v; $lh->{CHANGED}[0] = $v;
$lh->{STATE} = $v; $lh->{STATE} = $v;
$lh->{READINGS}{state}{TIME} = TimeNow(); $lh->{READINGS}{state}{TIME} = TimeNow();

View File

@ -143,7 +143,7 @@ FHT_Initialize($)
$hash->{DefFn} = "FHT_Define"; $hash->{DefFn} = "FHT_Define";
$hash->{UndefFn} = "FHT_Undef"; $hash->{UndefFn} = "FHT_Undef";
$hash->{ParseFn} = "FHT_Parse"; $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"; "showtime:0,1 loglevel:0,1,2,3,4,5,6 retrycount minfhtbuffer";
} }
@ -320,6 +320,8 @@ FHT_Parse($$)
my $def = $defptr{$dev}; my $def = $defptr{$dev};
my $name = $def->{NAME}; my $name = $def->{NAME};
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
# Short message # Short message
if(length($msg) < 26) { if(length($msg) < 26) {
Log 4,"FHT Short message. Device $name, Message: $msg"; Log 4,"FHT Short message. Device $name, Message: $msg";

View File

@ -39,7 +39,7 @@ HMS_Initialize($)
$hash->{DefFn} = "HMS_Define"; $hash->{DefFn} = "HMS_Define";
$hash->{UndefFn} = "HMS_Undef"; $hash->{UndefFn} = "HMS_Undef";
$hash->{ParseFn} = "HMS_Parse"; $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 $dev = substr($msg, 16, 4);
my $cde = substr($msg, 11, 1); my $cde = substr($msg, 11, 1);
012345678901234567890123456789
# 810e047f0214a001a81f000001000000 HMS100TFK
my $val = substr($msg, 24, 8) if(length($msg) == 32); my $val = substr($msg, 24, 8) if(length($msg) == 32);
my $type = ""; my $type = "";
@ -103,6 +105,7 @@ HMS_Parse($$)
} }
my $def = $defptr{$dev}; my $def = $defptr{$dev};
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
my (@v, @txt, @sfx); my (@v, @txt, @sfx);

View File

@ -20,7 +20,7 @@ KS300_Initialize($)
$hash->{DefFn} = "KS300_Define"; $hash->{DefFn} = "KS300_Define";
$hash->{UndefFn} = "KS300_Undef"; $hash->{UndefFn} = "KS300_Undef";
$hash->{ParseFn} = "KS300_Parse"; $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 $haverain = 0;
my $name= $def->{NAME}; my $name= $def->{NAME};
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
my @v; my @v;
my @txt = ( "rain_raw", "rain", "wind", "humidity", "temperature", my @txt = ( "rain_raw", "rain", "wind", "humidity", "temperature",
"israining", "unknown1", "unknown2", "unknown3"); "israining", "unknown1", "unknown2", "unknown3");

View File

@ -27,7 +27,7 @@ CUL_WS_Initialize($)
$hash->{DefFn} = "CUL_WS_Define"; $hash->{DefFn} = "CUL_WS_Define";
$hash->{UndefFn} = "CUL_WS_Undef"; $hash->{UndefFn} = "CUL_WS_Undef";
$hash->{ParseFn} = "CUL_WS_Parse"; $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"; Log 1, "CUL_WS UNDEFINED $type sensor detected, code $cde";
return "UNDEFINED CUL_WS: $cde"; return "UNDEFINED CUL_WS: $cde";
} }
my $def = $defptr{$cde};
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
$hash = $defptr{$cde}; $hash = $defptr{$cde};
my $name = $hash->{NAME}; my $name = $hash->{NAME};

View File

@ -19,7 +19,7 @@ CUL_EM_Initialize($)
$hash->{DefFn} = "CUL_EM_Define"; $hash->{DefFn} = "CUL_EM_Define";
$hash->{UndefFn} = "CUL_EM_Undef"; $hash->{UndefFn} = "CUL_EM_Undef";
$hash->{ParseFn} = "CUL_EM_Parse"; $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); $seqno, $total_cnt, $current_cnt, $peak_cnt);
if($defptr{$cde}) { if($defptr{$cde}) {
my $def = $defptr{$cde};
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
$hash = $defptr{$cde}; $hash = $defptr{$cde};
my $tn = TimeNow(); # current time my $tn = TimeNow(); # current time

View File

@ -104,8 +104,7 @@ X10_Initialize($)
$hash->{DefFn} = "X10_Define"; $hash->{DefFn} = "X10_Define";
$hash->{UndefFn} = "X10_Undef"; $hash->{UndefFn} = "X10_Undef";
$hash->{ParseFn} = "X10_Parse"; $hash->{ParseFn} = "X10_Parse";
$hash->{AttrList} = "follow-on-for-timer:1,0 do_not_notify:1,0 dummy:1,0 $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";
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) { foreach my $unitcode (@unitcodes) {
my $h= $devices{$housecode}{$unitcode}; my $h= $devices{$housecode}{$unitcode};
if($h) { if($h) {
return "" if($h->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
my $name= $h->{NAME}; my $name= $h->{NAME};
$h->{CHANGED}[0] = $value; $h->{CHANGED}[0] = $value;
$h->{STATE} = $value; $h->{STATE} = $value;

View File

@ -20,7 +20,7 @@ EMWZ_Initialize($)
$hash->{SetFn} = "EMWZ_Set"; $hash->{SetFn} = "EMWZ_Set";
$hash->{DefFn} = "EMWZ_Define"; $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";
} }

View File

@ -18,7 +18,7 @@ EMEM_Initialize($)
$hash->{GetFn} = "EMEM_Get"; $hash->{GetFn} = "EMEM_Get";
$hash->{DefFn} = "EMEM_Define"; $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";
} }
################################### ###################################

View File

@ -20,7 +20,7 @@ EMGZ_Initialize($)
$hash->{SetFn} = "EMGZ_Set"; $hash->{SetFn} = "EMGZ_Set";
$hash->{DefFn} = "EMGZ_Define"; $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";
} }

View File

@ -367,3 +367,7 @@
is sent back. The CUR must have reception enabled. is sent back. The CUR must have reception enabled.
Right now status/set time/set FHT desired temp are implemented. 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

View File

@ -1134,17 +1134,27 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Get</b> <ul>N/A</ul><br> <b>Get</b> <ul>N/A</ul><br>
<a name="FS20attributes"></a>
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<a name="IODev"></a>
<li>IODev<br>
Set the IO or physical device which should be used for receiving /
sending signals for this "logical" device. An example for the physical
device is an FHZ or a CUL. Note: Upon startup fhem assigns each logical
device (FS20/HMS/KS300/etc) the last physical device which can receive
data for this type of device. The attribute IODev should be used only
if you attached more than one physical device capable of receiving
signals for this logical device.</li><br>
<li><a href="#do_not_notify">do_not_notify</a></li><br> <li><a href="#do_not_notify">do_not_notify</a></li><br>
<a name="dummy"></a> <a name="dummy"></a>
<li>dummy<br> <li>dummy<br>
Can be applied to FS20/FHT devices.<br>
Set the device attribute dummy to define devices which should not Set the device attribute dummy to define devices which should not
output any radio signals. Associated notifys will be executed if output any radio signals. Associated notifys will be executed if
the signal is received. Used e.g. to react to a code from a sender, but the signal is received. Used e.g. to react to a code from a sender, but
it will not emit radio signal if triggered in the web frontend. it will not emit radio signal if triggered in the web frontend.
Implemented for FS20 and FHT devices.</li><br> </li><br>
<a name="follow-on-for-timer"></a> <a name="follow-on-for-timer"></a>
<li>follow-on-for-timer<br> <li>follow-on-for-timer<br>
@ -1377,6 +1387,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#loglevel">loglevel</a></li><br> <li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#model">model</a> (fht80b)</li><br> <li><a href="#model">model</a> (fht80b)</li><br>
<li><a href="#showtime">showtime</a></li><br> <li><a href="#showtime">showtime</a></li><br>
<li><a href="#IODev">IODev</a></li><br>
<a name="retrycount"></a> <a name="retrycount"></a>
<li>retrycount<br/> <li>retrycount<br/>
@ -1463,6 +1474,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#do_not_notify">do_not_notify</a></li><br> <li><a href="#do_not_notify">do_not_notify</a></li><br>
<li><a href="#loglevel">loglevel</a></li><br> <li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#showtime">showtime</a></li><br> <li><a href="#showtime">showtime</a></li><br>
<li><a href="#IODev">IODev</a></li><br>
<li><a href="#model">model</a> (hms100-t hms100-tf hms100-wd hms100-mg <li><a href="#model">model</a> (hms100-t hms100-tf hms100-wd hms100-mg
hms100-co hms100-tfk hms100-fit rm100-2)</li> hms100-co hms100-tfk hms100-fit rm100-2)</li>
</ul> </ul>
@ -1588,6 +1600,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#showtime">showtime</a></li><br> <li><a href="#showtime">showtime</a></li><br>
<li><a href="#loglevel">loglevel</a></li><br> <li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#model">model</a> (S300,KS300,WS7000)</li><br> <li><a href="#model">model</a> (S300,KS300,WS7000)</li><br>
<li><a href="#IODev">IODev</a></li><br>
</ul> </ul>
<br> <br>
</ul> </ul>
@ -1628,6 +1641,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#showtime">showtime</a></li><br> <li><a href="#showtime">showtime</a></li><br>
<li><a href="#loglevel">loglevel</a></li><br> <li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#model">model</a> (EMEM,EMWZ,EMGZ)</li><br> <li><a href="#model">model</a> (EMEM,EMWZ,EMGZ)</li><br>
<li><a href="#IODev">IODev</a></li><br>
</ul> </ul>
<br> <br>
</ul> </ul>
@ -1744,6 +1758,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#model">model</a> (EM1000WZ)</li> <li><a href="#model">model</a> (EM1000WZ)</li>
<li><a href="#dummy">dummy</a></li> <li><a href="#dummy">dummy</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#IODev">IODev</a></li><br>
</ul> </ul>
<br> <br>
</ul> </ul>
@ -1797,6 +1812,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#model">model</a> (EM1000GZ)</li> <li><a href="#model">model</a> (EM1000GZ)</li>
<li><a href="#dummy">dummy</a></li> <li><a href="#dummy">dummy</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#IODev">IODev</a></li><br>
</ul> </ul>
<br> <br>
</ul> </ul>
@ -1843,6 +1859,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#model">model</a> (EM1000EM)</li> <li><a href="#model">model</a> (EM1000EM)</li>
<li><a href="#dummy">dummy</a></li> <li><a href="#dummy">dummy</a></li>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#IODev">IODev</a></li><br>
</ul> </ul>
<br> <br>
</ul> </ul>
@ -2052,6 +2069,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#showtime">showtime</a></li><br> <li><a href="#showtime">showtime</a></li><br>
<li><a href="#model">model</a> (lm12,lm15,am12,tm13)</li><br> <li><a href="#model">model</a> (lm12,lm15,am12,tm13)</li><br>
<li><a href="#loglevel">loglevel</a></li> <li><a href="#loglevel">loglevel</a></li>
<li><a href="#IODev">IODev</a></li><br>
</ul> </ul>
<br> <br>
</ul> </ul>

View File

@ -46,6 +46,7 @@ sub AssignIoPort($);
sub CallFn(@); sub CallFn(@);
sub CommandChain($$); sub CommandChain($$);
sub DoClose($); sub DoClose($);
sub Dispatch($$);
sub FmtDateTime($); sub FmtDateTime($);
sub FmtTime($); sub FmtTime($);
sub GetLogLevel(@); sub GetLogLevel(@);
@ -148,7 +149,7 @@ my %intAt; # Internal at timer hash.
my $nextat; # Time when next timer will be triggered. my $nextat; # Time when next timer will be triggered.
my $intAtCnt=0; my $intAtCnt=0;
my $AttrList = "room comment"; 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 = my $namedef =
"where <name> is either:\n" . "where <name> is either:\n" .
"- a single device name\n" . "- a single device name\n" .
@ -1415,6 +1416,11 @@ CommandAttr($$)
next; next;
} }
if($a[1] eq "IODev" && (!$a[2] || !defined($defs{$a[2]}))) {
push @rets,"Unknown IODev specified";
next;
}
$a[0] = $sdev; $a[0] = $sdev;
$ret = CallFn($sdev, "AttrFn", "set", @a); $ret = CallFn($sdev, "AttrFn", "set", @a);
if($ret) { if($ret) {
@ -1427,6 +1433,7 @@ CommandAttr($$)
} else { } else {
$attr{$sdev}{$a[1]} = "1"; $attr{$sdev}{$a[1]} = "1";
} }
$defs{$sdev}{IODev} = $defs{$a[2]} if($a[1] eq "IODev");
} }
return join("\n", @rets); 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;
}