mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
15_CUL_EM.pm: try a workaround for CUL_EM power shortage (Forum #55626)
git-svn-id: https://svn.fhem.de/fhem/trunk@12259 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
81d36a2188
commit
36e9002b14
@ -132,19 +132,23 @@ CUL_EM_Parse($$)
|
||||
$total_cnt_last= $hash->{READINGS}{total_cnt}{VAL};
|
||||
}
|
||||
|
||||
|
||||
# initialize basis_cnt_last
|
||||
my $basis_cnt = 0;
|
||||
if(defined($hash->{READINGS}{basis})) {
|
||||
$basis_cnt = $hash->{READINGS}{basis}{VAL};
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# translate into device units
|
||||
#
|
||||
my $corr1 = $hash->{corr1}; # EMEM power correction factor
|
||||
my $corr2 = $hash->{corr2}; # EMEM energy correction factor
|
||||
my $counter_offset = AttrVal($n,"CounterOffset",0);
|
||||
my $oldraw = ReadingsVal($n, "RAW", ""); # Forum #55626
|
||||
my $basis_cnt = ReadingsVal($n, "basis", 0);
|
||||
if($oldraw) {
|
||||
my @a = split(" ", $oldraw);
|
||||
if($a[3] > $total_cnt) {
|
||||
$basis_cnt += ($a[3]+$total_cnt)/$corr2;
|
||||
readingsSingleUpdate($hash, "basis", $basis_cnt, 0);
|
||||
Log 1, "$n was reset, old CUM $a[3], new CUM: $total_cnt, ".
|
||||
"new basis $basis_cnt";
|
||||
}
|
||||
}
|
||||
|
||||
my $peak;
|
||||
|
||||
@ -177,7 +181,6 @@ CUL_EM_Parse($$)
|
||||
$basis_cnt += ($total_cnt_last > 65000 ? 65536 : $total_cnt_last);
|
||||
$readings{basis} = $basis_cnt;
|
||||
}
|
||||
my $counter_offset = AttrVal($n,"CounterOffset",0);
|
||||
|
||||
my $total = (($basis_cnt+$total_cnt)*$corr2)+$counter_offset;
|
||||
my $current = $current_cnt*$corr1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user