2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

structure: move global userattr to device userattr (Forum #27451)

git-svn-id: https://svn.fhem.de/fhem/trunk@6664 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2014-10-03 10:53:48 +00:00
parent 49ef17cbfe
commit 8148975916
2 changed files with 14 additions and 8 deletions

View File

@ -45,8 +45,6 @@ structure_Initialize($)
"clientstate_behavior:relative,relativeKnown,absolute,last ".
$readingFnAttributes;
addToAttrList("structexclude");
my %ahash = ( Fn=>"CommandAddStruct",
Hlp=>"<structure> <devspec>,add <devspec> to <structure>" );
$cmds{addstruct} = \%ahash;
@ -71,14 +69,15 @@ structure_Define($$)
my $modname = shift(@a);
my $stype = shift(@a);
addToAttrList($stype);
addToAttrList($stype . "_map");
$hash->{ATTR} = $stype;
my %list;
foreach my $a (@a) {
foreach my $d (devspec2array($a)) {
$list{$d} = 1;
addToDevAttrList($d, $stype);
addToDevAttrList($d, $stype . "_map");
addToDevAttrList($d, "structexclude");
}
}
$hash->{CONTENT} = \%list;

View File

@ -91,6 +91,7 @@ sub WakeUpFn($);
sub WriteStatefile();
sub XmlEscape($);
sub addEvent($$);
sub addToDevAttrList($$);
sub addToAttrList($);
sub addToWritebuffer($$@);
sub attrSplit($);
@ -3167,19 +3168,25 @@ AddDuplicate($$)
# Add an attribute to the userattr list, if not yet present
sub
addToAttrList($)
addToDevAttrList($$)
{
my $arg = shift;
my ($dev,$arg) = @_;
my $ua = "";
$ua = $attr{global}{userattr} if($attr{global}{userattr});
$ua = $attr{$dev}{userattr} if($attr{$dev}{userattr});
my @al = split(" ", $ua);
my %hash;
foreach my $a (@al) {
$hash{$a} = 1 if(" $AttrList " !~ m/ $a /); # Cleanse old ones
}
$hash{$arg} = 1 if(" $AttrList " !~ m/ $arg /);
$attr{global}{userattr} = join(" ", sort keys %hash);
$attr{$dev}{userattr} = join(" ", sort keys %hash);
}
sub
addToAttrList($)
{
addToDevAttrList("global", @_);
}
sub