mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +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/fhem@12259 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
2828c4e433
commit
e410d9cad1
@ -98,7 +98,7 @@ CUL_EM_Parse($$)
|
|||||||
# basis_cnt= correction to total (cumulated) value in ticks to account for
|
# basis_cnt= correction to total (cumulated) value in ticks to account for
|
||||||
# counter wraparounds
|
# counter wraparounds
|
||||||
# total = total (cumulated) value in device units
|
# total = total (cumulated) value in device units
|
||||||
# current_cnt = current value (average over latest 5 minutes) in device units
|
# current_cnt = current value (average over latest 5 minutes) in device units
|
||||||
# peak = maximum value in device units
|
# peak = maximum value in device units
|
||||||
|
|
||||||
my $seqno = hex($a[5].$a[6]);
|
my $seqno = hex($a[5].$a[6]);
|
||||||
@ -132,19 +132,23 @@ CUL_EM_Parse($$)
|
|||||||
$total_cnt_last= $hash->{READINGS}{total_cnt}{VAL};
|
$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
|
# translate into device units
|
||||||
#
|
#
|
||||||
my $corr1 = $hash->{corr1}; # EMEM power correction factor
|
my $corr1 = $hash->{corr1}; # EMEM power correction factor
|
||||||
my $corr2 = $hash->{corr2}; # EMEM energy 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;
|
my $peak;
|
||||||
|
|
||||||
@ -177,7 +181,6 @@ CUL_EM_Parse($$)
|
|||||||
$basis_cnt += ($total_cnt_last > 65000 ? 65536 : $total_cnt_last);
|
$basis_cnt += ($total_cnt_last > 65000 ? 65536 : $total_cnt_last);
|
||||||
$readings{basis} = $basis_cnt;
|
$readings{basis} = $basis_cnt;
|
||||||
}
|
}
|
||||||
my $counter_offset = AttrVal($n,"CounterOffset",0);
|
|
||||||
|
|
||||||
my $total = (($basis_cnt+$total_cnt)*$corr2)+$counter_offset;
|
my $total = (($basis_cnt+$total_cnt)*$corr2)+$counter_offset;
|
||||||
my $current = $current_cnt*$corr1;
|
my $current = $current_cnt*$corr1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user