From 2d4701733044f6208f2f4346500321516a5b9c78 Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Mon, 18 Nov 2013 08:48:43 +0000 Subject: [PATCH] correct startup-sequence to set logIDs in HMLAN git-svn-id: https://svn.fhem.de/fhem/trunk@4243 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/00_HMLAN.pm | 61 ++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/fhem/FHEM/00_HMLAN.pm b/fhem/FHEM/00_HMLAN.pm index 0d96a0bc7..1f77137c2 100755 --- a/fhem/FHEM/00_HMLAN.pm +++ b/fhem/FHEM/00_HMLAN.pm @@ -151,11 +151,18 @@ sub HMLAN_RemoveHMPair($) {#################################################### } sub HMLAN_Notify(@) {########################################################## my ($hash,$dev) = @_; - return if ($dev->{NAME} ne $hash->{NAME}); # looking for our own connect/disconnect - - foreach (grep (m/CONNECTED$/,@{$dev->{CHANGED}})) { # connect/disconnect - if ($_ eq "DISCONNECTED") {HMLAN_condUpdate($hash,253);} -# elsif ($_ eq "CONNECTED") {covered by init;} + if ($dev->{NAME} eq "global" && grep (m/^INITIALIZED$/,@{$dev->{CHANGED}})){ + if ($hash->{helper}{attrPend}){ + my $aVal = AttrVal($hash->{NAME},"logIDs",""); + HMLAN_Attr("set",$hash->{NAME},"logIDs",$aVal) if($aVal); + delete $hash->{helper}{attrPend}; + } + } + elsif ($dev->{NAME} eq $hash->{NAME}){ + foreach (grep (m/CONNECTED$/,@{$dev->{CHANGED}})) { # connect/disconnect + if ($_ eq "DISCONNECTED") {HMLAN_condUpdate($hash,253);} +# elsif ($_ eq "CONNECTED") {covered by init;} + } } return; } @@ -225,28 +232,34 @@ sub HMLAN_Attr(@) {############################################################ } elsif($aName eq "logIDs"){ if ($cmd eq "set"){ - my @ids = split",",$aVal; - my @idName; - if (grep /sys/,@ids){ - push @idName,"sys"; - $defs{$name}{helper}{log}{sys}=1; + if ($init_done){ + my @ids = split",",$aVal; + my @idName; + if (grep /sys/,@ids){ + push @idName,"sys"; + $defs{$name}{helper}{log}{sys}=1; + } + else{ + $defs{$name}{helper}{log}{sys}=0; + } + if (grep /all/,@ids){ + push @idName,"all"; + $defs{$name}{helper}{log}{all}=1; + } + else{ + $defs{$name}{helper}{log}{all}=0; + $_=substr(CUL_HM_name2Id($_),0,6) foreach(grep !/^$/,@ids); + $_="" foreach(grep !/^[A-F0-9]{6}$/,@ids); + @ids = HMLAN_noDup(@ids); + push @idName,CUL_HM_id2Name($_) foreach(@ids); + } + $attr{$name}{$aName} = join(",",@idName); + @{$defs{$name}{helper}{log}{ids}}=@ids; } else{ - $defs{$name}{helper}{log}{sys}=0; + $defs{$name}{helper}{attrPend} = 1; + return; } - if (grep /all/,@ids){ - push @idName,"all"; - $defs{$name}{helper}{log}{all}=1; - } - else{ - $defs{$name}{helper}{log}{all}=0; - $_=substr(CUL_HM_name2Id($_),0,6) foreach(grep !/^$/,@ids); - $_="" foreach(grep !/^[A-F0-9]{6}$/,@ids); - @ids = HMLAN_noDup(@ids); - push @idName,CUL_HM_id2Name($_) foreach(@ids); - } - $attr{$name}{$aName} = join(",",@idName); - @{$defs{$name}{helper}{log}{ids}}=@ids; } else{ my @ids = ();