mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
CostPerUnit documented for Klaus.
git-svn-id: https://svn.fhem.de/fhem/trunk@416 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
341bc6695c
commit
6b606d8f8b
@ -519,3 +519,4 @@
|
||||
- bugfix: Avoid unitialized in xmllist for corrupt readings (reporter: Boris)
|
||||
- bugfix: Add binmode to 01_fhemweb.pm for windows
|
||||
- bugfix: Uniform check for windows, enable CUL for windows.
|
||||
- bugfix: CUL/HMS parsing patches from Peter
|
||||
|
@ -6,6 +6,9 @@ use warnings;
|
||||
|
||||
my %defptr;
|
||||
|
||||
# Adjust TOTAL to you meter:
|
||||
# {$defs{emwz}{READINGS}{basis}{VAL}=<meter>/<corr2>-<total_cnt> }
|
||||
|
||||
#####################################
|
||||
sub
|
||||
CUL_EM_Initialize($)
|
||||
@ -38,9 +41,9 @@ CUL_EM_Define($$)
|
||||
|
||||
if($a[2] >= 1 && $a[2] <= 4) { # EMWZ: nRotation in 5 minutes
|
||||
my $c = (int(@a) > 3 ? $a[3] : 150);
|
||||
$hash->{corr1} = (12/$c);
|
||||
$c = (int(@a) > 4 ? $a[4] : 150);
|
||||
$hash->{corr2} = (12/$c);
|
||||
$hash->{corr1} = (12/$c); # peak/current
|
||||
$c = (int(@a) > 4 ? $a[4] : 1800);
|
||||
$hash->{corr2} = (12/$c); # total
|
||||
|
||||
} elsif($a[2] >= 5 && $a[2] <= 8) { # EMEM
|
||||
# corr1 is the correction factor for power
|
||||
@ -120,27 +123,22 @@ CUL_EM_Parse($$)
|
||||
# calculate readings
|
||||
#
|
||||
# initialize total_cnt_last
|
||||
my $total_cnt_last;
|
||||
my $total_cnt_last = 0;
|
||||
if(defined($hash->{READINGS}{total_cnt})) {
|
||||
$total_cnt_last= $hash->{READINGS}{total_cnt}{VAL};
|
||||
} else {
|
||||
$total_cnt_last= 0;
|
||||
$total_cnt_last= $hash->{READINGS}{total_cnt}{VAL};
|
||||
}
|
||||
|
||||
|
||||
# initialize basis_cnt_last
|
||||
my $basis_cnt_last;
|
||||
my $basis_cnt = 0;
|
||||
if(defined($hash->{READINGS}{basis})) {
|
||||
$basis_cnt_last= $hash->{READINGS}{basis}{VAL};
|
||||
} else {
|
||||
$basis_cnt_last= 0;
|
||||
$basis_cnt = $hash->{READINGS}{basis}{VAL};
|
||||
}
|
||||
|
||||
# correct counter wraparound
|
||||
my $basis_cnt= $basis_cnt_last;
|
||||
if($total_cnt< $total_cnt_last) {
|
||||
$basis_cnt += 65536;
|
||||
$readings{basis} = $basis_cnt;
|
||||
$basis_cnt += 65536;
|
||||
$readings{basis} = $basis_cnt;
|
||||
}
|
||||
|
||||
#
|
||||
@ -171,42 +169,55 @@ CUL_EM_Parse($$)
|
||||
# Start CUMULATE day and month
|
||||
Log GetLogLevel($n,4), "CUL_EM $n: $val";
|
||||
my $tsecs_prev;
|
||||
|
||||
#----- get previous tsecs
|
||||
if(defined($hash->{READINGS}{tsecs})) {
|
||||
$tsecs_prev= $hash->{READINGS}{tsecs}{VAL};
|
||||
} else {
|
||||
$tsecs_prev= 0; # 1970-01-01
|
||||
}
|
||||
|
||||
#----- save actual tsecs
|
||||
my $tsecs= time(); # number of non-leap seconds since January 1, 1970, UTC
|
||||
$readings{tsecs} = $tsecs;
|
||||
|
||||
#----- get cost parameter
|
||||
my $cost = $hash->{CostPerUnit};
|
||||
my $basicfee = $hash->{BasicFeePerMonth};
|
||||
|
||||
#----- check whether day or month was changed
|
||||
if(!defined($hash->{READINGS}{cum_day})) {
|
||||
#----- init cum_day if it is not set
|
||||
$val = sprintf("CUM_DAY: %0.3f CUM: %0.3f COST: %0.2f", 0,$total,0);
|
||||
$readings{cum_day} = $val;
|
||||
|
||||
} else {
|
||||
|
||||
if( (localtime($tsecs_prev))[3] != (localtime($tsecs))[3] ) {
|
||||
#----- day has changed (#3)
|
||||
my @cmv = split(" ", $hash->{READINGS}{cum_day}{VAL});
|
||||
$val = sprintf("CUM_DAY: %0.3f CUM: %0.3f COST: %0.2f", $total-$cmv[3], $total, ($total-$cmv[3])*$cost);
|
||||
$val = sprintf("CUM_DAY: %0.3f CUM: %0.3f COST: %0.2f",
|
||||
$total-$cmv[3], $total, ($total-$cmv[3])*$cost);
|
||||
$readings{cum_day} = $val;
|
||||
Log GetLogLevel($n,3), "CUL_EM $n: $val";
|
||||
#
|
||||
|
||||
|
||||
if( (localtime($tsecs_prev))[4] != (localtime($tsecs))[4] ) {
|
||||
|
||||
#----- month has changed (#4)
|
||||
if(!defined($hash->{READINGS}{cum_month})) {
|
||||
# init cum_month if not set
|
||||
$val = sprintf("CUM_MONTH: %0.3f CUM: %0.3f COST: %0.2f", 0,$total,0);
|
||||
$val = sprintf("CUM_MONTH: %0.3f CUM: %0.3f COST: %0.2f",
|
||||
0, $total, 0);
|
||||
$readings{cum_month} = $val;
|
||||
|
||||
} else {
|
||||
@cmv = split(" ", $hash->{READINGS}{cum_month}{VAL});
|
||||
$val = sprintf("CUM_MONTH: %0.3f CUM: %0.3f COST: %0.2f", $total-$cmv[3],$total,($total-$cmv[3])*$cost+$basicfee);
|
||||
$val = sprintf("CUM_MONTH: %0.3f CUM: %0.3f COST: %0.2f",
|
||||
$total-$cmv[3], $total,($total-$cmv[3])*$cost+$basicfee);
|
||||
$readings{cum_month} = $val;
|
||||
Log GetLogLevel($n,3), "CUL_EM $n: $val";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1666,20 +1666,47 @@ A line ending with \ will be concatenated with the next one, so long lines
|
||||
from EMEM, EMWZ or EMGZ devices.
|
||||
<br><br>
|
||||
|
||||
<a name="CUL_WSdefine"></a>
|
||||
<a name="CUL_EMdefine"></a>
|
||||
<b>Define</b>
|
||||
<ul>
|
||||
<code>define <name> CUL_EM <code> [corr]</code> <br>
|
||||
<code>define <name> CUL_EM <code> [corr1 corr2
|
||||
CostPerUnit BasicFeePerMonth]</code> <br>
|
||||
<br>
|
||||
<code> is the code which must be set on the EM device. Valid values
|
||||
are 1 through 12. 1-4 denotes EMWZ, 5-8 EMEM and 9-12 EMGZ devices.<br>
|
||||
corr (if specified) will be multiplied to the value delivered in the
|
||||
message.<br>
|
||||
are 1 through 12. 1-4 denotes EMWZ, 5-8 EMEM and 9-12 EMGZ devices.<br><br>
|
||||
|
||||
<b>corr1</b> is used to correct the current number, <b>corr2</b>
|
||||
for the total number.
|
||||
<ul>
|
||||
<li>for EMWZ devices you should specify the rotation speed (R/kW)
|
||||
of your watt-meter (e.g. 150)</li>
|
||||
<li>for EMEM devices the correct value is 0.01.</li>
|
||||
of your watt-meter (e.g. 150) for corr1 and 12 times this value for
|
||||
corr2</li>
|
||||
<li>for EMEM devices the corr1 value is 0.01, and the corr2 value is
|
||||
0.001 </li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<b>CostPerUnit</b> and <b>BasicFeePerMonth</b> are used to compute your
|
||||
daily and mothly fees. Your COST will appear in the log, generated once
|
||||
daiy (without the basic fee) or month (with the bassic fee included). Your
|
||||
definition should look like E.g.:
|
||||
<pre>
|
||||
define emwz 1 75 900 0.15 12.50</pre>
|
||||
and the Log looks like:
|
||||
<pre>
|
||||
CUM_DAY: 6.849 CUM: 60123.4 COST: 1.02
|
||||
CUM_MONTH: 212.319 CUM: 60123.4 COST: 44.34</pre>
|
||||
|
||||
Tipp: You can configure your EMWZ device to show in the CUM column of the
|
||||
STATE reading the current reading of your meter. For this purpose: multiply
|
||||
the current reading (from the real device) with the corr1 value (RperKW),
|
||||
and substract the RAW CUM value from it. Now set the basis reading of your
|
||||
EMWZ device (named emwz) to this value:<br>
|
||||
|
||||
<pre>
|
||||
{ $defs{emwz}{READINGS}{basis}{VAL} = <computedvalue> }</pre>
|
||||
|
||||
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user