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

View File

@ -498,76 +498,76 @@ sub HMinfo_status($){##########################################################
# - prot events if error # - prot events if error
my $hash = shift; my $hash = shift;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my @IDs = keys%{$modules{CUL_HM}{defptr}}; my ($nbrE,$nbrD,$nbrC,$nbrV) = (0,0,0,0);# count entities and types
my ($nbrE,$nbrD,$nbrC,$nbrV) = (scalar(@IDs),0,0,0);# count entities #--- used for status
my @crit = split ",",$attr{$name}{sumStatus};#prepare event my @crit = split ",",$attr{$name}{sumStatus};#prepare event
my %sum; my %sum;
#--- used for error counts
my @erro = split ",",$attr{$name}{sumERROR}; my @erro = split ",",$attr{$name}{sumERROR};
my %errFlt; my %errFlt;
my %err; my %err;
my @errNames; 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 ":",$_; 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); $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 $ehash = $modules{CUL_HM}{defptr}{$id};
my $eName = $ehash->{NAME}; my $eName = $ehash->{NAME};
$nbrE++;
$nbrC++ if ($ehash->{helper}{role}{chn}); $nbrC++ if ($ehash->{helper}{role}{chn});
$nbrV++ if ($ehash->{helper}{role}{vrt}); $nbrV++ if ($ehash->{helper}{role}{vrt});
foreach my $read (@crit){ foreach my $read (@crit){ #---- count critical readings
if ($ehash->{READINGS}{$read}){ next if (!$ehash->{READINGS}{$read});
my $val = $ehash->{READINGS}{$read}{VAL}; my $val = $ehash->{READINGS}{$read}{VAL};
$sum{$read}{$val} =0 if (!$sum{$read}{$val}); $sum{$read}{$val} =0 if (!$sum{$read}{$val});
$sum{$read}{$val}++; $sum{$read}{$val}++;
} }
} foreach my $read (keys %errFlt){ #---- count error readings
foreach my $read (keys %errFlt){ next if (!$ehash->{READINGS}{$read});
if ($ehash->{READINGS}{$read}){
my $val = $ehash->{READINGS}{$read}{VAL}; my $val = $ehash->{READINGS}{$read}{VAL};
next if (grep (/$val/,(keys%{$errFlt{$read}})));# filter non-Error next if (grep (/$val/,(keys%{$errFlt{$read}})));# filter non-Error
$err{$read}{$val} =0 if (!$err{$read}{$val}); $err{$read}{$val} =0 if (!$err{$read}{$val});
$err{$read}{$val}++; $err{$read}{$val}++;
push @errNames,$eName; push @errNames,$eName;
} }
} if ($ehash->{helper}{role}{dev}){#---restrict to devices
if ($ehash->{helper}{role}{dev}){#restrict to devices
$nbrD++; $nbrD++;
push @IOdev,$ehash->{IODev}{NAME} if($ehash->{IODev}); push @IOdev,$ehash->{IODev}{NAME} if($ehash->{IODev});
push @Anames,$eName if ($attr{$eName}{actStatus} && $attr{$eName}{actStatus} ne "alive"); push @Anames,$eName if ($attr{$eName}{actStatus} && $attr{$eName}{actStatus} ne "alive");
foreach (keys%prot){ foreach (keys%prot){# see if protocol events are to be reported
if ($ehash->{"prot".$_}){ next if (!$ehash->{"prot".$_});
$prot{$_}++; $prot{$_}++;
push @protNames,$eName; 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 foreach my $read(@crit){ #--- display critical counts
delete $hash->{$v} if($v =~ m/^(ERR_|sum_)/);
}
foreach my $read(@crit){
next if (!defined $sum{$read} ); next if (!defined $sum{$read} );
$hash->{"sum_".$read} = ""; $hash->{"sum_".$read} = "";
$hash->{"sum_".$read} .= "$_:$sum{$read}{$_};"foreach(keys %{$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} ); next if (!defined $err{$read} );
$hash->{"ERR_".$read} = ""; $hash->{"ERR_".$read} = "";
$hash->{"ERR_".$read} .= "$_:$err{$read}{$_};"foreach(keys %{$err{$read}}); $hash->{"ERR_".$read} .= "$_:$err{$read}{$_};"foreach(keys %{$err{$read}});
} }
delete $hash->{ERR_names}; 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"; $hash->{sumDefined} = "entities:$nbrE device:$nbrD channel:$nbrC virtual:$nbrV";
# ------- what about IO devices??? ------ # ------- display status of action detector ------
$hash->{actTotal} = $modules{CUL_HM}{defptr}{"000000"}{STATE};# display actionDetector $hash->{actTotal} = $modules{CUL_HM}{defptr}{"000000"}{STATE};
delete $hash->{ERRactNames} if(!@Anames); delete $hash->{ERRactNames} if(!@Anames);
$hash->{ERRactNames} = join",",@Anames; $hash->{ERRactNames} = join",",@Anames;