2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-01 01:09:47 +00:00

bugs LED16, HMcnd and CC-VD

git-svn-id: https://svn.fhem.de/fhem/trunk@3338 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2013-06-26 17:05:56 +00:00
parent 7c8cda0188
commit 09312eb8f1
2 changed files with 57 additions and 68 deletions

View File

@ -342,10 +342,7 @@ sub CUL_HM_Undef($$) {###############################
$devHash->{helper}{role}{chn}=1 if($chn eq "01");# return chan 01 role
}
else{# delete a device
foreach my $channel (keys %{$hash}){
CommandDelete(undef,$hash->{$channel})
if ($channel =~ m/^channel_/);
}
CommandDelete(undef,$hash->{$_}) foreach (grep(/^channel_/,keys %{$hash}));
}
delete($modules{CUL_HM}{defptr}{$HMid});
return undef;
@ -361,7 +358,7 @@ sub CUL_HM_Rename($$$) {#############################
$devHash->{"channel_".$hash->{chanNo}} = $name;
}
else{# we are a device - inform channels if exist
foreach (grep {$_ =~m/^channel_/} keys%{$hash}){
foreach (grep (/^channel_/, keys%{$hash})){
my $chnHash = $defs{$hash->{$_}};
$chnHash->{device} = $name;
}
@ -762,7 +759,7 @@ sub CUL_HM_Parse($$) {##############################
#VD hang detection
my $des = ReadingsVal($name, "ValveDesired", "");
$des =~ s/ .*//; # remove unit
if (defined $des && $des != $vp && ($err&0x30) == 0x00){
if ($des ne $vp && ($err&0x30) == 0x00){
push @event, "operState:errorTargetNotMet";
push @event, "operStateErrCnt:".
(ReadingsVal($name,"operStateErrCnt","0")+1);
@ -980,7 +977,7 @@ sub CUL_HM_Parse($$) {##############################
}
elsif($st eq "outputUnit"){ #################################################
if($mTp eq "40" && @mI == 2){
my ($button, $bno) = (hex($mI[1]), hex($mI[2]));
my ($button, $bno) = (hex($mI[0]), hex($mI[1]));
if(!(exists($shash->{BNO})) || $shash->{BNO} ne $bno){
$shash->{BNO}=$bno;
$shash->{BNOCNT}=1;
@ -1447,9 +1444,7 @@ sub CUL_HM_parseCommon(@){#####################################################
my @peers = substr($p,2,) =~ /(.{8})/g;
$chnhash->{helper}{peerIDsRaw}.= ",".join",",@peers;
foreach my $peer(@peers){
CUL_HM_ID2PeerList ($chnNname,$peer,1);
}
CUL_HM_ID2PeerList ($chnNname,$_,1) foreach (@peers);
if ($p =~ m/000000..$/) {# last entry, peerList is complete
CUL_HM_respPendRm($shash);
# check for request to get List3 data
@ -1459,8 +1454,7 @@ sub CUL_HM_parseCommon(@){#####################################################
my $id = CUL_HM_IOid($shash);
my $listNo = "0".$chnhash->{helper}{getCfgListNo};
my @peerID = split(",",($attr{$chnNname}{peerIDs}?$attr{$chnNname}{peerIDs}:""));
foreach my $peer (@peerID){
next if ($peer eq '00000000');# ignore termination
foreach my $peer (grep (!/00000000/,@peerID)){
$peer .="01" if (length($peer) == 6); # add the default
if ($peer &&($peer eq $reqPeer || $reqPeer eq "all")){
CUL_HM_PushCmdStack($shash,sprintf("++%s01%s%s%s04%s%s",
@ -1760,9 +1754,9 @@ sub CUL_HM_Get($@) {
print aSave "\nset ".$eName." peerBulk ".$pIds;
}
my $ehash = $defs{$eName};
foreach my $read (sort keys %{$ehash->{READINGS}}){
next if ($read !~ m/^[\.]?RegL_/);
print aSave "\nset ".$eName." regBulk ".$read." ".ReadingsVal($eName,$read,"");
foreach my $read (sort grep(!/^[\.]?RegL_/,keys %{$ehash->{READINGS}})){
print aSave "\nset ".$eName." regBulk ".$read." "
.ReadingsVal($eName,$read,"");
$timestamps .= "\n# ".ReadingsTimestamp($eName,$read,"")." :".$read;
}
print aSave $timestamps;
@ -1911,20 +1905,16 @@ sub CUL_HM_Set($@) {
CUL_HM_respPendRm($hash);
delete ($hash->{helper}{burstEvtCnt});
delete ($hash->{cmdStack});
foreach my $var (keys %{$attr{$name}}){ # can be removed versions later
delete ($attr{$name}{$var}) if ($var =~ m/^prot/);
}
foreach my $var (keys %{$hash}){
delete ($hash->{$var}) if ($var =~ m/^prot/);
delete ($hash->{EVENTS});
}
delete ($hash->{EVENTS});
#rescue and restore "protLastRcv" for action detector.
my $protLastRcv = $hash->{protLastRcv} if ($hash->{protLastRcv});
delete ($hash->{$_}) foreach (grep(/^prot/,keys %{$hash}));
$hash->{protLastRcv} = $protLastRcv if ($protLastRcv);
CUL_HM_protState($hash,"Info_Cleared");
}
elsif($sect eq "rssi"){
delete $defs{$name}{helper}{rssi};
foreach my $var (keys %{$hash}){
delete ($hash->{$var}) if ($var =~ m/^rssi_/);
}
delete ($hash->{$_}) foreach (grep(/^rssi/,keys %{$hash}))
}
else{
return "unknown section. User readings, msgEvents or rssi";
@ -1969,8 +1959,7 @@ sub CUL_HM_Set($@) {
my $pL = $a[2];
return "unknown action: $a[3] - use set or unset" if ($a[3] && $a[3] !~ m/^(set|unset)/);
my $set = ($a[3] eq "unset")?"02":"01";
foreach my $peer (split(',',$pL)){
next if ($peer =~ m/^self/);
foreach my $peer (grep(!/^self/,split(',',$pL))){
my $pID = CUL_HM_peerChId($peer,$dst,$id);
return "unknown peer".$peer if (length($pID) != 8);# peer only to channel
my $pCh1 = substr($pID,6,2);
@ -2772,7 +2761,7 @@ sub CUL_HM_SndCmd($$) {
$hash = CUL_HM_getDeviceHash($hash);
my $io = $hash->{IODev};
return if(!$io);
if ($io->{helper}{HMcnd} == 4){#io is in overload - dont send messages
if ($io->{helper}{HMcnd} && $io->{helper}{HMcnd} == 4){#io in overload, dont send
CUL_HM_eventP($hash,"IOerr");
return;
}
@ -3151,7 +3140,7 @@ sub CUL_HM_getAssChnIds($) { #in: name out:ID list of assotiated channels
my ($name) = @_;
my @chnIdList;
my $hash = $defs{$name};
foreach my $channel (grep {$_ =~m/^channel_/} keys %{$hash}){
foreach my $channel (grep /^channel_/, keys %{$hash}){
my $chnHash = $defs{$hash->{$channel}};
push @chnIdList,$chnHash->{DEF} if ($chnHash);
}
@ -3918,7 +3907,7 @@ sub CUL_HM_stateUpdat($){#in:name, send status-request
(undef,$name)=split":",$name,2;
CUL_HM_Set($defs{$name},$name,"statusRequest") if ($name);
}
sub CUL_HM_qStateUpdatIfEnab($@){#in:name or id, queue stat-request after 12 sec
sub CUL_HM_qStateUpdatIfEnab($@){#in:name or id, queue stat-request after 12 s
my ($name,$force) = @_;
$name = CUL_HM_id2Name($name) if ($name =~ m/^[A-F0-9]{6,8}$/i);
$name =~ s /_chn:..$//;

View File

@ -498,77 +498,77 @@ sub HMinfo_status($){##########################################################
# - prot events if error
my $hash = shift;
my $name = $hash->{NAME};
my @IDs = keys%{$modules{CUL_HM}{defptr}};
my ($nbrE,$nbrD,$nbrC,$nbrV) = (scalar(@IDs),0,0,0);# count entities
my ($nbrE,$nbrD,$nbrC,$nbrV) = (0,0,0,0);# count entities and types
#--- used for status
my @crit = split ",",$attr{$name}{sumStatus};#prepare event
my %sum;
#--- used for error counts
my @erro = split ",",$attr{$name}{sumERROR};
my %errFlt;
my %err;
my @errNames;
my @IOdev;
my %prot = (NACK =>0,IOerr =>0,ResendFail =>0,CmdDel =>0,CmdPend =>0);
my @protNames;
my @Anames;
foreach (@erro){ #prepare reading filter for error counts
foreach (@erro){ #prepare reading filter for error counts
my ($p,@a) = split ":",$_;
$errFlt{$p}{x}=1; # at least one reading
$errFlt{$p}{x}=1; # add at least one reading
$errFlt{$p}{$_}=1 foreach (@a);
}
foreach my $id (@IDs){#search for Parameter
#--- used for IO and protocol
my @IOdev;
my %prot = (NACK =>0,IOerr =>0,ResendFail =>0,CmdDel =>0,CmdPend =>0);
my @protNames; # devices with current protocol events
my @Anames; # devices with ActionDetector events
foreach my $id (keys%{$modules{CUL_HM}{defptr}}){#search/count for parameter
my $ehash = $modules{CUL_HM}{defptr}{$id};
my $eName = $ehash->{NAME};
$nbrE++;
$nbrC++ if ($ehash->{helper}{role}{chn});
$nbrV++ if ($ehash->{helper}{role}{vrt});
foreach my $read (@crit){
if ($ehash->{READINGS}{$read}){
my $val = $ehash->{READINGS}{$read}{VAL};
$sum{$read}{$val} =0 if (!$sum{$read}{$val});
$sum{$read}{$val}++;
}
foreach my $read (@crit){ #---- count critical readings
next if (!$ehash->{READINGS}{$read});
my $val = $ehash->{READINGS}{$read}{VAL};
$sum{$read}{$val} =0 if (!$sum{$read}{$val});
$sum{$read}{$val}++;
}
foreach my $read (keys %errFlt){
if ($ehash->{READINGS}{$read}){
my $val = $ehash->{READINGS}{$read}{VAL};
next if (grep (/$val/,(keys%{$errFlt{$read}})));# filter non-Error
$err{$read}{$val} =0 if (!$err{$read}{$val});
$err{$read}{$val}++;
push @errNames,$eName;
}
foreach my $read (keys %errFlt){ #---- count error readings
next if (!$ehash->{READINGS}{$read});
my $val = $ehash->{READINGS}{$read}{VAL};
next if (grep (/$val/,(keys%{$errFlt{$read}})));# filter non-Error
$err{$read}{$val} =0 if (!$err{$read}{$val});
$err{$read}{$val}++;
push @errNames,$eName;
}
if ($ehash->{helper}{role}{dev}){#restrict to devices
if ($ehash->{helper}{role}{dev}){#---restrict to devices
$nbrD++;
push @IOdev,$ehash->{IODev}{NAME} if($ehash->{IODev});
push @Anames,$eName if ($attr{$eName}{actStatus} && $attr{$eName}{actStatus} ne "alive");
foreach (keys%prot){
if ($ehash->{"prot".$_}){
$prot{$_}++;
push @protNames,$eName;
}
foreach (keys%prot){# see if protocol events are to be reported
next if (!$ehash->{"prot".$_});
$prot{$_}++;
push @protNames,$eName;
}
}
}
#====== collection finished - start data preparation======
delete $hash->{$_} foreach (grep(/^(ERR_|sum_)/,keys%{$hash}));# remove old
foreach my $v(keys%{$hash}){# remove old readings
delete $hash->{$v} if($v =~ m/^(ERR_|sum_)/);
}
foreach my $read(@crit){
foreach my $read(@crit){ #--- display critical counts
next if (!defined $sum{$read} );
$hash->{"sum_".$read} = "";
$hash->{"sum_".$read} .= "$_:$sum{$read}{$_};"foreach(keys %{$sum{$read}});
}
foreach my $read(keys %errFlt){
foreach my $read(keys %errFlt){#--- display error counts
next if (!defined $err{$read} );
$hash->{"ERR_".$read} = "";
$hash->{"ERR_".$read} .= "$_:$err{$read}{$_};"foreach(keys %{$err{$read}});
}
delete $hash->{ERR_names};
$hash->{ERR_names} = join",",@errNames if(@errNames);
$hash->{ERR_names} = join",",@errNames if(@errNames);# and name entities
$hash->{sumDefined} = "entities:$nbrE device:$nbrD channel:$nbrC virtual:$nbrV";
# ------- what about IO devices??? ------
$hash->{actTotal} = $modules{CUL_HM}{defptr}{"000000"}{STATE};# display actionDetector
delete $hash->{ERRactNames}if(!@Anames);
# ------- display status of action detector ------
$hash->{actTotal} = $modules{CUL_HM}{defptr}{"000000"}{STATE};
delete $hash->{ERRactNames} if(!@Anames);
$hash->{ERRactNames} = join",",@Anames;
# ------- what about IO devices??? ------