Ignore attribute added

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@532 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2010-01-01 14:53:03 +00:00
parent 2ccd40ac3e
commit a1acbf067b
18 changed files with 97 additions and 32 deletions

View File

@ -22,7 +22,8 @@ BS_Initialize($)
$hash->{DefFn} = "BS_Define";
$hash->{UndefFn} = "BS_Undef";
$hash->{ParseFn} = "BS_Parse";
$hash->{AttrList} = "IODev do_not_notify:1,0 showtime:0,1 dummy:1,0 model:BS loglevel:0,1,2,3,4,5,6";
$hash->{AttrList} = "do_not_notify:1,0 showtime:0,1 ".
"ignore:1,0 model:BS loglevel:0,1,2,3,4,5,6";
}
@ -88,6 +89,7 @@ BS_Parse($$)
}
my $name= $def->{NAME};
return "" if(IsIgnored($name));
my $t= TimeNow();

View File

@ -112,7 +112,8 @@ CUL_FHTTK_Initialize($)
$hash->{DefFn} = "CUL_FHTTK_Define";
$hash->{UndefFn} = "CUL_FHTTK_Undef";
$hash->{ParseFn} = "CUL_FHTTK_Parse";
$hash->{AttrList} = "IODev do_not_notify:1,0 showtime:0,1 dummy:1,0 model:FHT80TF loglevel:0,1,2,3,4,5,6";
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 showtime:0,1 " .
"model:FHT80TF loglevel:0,1,2,3,4,5,6";
}
@ -168,6 +169,8 @@ CUL_FHTTK_Parse($$)
my $self = $def->{NAME};
my $state = lc(substr($msg, 7, 2));
return "" if(IsIgnored($self));
if(!defined($fhttfk_translatedcodes{$state})) {
Log 3, sprintf("FHTTK $def Unknown state $state");
$defs{$self}{READINGS}{"Unknown"}{VAL} = $state;

View File

@ -24,7 +24,8 @@ USF1000_Initialize($)
$hash->{DefFn} = "USF1000_Define";
$hash->{UndefFn} = "USF1000_Undef";
$hash->{ParseFn} = "USF1000_Parse";
$hash->{AttrList} = "IODev do_not_notify:1,0 showtime:0,1 dummy:1,0 model:usf1000s loglevel:0,1,2,3,4,5,6";
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 showtime:0,1 " .
"model:usf1000s loglevel:0,1,2,3,4,5,6";
}
@ -97,6 +98,8 @@ USF1000_Parse($$)
my $def= $modules{USF1000}{defptr}{$dev};
my $name= $def->{NAME};
return "" if(IsIgnored($name));
my $t= TimeNow();
# Msg format:

View File

@ -106,7 +106,7 @@ FS20_Initialize($)
$hash->{DefFn} = "FS20_Define";
$hash->{UndefFn} = "FS20_Undef";
$hash->{ParseFn} = "FS20_Parse";
$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,fs20ls,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 ignore:0,1 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,fs20ls,fs20ms2,fs20rst,fs20sa,fs20sig,fs20st,fs20sv,fs20usr loglevel:0,1,2,3,4,5,6";
}
@ -206,8 +206,7 @@ FS20_Set($@)
return "Specified timeout too large, max is 15360" if(length($c) == 2);
}
IOWrite($hash, "04", "010101" . $hash->{XMIT} . $hash->{BTN} . $c)
if(!IsDummy($a[0]));
IOWrite($hash, "04", "010101" . $hash->{XMIT} . $hash->{BTN} . $c);
###########################################
# Set the state of a device to off if on-for-timer is called
@ -356,6 +355,8 @@ FS20_Parse($$)
my $lh = $def->{$n};
$n = $lh->{NAME}; # It may be renamed
return "" if(IsIgnored($n)); # Little strange.
$lh->{CHANGED}[0] = $v;
$lh->{STATE} = $v;
$lh->{READINGS}{state}{TIME} = TimeNow();

View File

@ -144,7 +144,7 @@ FHT_Initialize($)
$hash->{ParseFn} = "FHT_Parse";
$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 lazy tmpcorr";
"minfhtbuffer lazy tmpcorr ignore:0,1";
}
@ -267,7 +267,7 @@ FHT_Set($@)
} else {
IOWrite($hash, "04", $arg) if(!IsDummy($name));
IOWrite($hash, "04", $arg);
Log GetLogLevel($name,2), "FHT set $name $allcmd";
}
@ -343,6 +343,7 @@ FHT_Parse($$)
my $def = $modules{FHT}{defptr}{$dev};
my $name = $def->{NAME};
return "" if(IsIgnored($name));
# Short message
if(length($msg) < 26) {
@ -502,7 +503,7 @@ doSoftBuffer($)
my $arglen = length($h->{ARG})/2 - 2; # Length in bytes
next if($fhzbuflen < $arglen || $fhzbuflen < getFhtMin($io));
IOWrite($h->{HASH}, "04", $h->{ARG}) if(!IsDummy($name));
IOWrite($h->{HASH}, "04", $h->{ARG});
Log GetLogLevel($name,2), "FHT set $name $h->{CMD}";
$fhzbuflen -= $arglen;

View File

@ -37,7 +37,7 @@ HMS_Initialize($)
$hash->{DefFn} = "HMS_Define";
$hash->{UndefFn} = "HMS_Undef";
$hash->{ParseFn} = "HMS_Parse";
$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";
$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 ignore:0,1";
}
#####################################
@ -106,6 +106,8 @@ HMS_Parse($$)
}
my $def = $modules{HMS}{defptr}{$dev};
my $name = $def->{NAME};
return "" if(IsIgnored($name));
my (@v, @txt);
@ -209,7 +211,7 @@ HMS_Parse($$)
}
my $now = TimeNow();
Log GetLogLevel($def->{NAME},4), "HMS Device $dev ($type: $val)";
Log GetLogLevel($name,4), "HMS Device $dev ($type: $val)";
my $max = int(@txt);
for( my $i = 0; $i < $max; $i++) {
@ -224,7 +226,7 @@ HMS_Parse($$)
$def->{CHANGED}[$max++] = $val;
$def->{CHANGED}[$max++] = "ExactId: $odev" if($odev ne $dev);
return $def->{NAME};
return $name;
}
1;

View File

@ -19,7 +19,7 @@ KS300_Initialize($)
$hash->{DefFn} = "KS300_Define";
$hash->{UndefFn} = "KS300_Undef";
$hash->{ParseFn} = "KS300_Parse";
$hash->{AttrList} = "IODev 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 ignore:0,1";
}
#####################################
@ -87,6 +87,7 @@ KS300_Parse($$)
my $def = $modules{KS300}{defptr}{$dev};
my $haverain = 0;
my $name= $def->{NAME};
return "" if(IsIgnored($name));
my @v;
my @txt = ( "rain_raw", "rain", "wind", "humidity", "temperature",

View File

@ -24,7 +24,7 @@ CUL_WS_Initialize($)
$hash->{UndefFn} = "CUL_WS_Undef";
$hash->{AttrFn} = "CUL_WS_Attr";
$hash->{ParseFn} = "CUL_WS_Parse";
$hash->{AttrList} = "IODev 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 ignore:0,1";
}
@ -94,6 +94,8 @@ CUL_WS_Parse($$)
my $tm=TimeNow();
$hash = $def;
my $name = $hash->{NAME};
return "" if(IsIgnored($name));
my $typbyte = hex($a[2]) & 7;
my $sfirstbyte = $firstbyte & 7;
@ -217,7 +219,6 @@ CUL_WS_Parse($$)
}
my $name = $hash->{NAME};
if(!$val) {
Log GetLogLevel($name,1), "CUL_WS Cannot decode $msg";
return "";

View File

@ -20,7 +20,8 @@ CUL_EM_Initialize($)
$hash->{DefFn} = "CUL_EM_Define";
$hash->{UndefFn} = "CUL_EM_Undef";
$hash->{ParseFn} = "CUL_EM_Parse";
$hash->{AttrList} = "IODev 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 ignore:0,1";
}
#####################################
@ -106,14 +107,14 @@ CUL_EM_Parse($$)
if($modules{CUL_EM}{defptr}{$cde}) {
my $def = $modules{CUL_EM}{defptr}{$cde};
$hash = $def;
my $n = $hash->{NAME};
return "" if(IsIgnored($n));
my $tn = TimeNow(); # current time
my $c= 0; # count changes
my %readings;
my $n = $hash->{NAME};
Log GetLogLevel($n,5), "CUL_EM $n: $val";
$readings{RAW} = $val;

View File

@ -22,7 +22,8 @@ CUL_RFR_Initialize($)
$hash->{DefFn} = "CUL_RFR_Define";
$hash->{UndefFn} = "CUL_RFR_Undef";
$hash->{ParseFn} = "CUL_RFR_Parse";
$hash->{AttrList} = "IODev do_not_notify:0,1 model:CUL,CUN,CUR loglevel";
$hash->{AttrList} = "IODev do_not_notify:0,1 model:CUL,CUN,CUR " .
"loglevel:0,1,2,3,4,5,6 ignore:0,1";
$hash->{WriteFn} = "CUL_RFR_Write";
$hash->{GetFn} = "CUL_Get";
@ -87,6 +88,7 @@ CUL_RFR_Parse($$)
}
my $hash = $modules{CUL_RFR}{defptr}{$cde};
my $name = $hash->{NAME};
return "" if(IsIgnored($name));
if($smsg =~ m/^T/) { $hash->{NR_TMSG}++ }
elsif($smsg =~ m/^F/) { $hash->{NR_FMSG}++ }

View File

@ -67,9 +67,8 @@ OWFS_Initialize($)
$hash->{UndefFn} = "OWFS_Undef";
$hash->{GetFn} = "OWFS_Get";
#$hash->{SetFn} = "OWFS_Set";
$hash->{AttrList} = "do_not_notify:1,0 dummy:1,0 temp-scale:C,F,K,R " .
"showtime:1,0 loglevel:0,1,2,3,4,5,6";
}
$hash->{AttrList} = "IODev do_not_notify:1,0 dummy:1,0 temp-scale:C,F,K,R ".
"showtime:1,0 loglevel:0,1,2,3,4,5,6"; }
#####################################
sub

View File

@ -102,7 +102,9 @@ X10_Initialize($)
$hash->{DefFn} = "X10_Define";
$hash->{UndefFn} = "X10_Undef";
$hash->{ParseFn} = "X10_Parse";
$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";
$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";
}

View File

@ -45,6 +45,7 @@ CommandXmlList($$)
$modules{$defs{$b}{TYPE}}{ORDER};
$x = ($a cmp $b) if($x == 0); $x; } keys %defs) {
next if(IsIgnored($d));
my $p = $defs{$d};
my $t = $p->{TYPE};

View File

@ -464,3 +464,4 @@
- my %defptr is no $modules{modname}{defptr} in order for CommandReload to
work. There is also a second parameter $modules{modname}{ldata} which will
be saved over a Reload, used by the FS20 for the follow feature.
- ignore attribute added to ignore devices of the neighbour

View File

@ -1249,6 +1249,16 @@ A line ending with \ will be concatenated with the next one, so long lines
</li><br>
<a name="ignore"></a>
<li>ignore<br>
Ignore this device, e.g. if it belongs to your neighbour. The device
won't trigger any FileLogs/notifys, issued commands will silently
ignored (no RF signal will be sent out, just like for the <a
href="#attrdummy">dummy</a> attribute). The device won't appear in the
list command (only if it is explicitely asked for it), nor will it
appear in commands which use some wildcard/attribute as name specifiers
(see <a href="#devspec">devspec</a>). You still get them with the
"ignored=1" special devspec. </li>
</ul>
</ul>
@ -1449,6 +1459,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b>
<ul>
<li><a href="#ignore">ignore</a></li><br>
<li><a href="#do_not_notify">do_not_notify</a></li><br>
<li><a href="#attrdummy">dummy</a><br>
<b>Note:</b>It makes sense to define an FHT device even for an FHT8b,
@ -1544,11 +1555,11 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b>
<ul>
<li><a href="#do_not_notify">do_not_notify</a></li><br>
<li><a href="#attrdummy">dummy</a></li><br>
<li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#model">model</a> (FHT80TF)</li><br>
<li><a href="#showtime">showtime</a></li><br>
<li><a href="#IODev">IODev</a></li><br>
<li><a href="#ignore">ignore</a></li><br>
</ul>
<br>
@ -1613,6 +1624,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b>
<ul>
<li><a href="#ignore">ignore</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="#showtime">showtime</a></li><br>
@ -1761,6 +1773,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b>
<ul>
<li><a href="#ignore">ignore</a></li><br>
<li><a href="#do_not_notify">do_not_notify</a></li><br>
<li><a href="#showtime">showtime</a></li><br>
<li><a href="#loglevel">loglevel</a></li><br>
@ -1825,6 +1838,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b>
<ul>
<li><a href="#ignore">ignore</a></li><br>
<li><a href="#do_not_notify">do_not_notify</a></li><br>
<li><a href="#showtime">showtime</a></li><br>
<li><a href="#loglevel">loglevel</a></li><br>
@ -1898,7 +1912,9 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b>
<ul>
Same as for the <a href="#CUL">CUL</a>.</ul><br>
<li><a href="#ignore">ignore</a></li><br>
<li><a href="#IODev">IODev</a></li><br>
The rest of the attributes is the same as for the <a href="#CUL">CUL</a>.</ul><br>
</ul>
<br>
</ul>
@ -2166,6 +2182,8 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b>
<ul>
<li><a href="#ignore">ignore</a></li>
<li><a href="#IODev">IODev</a></li>
<li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#showtime">showtime</a></li>
<li><a href="#loglevel">loglevel</a></li>
@ -2563,10 +2581,12 @@ A line ending with \ will be concatenated with the next one, so long lines
<b>Attributes</b>
<ul>
<li><a href="#IODev">IODev</a></li><br>
<li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#showtime">showtime</a></li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (usf1000s)</li>
<li><a href="#ignore">ignore</a></li>
</ul>
<br>
@ -2629,6 +2649,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#showtime">showtime</a></li>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#model">model</a> (bs)</li>
<li><a href="#ignore">ignore</a></li>
</ul>
<br>
@ -3138,6 +3159,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>
<li><a href="#loglevel">loglevel</a></li>
<li><a href="#showtime">showtime</a></li>
<li><a href="#IODev">IODev</a></li>
</ul>
<br>
@ -3402,7 +3424,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li>Title with maximum and current values of the 1st curve (FileLog)
<ul>
<li>Fhem config:<br>
attr wl_1 label "Max $data{max1}, Current $data{lastv1}"</li>
attr wl_1 label "Max $data{max1}, Current $data{currval1}"</li>
<li>.gplot file entry:<br>
set title &lt;L1&gt;<br>
</ul></li>
@ -4138,8 +4160,8 @@ A line ending with \ will be concatenated with the next one, so long lines
Plots the measured-temp/desired-temp/actuator lines. The
corresponding filelog definitions (for the FHT device named
fht1) looks like:<br>
define FileLog fhtlog1 fht1:.*(temp|actuator).*
/var/log/fht1-%Y-%U.log
<code>define fhtlog1 FileLog fht1:.*(temp|actuator).* /var/log/fht1-%Y-%U.log</code>
</li>
<li>ks300<br>
Plots the temperature and rain (per hour and per day) of a

View File

@ -7,7 +7,7 @@ attr global port 7072 # our TCP/IP port (localhost only)
attr global statefile /tmp/fhem.save # where to save the state of the devices
attr global verbose 3 # "normal" verbosity (min 1, max 5)
#define CUL CUL /dev/ttyACM0
#define CUL CUL /dev/ttyACM0 1234
#define FHEM FHEM /dev/USB0
define WEB FHEMWEB 8083 global

22
fhem.pl
View File

@ -73,6 +73,8 @@ sub devspec2array($);
sub doGlobalDef($);
sub fhem($);
sub fhz($);
sub IsDummy($);
sub IsIgnored($);
sub CommandAttr($$);
sub CommandDefaultAttr($$);
@ -157,7 +159,7 @@ my $nextat; # Time when next timer will be triggered.
my $intAtCnt=0;
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.95 2010-01-01 13:48:33 rudolfkoenig Exp $';
my $cvsid = '$Id: fhem.pl,v 1.96 2010-01-01 14:53:03 rudolfkoenig Exp $';
my $namedef =
"where <name> is either:\n" .
"- a single device name\n" .
@ -400,6 +402,17 @@ IsDummy($)
return 0;
}
sub
IsIgnored($)
{
my $devname = shift;
return 1 if($devname &&
defined($attr{$devname}) &&
defined($attr{$devname}{ignore}));
return 0;
}
################################################
sub
IsIoDummy($)
@ -472,9 +485,11 @@ IOWrite($@)
{
my ($hash, @a) = @_;
my $dev = $hash->{NAME};
return if(IsDummy($dev) || IsIgnored($dev));
my $iohash = $hash->{IODev};
if(!$iohash) {
Log 5, "No IO device found for $hash->{NAME}";
Log 5, "No IO device found for $dev";
return;
}
@ -679,6 +694,8 @@ devspec2array($)
}
return $name if(!@ret && !$isattr); # No match, return the input
@ret = grep { !$attr{$_} || !$attr{$_}{ignore} } @ret
if($name !~ m/^ignore=/);
return @ret;
}
@ -1213,6 +1230,7 @@ CommandList($$)
for my $d (sort { my $x = $modules{$defs{$a}{TYPE}}{ORDER} cmp
$modules{$defs{$b}{TYPE}}{ORDER};
$x = ($a cmp $b) if($x == 0); $x; } keys %defs) {
next if(IsIgnored($d));
my $t = $defs{$d}{TYPE};
$str .= "\n$t:\n" if($t ne $lt);
$str .= sprintf(" %-20s (%s)\n", $d, $defs{$d}{STATE});

View File

@ -191,8 +191,10 @@ FW_Read($)
$hash->{BUF} = "";
Log($ll, "HTTP $name GET $arg");
$hash->{INUSE} = 1;
my $pid;
return if(($arg =~ m/cmd=showlog/) && ($pid = fork));
$hash->{INUSE} = 1;
my $cacheable = FW_AnswerCall($arg);
delete($hash->{INUSE});
@ -210,6 +212,7 @@ FW_Read($)
$e,
"Content-Type: $__RETTYPE\r\n\r\n",
$__RET;
exit if(defined($pid));
}
###########################
@ -387,6 +390,7 @@ FW_updateHashes()
# Make a room hash
%__rooms = ();
foreach my $d (keys %defs ) {
next if(IsIgnored($d));
foreach my $r (split(",", FW_getAttr($d, "room", "Unsorted"))) {
$__rooms{$r}{$d} = 1;
}
@ -396,6 +400,7 @@ FW_updateHashes()
# Needed for type sorting
%__types = ();
foreach my $d (sort keys %defs ) {
next if(IsIgnored($d));
$__types{$defs{$d}{TYPE}}{$d} = 1;
}