2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

10_CUL_HM:repair peerSmart to remove peerings

git-svn-id: https://svn.fhem.de/fhem/trunk@25078 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2021-10-16 10:31:26 +00:00
parent d582bda72c
commit 04c81c51b3

View File

@ -181,6 +181,7 @@ sub CUL_HM_Initialize($) {
CUL_HM_AttrInit($hash,"initAttrlist"); CUL_HM_AttrInit($hash,"initAttrlist");
CUL_HM_initRegHash(); CUL_HM_initRegHash();
my $time = gettimeofday();
$hash->{prot}{rspPend} = 0;#count Pending responses $hash->{prot}{rspPend} = 0;#count Pending responses
my @statQArr = (); my @statQArr = ();
@ -200,7 +201,7 @@ sub CUL_HM_Initialize($) {
$hash->{stat}{s}{dummy}=0; $hash->{stat}{s}{dummy}=0;
$hash->{stat}{r}{dummy}=0; $hash->{stat}{r}{dummy}=0;
RemoveInternalTimer("StatCntRfresh"); 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->{hmIoMaxDly} = 60;# poll timeout - stop poll and discard
$hash->{hmAutoReadScan} = 4; # delay autoConf readings $hash->{hmAutoReadScan} = 4; # delay autoConf readings
@ -210,8 +211,9 @@ sub CUL_HM_Initialize($) {
# fhem does not provide module notifcation - so we streamline here. # fhem does not provide module notifcation - so we streamline here.
$hash->{helper}{initDone} = 0; $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 $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($time + 1,"CUL_HM_updateConfig","startUp",0);
#InternalTimer(1,"CUL_HM_setupHMLAN", "initHMLAN", 0);#start asap once FHEM is operational #InternalTimer($time + 1,"CUL_HM_setupHMLAN", "initHMLAN", 0);#start asap once FHEM is operational
return; return;
} }
@ -223,7 +225,7 @@ sub CUL_HM_updateConfig($){##########################
# Purpose is to parse attributes and read config # Purpose is to parse attributes and read config
RemoveInternalTimer("updateConfig"); RemoveInternalTimer("updateConfig");
if (!$init_done){ 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; return;
} }
if (!$modules{CUL_HM}{helper}{initDone}){ #= 0;$type eq "startUp"){ if (!$modules{CUL_HM}{helper}{initDone}){ #= 0;$type eq "startUp"){
@ -546,7 +548,13 @@ sub CUL_HM_updateConfig($){##########################
} }
delete $modules{CUL_HM}{helper}{updtCfgLst}; 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 $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 ## 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. return undef if(!$events); # Some previous notify deleted the array.
#my $cws = join(";#",@{$dev->{CHANGED}}); #my $cws = join(";#",@{$dev->{CHANGED}});
my $count; my $count;
foreach my $evnt(@{$events}){ foreach my $evnt(@{$events}){
if($evnt =~ m/^(DELETEATTR)/){ if($evnt =~ m/^(DELETEATTR)/){
} }
@ -9943,7 +9952,7 @@ sub CUL_HM_getChnPeerFriend($){ #which are my peerFriends
return join(",",@chPopt); 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) = @_; my ($name) = @_;
CUL_HM_calcPeerOptions() if(!$modules{CUL_HM}{helper}{peerOpt}); CUL_HM_calcPeerOptions() if(!$modules{CUL_HM}{helper}{peerOpt});
@ -9955,10 +9964,9 @@ sub CUL_HM_getPeerOption($){ #who are my friends
grep!/^-$/, grep!/^-$/,
split(",",$defs{$name}{helper}{peerFriend})))); split(",",$defs{$name}{helper}{peerFriend}))));
} }
else{ if($defs{$name}{helper}{peerIDsH}){
$curPTmp{$_} = "remove_".$_ foreach(grep !/(broadcast|self)/,values %{$defs{$name}{helper}{peerIDsH}}); $curPTmp{$_} = "remove_".$_ foreach(grep !/(broadcast|self)/,values %{$defs{$name}{helper}{peerIDsH}});
} }
my @peers = sort values %curPTmp; my @peers = sort values %curPTmp;
return join(",",(grep/remove/ ,@peers) # offer remove first 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. which specifies the index of the old key when the reading is divided by 2.
</li> </li>
<li><a id="CUL_HM-set-clear"></a><B>clear &lt;[rssi|readings|register|msgEvents|attack|all]&gt;</B><br> <li><a id="CUL_HM-set-clear"></a><B>clear &lt;[rssi|readings|register|msgEvents|attack|all]&gt;</B><br>
A set of variables can be removed.<br> A set of variables or readings can be removed.<br>
<ul> <ul>
readings: all readings will be deleted. Any new reading will be added usual. May be used to eliminate old data<br> readings: all readings are removed. Any new reading will be added usual. Used to eliminate old data.<br>
register: all captured register-readings in FHEM will be removed. This has NO impact to the values in the device.<br> register: all captured register-readings in FHEM are removed. NO impact to the device.<br>
msgEvents: all message event counter will be removed. Also commandstack will be cleared. <br> msgEvents: all message event counter are removed. Also commandstack is cleared. <br>
rssi: collected rssi values will be cleared. <br> msgErrors: message-error counter are removed.<br>
attack: information regarding an attack will be removed. <br> rssi: collected rssi values are cleared. <br>
attack: information regarding an attack are removed. <br>
trigger: all trigger readings are removed. <br>
all: all of the above. <br> all: all of the above. <br>
</ul> </ul>
</li> </li>
@ -12091,12 +12101,11 @@ __END__
used to stimulate the related actions as defined in the actor register. used to stimulate the related actions as defined in the actor register.
</li> </li>
<li><a id="CUL_HM-set-peerSmart"></a><B>peerSmart [&lt;peer&gt;]</B><br> <li><a id="CUL_HM-set-peerSmart"></a><B>peerSmart [&lt;peer&gt;]</B><br>
The command is similar to <B><a href="#CUL_HM-set-peerChan">peerChan</a></B>. The command is similar to <B><a href="#CUL_HM-set-peerChan">peerChan</a></B>
peerChan uses only one parameter, the peer which the channel shall be peered to. <br> with reduced options for peer and unpeer.<br>
Therefore peerSmart peers always in single mode (see peerChan). Funktionallity of the peered actor shall be applied peerSmart peers in single mode (see peerChan) while funktionallity should be defined
manually by setting register. This is not a big difference to peerChan. <br> by setting register (not much difference to peerChan). <br>
Smart register setting could be done using hmTemplate. <br> Smart register setting could be done using hmTemplate.
peerSmart is also available for actor-channel.
</li> </li>
<li><a id="CUL_HM-set-peerChan"></a><B>peerChan &lt;btn_no&gt; &lt;actChan&gt; [single|<u>dual</u>|reverse][<u>set</u>|unset] [<u>both</u>|actor|remote]</B><br> <li><a id="CUL_HM-set-peerChan"></a><B>peerChan &lt;btn_no&gt; &lt;actChan&gt; [single|<u>dual</u>|reverse][<u>set</u>|unset] [<u>both</u>|actor|remote]</B><br>
@ -13560,12 +13569,10 @@ __END__
Initiiert ein pressL fuer die peer entity. Wenn <B>all</B> ausgewählt ist wird das Kommando bei jedem der Peers ausgeführt. Siehe auch <a href="#CUL_HM-set-pressL">pressL</a><br> Initiiert ein pressL fuer die peer entity. Wenn <B>all</B> ausgewählt ist wird das Kommando bei jedem der Peers ausgeführt. Siehe auch <a href="#CUL_HM-set-pressL">pressL</a><br>
</li> </li>
<li><B>peerSmart [&lt;peer&gt;] </B><a id="CUL_HM-set-peerSmart"></a><br> <li><B>peerSmart [&lt;peer&gt;] </B><a id="CUL_HM-set-peerSmart"></a><br>
Das Kommando ist aehnlich dem <B><a href="#CUL_HM-set-peerChan">peerChan</a></B>. Das Kommando ist aehnlich <B><a href="#CUL_HM-set-peerChan">peerChan</a></B> mit reduzierten Optionen.<br>
peerChan braucht nur einen Parameter, den Peer zu welchem die Beziehung hergestellt werden soll.<br> peerSmart peert immer single mode (siehe peerChan). Die Funktionalitaet über das
Daher peert peerSmart immer single mode (siehe peerChan). Die Funktionalitaet des gepeerten Aktors wird über das manuelle setzen der Register erstellt (kein grosser Unterschied zu peerChan).<br>
setzen der Register eingestellt. Am Ende ist das kein grosser Unterschied zu peerChan. <br> Smartes Registersetzen unterstützt bspw hmTemplate.<br>
Smartes Register Setzen kann man mit hmTemplate erreichen. <br>
peerSmart ist auch für Aktor Kanäle verfügbar.
</li> </li>
<li><B>peerChan &lt;btn_no&gt; &lt;actChan&gt; [single|<u>dual</u>|reverse] <li><B>peerChan &lt;btn_no&gt; &lt;actChan&gt; [single|<u>dual</u>|reverse]
[<u>set</u>|unset] [<u>both</u>|actor|remote]</B><a id="CUL_HM-set-peerChan"></a><br> [<u>set</u>|unset] [<u>both</u>|actor|remote]</B><a id="CUL_HM-set-peerChan"></a><br>