mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
15_CUL_EM.pm: added attribute "maxPeak" to make
device readings more robust git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@6825 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
81b9e0f7c9
commit
a25ae072b9
@ -23,6 +23,7 @@ CUL_EM_Initialize($)
|
|||||||
$hash->{ParseFn} = "CUL_EM_Parse";
|
$hash->{ParseFn} = "CUL_EM_Parse";
|
||||||
$hash->{AttrList} = "IODev do_not_notify:0,1 showtime:0,1 " .
|
$hash->{AttrList} = "IODev do_not_notify:0,1 showtime:0,1 " .
|
||||||
"model:EMEM,EMWZ,EMGZ ignore:0,1 ".
|
"model:EMEM,EMWZ,EMGZ ignore:0,1 ".
|
||||||
|
"maxPeak ".
|
||||||
$readingFnAttributes;
|
$readingFnAttributes;
|
||||||
$hash->{AutoCreate}=
|
$hash->{AutoCreate}=
|
||||||
{ "CUL_EM.*" => { GPLOT => "power8:Power,", FILTER => "%NAME:CNT.*" } };
|
{ "CUL_EM.*" => { GPLOT => "power8:Power,", FILTER => "%NAME:CNT.*" } };
|
||||||
@ -138,12 +139,6 @@ CUL_EM_Parse($$)
|
|||||||
$basis_cnt = $hash->{READINGS}{basis}{VAL};
|
$basis_cnt = $hash->{READINGS}{basis}{VAL};
|
||||||
}
|
}
|
||||||
|
|
||||||
# correct counter wraparound
|
|
||||||
if($total_cnt < $total_cnt_last) {
|
|
||||||
# check: real wraparound or reset only
|
|
||||||
$basis_cnt += ($total_cnt_last > 65000 ? 65536 : $total_cnt_last);
|
|
||||||
$readings{basis} = $basis_cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# translate into device units
|
# translate into device units
|
||||||
@ -151,18 +146,44 @@ CUL_EM_Parse($$)
|
|||||||
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 $total = ($basis_cnt+$total_cnt)*$corr2;
|
my $peak;
|
||||||
my $current = $current_cnt*$corr1;
|
|
||||||
my $peak = $peak_cnt*$corr1;
|
|
||||||
|
|
||||||
if($tpe ne 2) {
|
if($tpe ne 2) {
|
||||||
$peak = 3000/($peak_cnt > 1 ? $peak_cnt : 1)*$corr1;
|
$peak = $current_cnt && $peak_cnt ? 3000/$peak_cnt*$corr1 : 0;
|
||||||
$peak = ($current > 0 ? $peak : 0);
|
# when EM detection toggles/glitches somewhere the internal
|
||||||
|
# EM-Counter increments by one and the device registers a
|
||||||
|
# very hi peak value
|
||||||
|
# Here we fix this by checking against a maximum peak
|
||||||
|
# level, removing the wrong counter increment and
|
||||||
|
# setting peak to the current value.
|
||||||
|
my $maxpeak = $attr{$n}{"maxPeak"};
|
||||||
|
if(defined $maxpeak and $peak > $maxpeak){
|
||||||
|
Log3 $n, 2,
|
||||||
|
"CUL_EM $n: max peak detected: $peak kW > $maxpeak kW";
|
||||||
|
$current_cnt--;
|
||||||
|
# as total_cnt is "owned" by EM we decrement our basis_cnt
|
||||||
|
$basis_cnt--;
|
||||||
|
$readings{basis} = $basis_cnt;
|
||||||
|
$peak = $current_cnt*$corr1;
|
||||||
|
$peak_cnt = $peak ? int(3000*$corr1/$peak) : 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$peak = $peak_cnt*$corr1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# correct counter wraparound
|
||||||
|
if($total_cnt < $total_cnt_last) {
|
||||||
|
# check: real wraparound or reset only
|
||||||
|
$basis_cnt += ($total_cnt_last > 65000 ? 65536 : $total_cnt_last);
|
||||||
|
$readings{basis} = $basis_cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $total = ($basis_cnt+$total_cnt)*$corr2;
|
||||||
|
my $current = $current_cnt*$corr1;
|
||||||
|
|
||||||
$val = sprintf("CNT: %d CUM: %0.3f 5MIN: %0.3f TOP: %0.3f",
|
$val = sprintf("CNT: %d CUM: %0.3f 5MIN: %0.3f TOP: %0.3f",
|
||||||
$seqno, $total, $current, $peak);
|
$seqno, $total, $current, $peak);
|
||||||
|
|
||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
readingsBulkUpdate($hash, "state", $val);
|
readingsBulkUpdate($hash, "state", $val);
|
||||||
|
|
||||||
@ -321,7 +342,15 @@ CUL_EM_Parse($$)
|
|||||||
<li><a href="#model">model</a> (EMEM,EMWZ,EMGZ)</li><br>
|
<li><a href="#model">model</a> (EMEM,EMWZ,EMGZ)</li><br>
|
||||||
<li><a href="#IODev">IODev</a></li><br>
|
<li><a href="#IODev">IODev</a></li><br>
|
||||||
<li><a href="#eventMap">eventMap</a></li><br>
|
<li><a href="#eventMap">eventMap</a></li><br>
|
||||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
|
<li><a href="#readingFnAttributes">readingFnAttributes</a></li><br>
|
||||||
|
<li><a name="maxPeak">maxPeak</a> <number><br>
|
||||||
|
Specifies the maximum possible peak value for the EM meter
|
||||||
|
("TOP:" value in logfile). Peak values greater than this value
|
||||||
|
are considered as EM read errors and are ignored.
|
||||||
|
For example if it's not possible to consume more than 40kW of
|
||||||
|
power set maxPeak to 40 to make the readings of the power meter
|
||||||
|
more robust.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
@ -395,7 +424,15 @@ CUL_EM_Parse($$)
|
|||||||
<li><a href="#model">model</a> (EMEM,EMWZ,EMGZ)</li><br>
|
<li><a href="#model">model</a> (EMEM,EMWZ,EMGZ)</li><br>
|
||||||
<li><a href="#IODev">IODev</a></li><br>
|
<li><a href="#IODev">IODev</a></li><br>
|
||||||
<li><a href="#eventMap">eventMap</a></li><br>
|
<li><a href="#eventMap">eventMap</a></li><br>
|
||||||
<li><a href="#readingFnAttributes">readingFnAttributes</a></li>
|
<li><a href="#readingFnAttributes">readingFnAttributes</a></li><br>
|
||||||
|
<li><a name="maxPeak">maxPeak</a> <number><br>
|
||||||
|
Gibt den maximal möglichen Spitzenwert für das EM-Meter an
|
||||||
|
("TOP:"-Wert in Logdatei). Spitzenwerte größer als dieser
|
||||||
|
Wert gelten als EM-Lesefehler und werden ignoriert.
|
||||||
|
Wenn es z.B. nicht möglich ist mehr zu 40kW Leistung
|
||||||
|
zu beziehen setzt man maxPeak auf 40 um das Auslesen des
|
||||||
|
Stromzählers robuster zu machen.
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user