From 880eb16e6b1fe61b26920c72b8062089428797df Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 20 Jan 2015 20:38:03 +0000 Subject: [PATCH] 98_structure.pm: fixing structure of structure problem (Forum #32493) git-svn-id: https://svn.fhem.de/fhem/trunk@7645 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_structure.pm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/fhem/FHEM/98_structure.pm b/fhem/FHEM/98_structure.pm index 6d74d5df8..57f7eb712 100755 --- a/fhem/FHEM/98_structure.pm +++ b/fhem/FHEM/98_structure.pm @@ -54,6 +54,23 @@ structure_Initialize($) $cmds{delstruct} = \%dhash; } +sub structAdd($$); +sub +structAdd($$) +{ + my ($d, $attrList) = @_; + $defs{$d}{INstructAdd} = 1; + foreach my $c (keys %{$defs{$d}{CONTENT}}) { + if($defs{$c}{INstructAdd}) { + Log 1, "recursive structure definition" + + } else { + addToDevAttrList($c, $attrList); + structAdd($c, $attrList) if($defs{$d}{TYPE} eq "structure"); + } + } + delete $defs{$d}{INstructAdd}; +} ############################# sub @@ -72,12 +89,12 @@ structure_Define($$) $hash->{ATTR} = $stype; my %list; + my $attrList = "$stype ${stype}_map structexclude"; foreach my $a (@a) { foreach my $d (devspec2array($a)) { $list{$d} = 1; - addToDevAttrList($d, $stype); - addToDevAttrList($d, $stype . "_map"); - addToDevAttrList($d, "structexclude"); + addToDevAttrList($d, $attrList); + structAdd($d, $attrList) if($defs{$d}{TYPE} eq "structure"); } } $hash->{CONTENT} = \%list;