2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 23:06:37 +00:00

HMInfo:cleanup unused shadowregs

git-svn-id: https://svn.fhem.de/fhem/trunk@11522 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinp876 2016-05-26 08:01:33 +00:00
parent cbdc9e22cb
commit 9a421775fb
2 changed files with 26 additions and 4 deletions

View File

@ -1281,8 +1281,8 @@ sub CUL_HM_Parse($$) {#########################################################
my $ack = $mh{devH}->{helper}{rpt}{ack};#shorthand
my $i=0;
$mh{devH}->{helper}{rpt}{ts} = gettimeofday();
CUL_HM_SndCmd($mh{$ack}[$i++],$mh{$ack}[$i++]
.(defined $mh{devH}->{helper}{aesAuthBytes}
CUL_HM_SndCmd(${$ack}[$i++],${$ack}[$i++]
.($mh{devH}->{helper}{aesAuthBytes}
?$mh{devH}->{helper}{aesAuthBytes}
:"")
) while ($i<@{$ack});
@ -7227,7 +7227,6 @@ sub CUL_HM_getRegFromStore($$$$@) {#read a register from backup data
my $rRL = ($hash->{READINGS}{$regLN}) #realRegList
?$hash->{READINGS}{$regLN}{VAL}
:"";
my $data=0;
my $convFlg = "";# confirmation flag - indicates data not confirmed by device
for (my $size2go = $size;$size2go>0;$size2go -=8){
@ -8708,6 +8707,27 @@ sub CUL_HM_configUpdate($) {# mark entities with changed data
CUL_HM_noDup(@{$modules{CUL_HM}{helper}{confUpdt}},$name);
}
sub CUL_HM_cleanShadowReg($){
# remove shadow-regs if those are identical to readings or
# the reading does not exist.
# return dirty "1" if some shadowregs still remain active
my ($name) = @_;
my $hash = $defs{$name};
my $dirty = 0;
foreach my $rLn (keys %{$hash->{helper}{shadowReg}}){
my $rLnP = ($hash->{helper}{expert}{raw}?"":".").$rLn;
if ( !$hash->{READINGS}{$rLnP}
|| $hash->{READINGS}{$rLnP}{VAL} eq $hash->{helper}{shadowReg}{$rLn}){
delete $hash->{helper}{shadowReg}{$rLn};
}
else{
$dirty = 1;
}
}
return $dirty;
}
#+++++++++++++++++ templates ++++++++++++++++++++++++++++++++++++++++++++++++++
sub CUL_HM_tempListTmpl(@) { ##################################################
# $name is comma separated list of names

View File

@ -223,7 +223,9 @@ sub HMinfo_status($){##########################################################
$nbrE++;
$nbrC++ if ($ehash->{helper}{role}{chn});
$nbrV++ if ($ehash->{helper}{role}{vrt});
push @shdwNames,$eName if (keys %{$ehash->{helper}{shadowReg}});
push @shdwNames,$eName if (CUL_HM_cleanShadowReg($eName)); # are shadowRegs active?
foreach my $read (grep {$ehash->{READINGS}{$_}} @info){ #---- count critical readings
my $val = $ehash->{READINGS}{$read}{VAL};
$sum{$read}{$val} =0 if (!$sum{$read}{$val});