2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-20 07:16:03 +00:00

10_CUL_HM:bugfix peer handling, add get list command

git-svn-id: https://svn.fhem.de/fhem/trunk@23421 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2020-12-26 15:11:46 +00:00
parent f11b1029d4
commit bdcb321df5

View File

@ -1404,6 +1404,7 @@ sub CUL_HM_Parse($$) {#########################################################
$mh{dstH}->{"prot"."ErrIoAttack"} = $mh{dstH}->{"prot"."ErrIoAttack"} =
ReadingsVal($mh{dstN},"sabotageAttack_ErrIoAttack_cnt:",undef); ReadingsVal($mh{dstN},"sabotageAttack_ErrIoAttack_cnt:",undef);
} }
Log3 $mh{dstN},2,"CUL_HM $mh{dstN} attack:$mh{dstH}->{helper}{cSnd}:".$tm; Log3 $mh{dstN},2,"CUL_HM $mh{dstN} attack:$mh{dstH}->{helper}{cSnd}:".$tm;
CUL_HM_eventP($mh{dstH},"ErrIoAttack"); CUL_HM_eventP($mh{dstH},"ErrIoAttack");
my ($evntCnt,undef) = split(' last_at:',$mh{dstH}->{"prot"."ErrIoAttack"},2); my ($evntCnt,undef) = split(' last_at:',$mh{dstH}->{"prot"."ErrIoAttack"},2);
@ -4362,6 +4363,18 @@ sub CUL_HM_Get($@) {#+++++++++++++++++ get command+++++++++++++++++++++++++++++
} }
return $ret; return $ret;
} }
elsif($cmd eq "list"){ ###############################################
my $globAttr = AttrVal("global","showInternalValues","undef");
$attr{global}{showInternalValues} = $a[2] eq "full" ? 1 : 0;
my $ret = CommandList(undef,$name);
if ($globAttr eq "undef"){
delete $attr{global}{showInternalValues};
}
else{
$attr{global}{showInternalValues} = $globAttr;
}
return $ret;
}
Log3 $name,3,"CUL_HM get $name " . join(" ", @a[1..$#a]); Log3 $name,3,"CUL_HM get $name " . join(" ", @a[1..$#a]);
@ -8117,27 +8130,22 @@ sub CUL_HM_protState($$){
###################-----------helper and shortcuts--------##################### ###################-----------helper and shortcuts--------#####################
################### Peer Handling ################ ################### Peer Handling ################
sub CUL_HM_ID2PeerList ($$$) { sub CUL_HM_ID2PeerList ($$$) { # {CUL_HM_ID2PeerList ("lvFrei","12345678",1)}
my($name,$peerID,$set) = @_; my($name,$peerID,$set) = @_;
my $peerIDs = AttrVal($name,"peerIDs","peerUnread"); $peerID = ' ' if (!defined($peerID) || $peerID eq ''); # no peer
$peerIDs =~ s/peerUnread//;
return if (!$peerID && !$peerIDs); # nothing to do
my $hash = $defs{$name};
$peerIDs =~ s/$peerID//g; #avoid duplicate, support unset
$peerID =~ s/^000000../00000000/; #correct end detector $peerID =~ s/^000000../00000000/; #correct end detector
$peerIDs.= $peerID."," if($set);
my %tmpHash = map { $_ => 1 } split(",",$peerIDs);#remove duplicates
$peerIDs = ""; #clear list
my $peerNames = ""; #prepare names
my $dId = substr(CUL_HM_name2Id($name),0,6); #get own device ID my $dId = substr(CUL_HM_name2Id($name),0,6); #get own device ID
foreach my $pId (sort(keys %tmpHash)){ my $peerIDs = AttrVal($name,"peerIDs","peerUnread");
next if ($pId !~ m/^[0-9A-Fx]{8}$/); #ignore non-channel IDs $peerIDs =~ s/(peerUnread|$peerID)//g; #avoid duplicate, support unset
$peerIDs .= $pId.","; #append ID $peerIDs.= ",$peerID" if($set);
next if ($pId eq "00000000"); # and end detection
$peerNames .= CUL_HM_peerChName($pId,$dId).","; my %tmpHash = map { $_ => 1 } grep/^[0-9A-Fx]{8}$/,split(",",$peerIDs);#remove duplicates
} $peerIDs = join(",",sort(keys %tmpHash)).',';
my $peerNames = join(",",map{CUL_HM_peerChName($_,$dId)} sort(grep !/00000000/,keys %tmpHash));
$attr{$name}{peerIDs} = $peerIDs ? $peerIDs : "peerUnread"; # make it public $attr{$name}{peerIDs} = $peerIDs ? $peerIDs : "peerUnread"; # make it public
my $hash = $defs{$name};
my $dHash = CUL_HM_getDeviceHash($hash); my $dHash = CUL_HM_getDeviceHash($hash);
my $st = AttrVal($dHash->{NAME},"subType",""); my $st = AttrVal($dHash->{NAME},"subType","");
my $md = AttrVal($dHash->{NAME},"model",""); my $md = AttrVal($dHash->{NAME},"model","");
@ -8198,9 +8206,8 @@ sub CUL_HM_ID2PeerList ($$$) {
CUL_HM_UpdtReadSingle($hash,"state","peered",0); CUL_HM_UpdtReadSingle($hash,"state","peered",0);
} }
} }
elsif( ($md =~ m/^HM-CC-RT-DN/ && $chn =~ m/^(03|06)$/) elsif( $chn =~ m/^(03|06)$/ && $md =~ m/^(HM-CC-RT-DN|HM-TC-IT-WM-W-EU)/ ){
||($md eq "HM-TC-IT-WM-W-EU" && $chn =~ m/^(03|06)$/)){ if (ReadingsVal($name,"state","unpeered") eq "unpeered"){
if (AttrVal($hash,"state","unpeered") eq "unpeered"){
CUL_HM_UpdtReadSingle($hash,"state","unknown",0); CUL_HM_UpdtReadSingle($hash,"state","unknown",0);
} }
} }
@ -11850,6 +11857,9 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
prior to rewrite data to an entity it is necessary to pair the device with FHEM.<br> prior to rewrite data to an entity it is necessary to pair the device with FHEM.<br>
restore will not delete any peered channels, it will just add peer channels.<br> restore will not delete any peered channels, it will just add peer channels.<br>
</li> </li>
<li><B>list (normal|hidden);</B><a name="CUL_HMlist"><br>
issue list command for the fiven entity normal or including the hidden parameter
</li>
<li><B>listDevice</B><br> <li><B>listDevice</B><br>
<ul> <ul>
<li>when used with ccu it returns a list of Devices using the ccu service to assign an IO.<br> <li>when used with ccu it returns a list of Devices using the ccu service to assign an IO.<br>
@ -13278,19 +13288,22 @@ sub CUL_HM_tempListTmpl(@) { ##################################################
vor dem zur&uuml;ckschreiben der Daten eines Eintrags muss das Ger&auml;t mit FHEM verbunden werden.<br> vor dem zur&uuml;ckschreiben der Daten eines Eintrags muss das Ger&auml;t mit FHEM verbunden werden.<br>
"restore" l&ouml;scht keine verkn&uuml;pften Kan&auml;le, es f&uuml;gt nur neue Peers hinzu.<br> "restore" l&ouml;scht keine verkn&uuml;pften Kan&auml;le, es f&uuml;gt nur neue Peers hinzu.<br>
</li> </li>
<li><B>listDevice</B><br> <li><B>list (normal|hidden);</B><a name="CUL_HMlist"><br>
<ul> triggern des list commandos fuer die entity normal oder inclusive der verborgenen parameter
<li>bei einer CCU gibt es eine Liste der Devices, welche den ccu service zum zuweisen der IOs zurück<br> </li>
</li> <li><B>listDevice</B><br>
<li>beim ActionDetector wird eine Komma geteilte Liste der Entities zurückgegeben<br> <ul>
get ActionDetector listDevice # returns alle assigned entities<br> <li>bei einer CCU gibt es eine Liste der Devices, welche den ccu service zum zuweisen der IOs zurück<br>
get ActionDetector listDevice notActive# returns entities ohne status alive<br> </li>
get ActionDetector listDevice alive # returns entities mit status alive<br> <li>beim ActionDetector wird eine Komma geteilte Liste der Entities zurückgegeben<br>
get ActionDetector listDevice unknown # returns entities mit status unknown<br> get ActionDetector listDevice # returns alle assigned entities<br>
get ActionDetector listDevice dead # returns entities mit status dead<br> get ActionDetector listDevice notActive# returns entities ohne status alive<br>
</li> get ActionDetector listDevice alive # returns entities mit status alive<br>
</ul> get ActionDetector listDevice unknown # returns entities mit status unknown<br>
</li> get ActionDetector listDevice dead # returns entities mit status dead<br>
</li>
</ul>
</li>
</ul><br> </ul><br>
<a name="CUL_HMattr"></a><b>Attribute</b> <a name="CUL_HMattr"></a><b>Attribute</b>
<ul> <ul>