diff --git a/FHEM/10_CUL_HM.pm b/FHEM/10_CUL_HM.pm index ac1d0937f..b055b4984 100755 --- a/FHEM/10_CUL_HM.pm +++ b/FHEM/10_CUL_HM.pm @@ -181,7 +181,8 @@ sub CUL_HM_Initialize($) { CUL_HM_AttrInit($hash,"initAttrlist"); CUL_HM_initRegHash(); - + my $time = gettimeofday(); + $hash->{prot}{rspPend} = 0;#count Pending responses my @statQArr = (); my @statQWuArr = (); @@ -200,7 +201,7 @@ sub CUL_HM_Initialize($) { $hash->{stat}{s}{dummy}=0; $hash->{stat}{r}{dummy}=0; RemoveInternalTimer("StatCntRfresh"); - InternalTimer(gettimeofday()+3600*20,"CUL_HM_statCntRfresh","StatCntRfresh", 0); + InternalTimer($time + 3600 * 20,"CUL_HM_statCntRfresh","StatCntRfresh", 0); $hash->{hmIoMaxDly} = 60;# poll timeout - stop poll and discard $hash->{hmAutoReadScan} = 4; # delay autoConf readings @@ -210,8 +211,9 @@ sub CUL_HM_Initialize($) { # fhem does not provide module notifcation - so we streamline here. $hash->{helper}{initDone} = 0; $hash->{NotifyOrderPrefix} = "48-"; #Beta-User: make sure, CUL_HM is up and running prior to User code e.g. in notify, and also prior to HMinfo - InternalTimer(1,"CUL_HM_updateConfig","startUp",0); - #InternalTimer(1,"CUL_HM_setupHMLAN", "initHMLAN", 0);#start asap once FHEM is operational + InternalTimer($time + 1,"CUL_HM_updateConfig","startUp",0); + #InternalTimer($time + 1,"CUL_HM_setupHMLAN", "initHMLAN", 0);#start asap once FHEM is operational + return; } @@ -223,7 +225,7 @@ sub CUL_HM_updateConfig($){########################## # Purpose is to parse attributes and read config RemoveInternalTimer("updateConfig"); if (!$init_done){ - InternalTimer(1,"CUL_HM_updateConfig", "updateConfig", 0);#start asap once FHEM is operational + InternalTimer(gettimeofday() + 1,"CUL_HM_updateConfig", "updateConfig", 0);#start asap once FHEM is operational return; } if (!$modules{CUL_HM}{helper}{initDone}){ #= 0;$type eq "startUp"){ @@ -546,7 +548,13 @@ sub CUL_HM_updateConfig($){########################## } delete $modules{CUL_HM}{helper}{updtCfgLst}; - Log 1,"CUL_HM finished initial cleanup" if(!$modules{CUL_HM}{helper}{initDone}); + if(!$modules{CUL_HM}{helper}{initDone}){ + Log 1,"CUL_HM finished initial cleanup"; + if ($modules{HMinfo}){# force reread + $modules{HMinfo}{helper}{initDone} = 0; + InternalTimer(gettimeofday() + 5,"HMinfo_init", "HMinfo_init", 0); + } + } $modules{CUL_HM}{helper}{initDone} = 1;# we made init once - now we are operational. Check with HMInfo as well ## configCheck will be issues by HMInfo once } @@ -1560,6 +1568,7 @@ sub CUL_HM_Notify(@){############################### return undef if(!$events); # Some previous notify deleted the array. #my $cws = join(";#",@{$dev->{CHANGED}}); my $count; + foreach my $evnt(@{$events}){ if($evnt =~ m/^(DELETEATTR)/){ } @@ -9943,22 +9952,21 @@ sub CUL_HM_getChnPeerFriend($){ #which are my peerFriends return join(",",@chPopt); } -sub CUL_HM_getPeerOption($){ #who are my friends +sub CUL_HM_getPeerOption($){ #who are my friends? Whom can I peer to, who can I unpeer my ($name) = @_; CUL_HM_calcPeerOptions() if(!$modules{CUL_HM}{helper}{peerOpt}); my %curPTmp; if($defs{$name}{helper}{peerFriend}){ - $curPTmp{$_} = $_ foreach(grep !/$name/, - split(",", - join(",",map{$modules{CUL_HM}{helper}{peerOpt}{$_}} - grep!/^-$/, - split(",",$defs{$name}{helper}{peerFriend})))); + $curPTmp{$_} = $_ foreach(grep !/$name/, + split(",", + join(",",map{$modules{CUL_HM}{helper}{peerOpt}{$_}} + grep!/^-$/, + split(",",$defs{$name}{helper}{peerFriend})))); } - else{ - $curPTmp{$_} = "remove_".$_ foreach(grep !/(broadcast|self)/,values %{$defs{$name}{helper}{peerIDsH}}); + if($defs{$name}{helper}{peerIDsH}){ + $curPTmp{$_} = "remove_".$_ foreach(grep !/(broadcast|self)/,values %{$defs{$name}{helper}{peerIDsH}}); } - my @peers = sort values %curPTmp; return join(",",(grep/remove/ ,@peers) # offer remove first @@ -11758,13 +11766,15 @@ __END__ which specifies the index of the old key when the reading is divided by 2.