mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
Changes by STefan
git-svn-id: https://svn.fhem.de/fhem/trunk@815 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7d77a6212a
commit
38ca84cf53
@ -946,7 +946,9 @@ CUL_SimpleRead($)
|
||||
my ($hash) = @_;
|
||||
|
||||
if($hash->{USBDev}) {
|
||||
return $hash->{USBDev}->input();
|
||||
my $buf = $hash->{USBDev}->input();
|
||||
#Log 1, "Got $buf";
|
||||
return $buf;
|
||||
}
|
||||
|
||||
if($hash->{TCPDev}) {
|
||||
@ -955,7 +957,6 @@ CUL_SimpleRead($)
|
||||
CUL_Disconnected($hash);
|
||||
return undef;
|
||||
}
|
||||
|
||||
return $buf;
|
||||
}
|
||||
return undef;
|
||||
|
@ -163,7 +163,7 @@ KS300_Parse($$)
|
||||
|
||||
# detect error condition
|
||||
# delta is negative or delta is too large
|
||||
# see http://de.wikipedia.org/wiki/Niederschlagsintensität#Niederschlagsintensit.C3.A4t
|
||||
# see http://de.wikipedia.org/wiki/Niederschlagsintensit??t#Niederschlagsintensit.C3.A4t
|
||||
# during a thunderstorm in middle europe, 50l/m^2 rain may fall per hour
|
||||
# 50l/(m^2*h) correspond to 200 ticks/h
|
||||
# Since KS300 sends every 2,5 minutes, a maximum delta of 8 ticks would
|
||||
@ -228,6 +228,7 @@ KS300_Parse($$)
|
||||
|
||||
# For logging/summary
|
||||
my $val = "T: $v[4] H: $v[3] W: $v[2] R: $v[1] IR: $v[5]";
|
||||
Log GetLogLevel($def->{NAME},4), "KS300 $dev: $val";
|
||||
$def->{STATE} = $val;
|
||||
$def->{CHANGED}[0] = $val;
|
||||
|
||||
|
@ -102,9 +102,12 @@ ESA2000_Parse($$)
|
||||
my $now = TimeNow();
|
||||
my (@v, @txt);
|
||||
|
||||
# ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
|
||||
# $year = $year + 1900;
|
||||
|
||||
if($type eq "ESA2000_LED") {
|
||||
|
||||
@txt = ( "repeat", "sequence", "total_ticks", "actual_ticks", "ticks_kwh", "raw", "total_kwh", "actual_kwh", "diff_kwh", "diff_sec", "diff_ticks", "last_sec", "raw_total_kwh", "max_kwh", "day_kwh", "month_kwh", "year_kwh" );
|
||||
@txt = ( "repeat", "sequence", "total_ticks", "actual_ticks", "ticks_kwh", "raw", "total_kwh", "actual_kwh", "diff_kwh", "diff_sec", "diff_ticks", "last_sec", "raw_total_kwh", "max_kwh", "day_kwh", "month_kwh", "year_kwh", "high_rate", "hr_kwh", "lr_kwh", "day_hr_kwh", "day_lr_kwh", "month_hr_kwh", "month_lr_kwh", "year_hr_kwh", "year_lr_kwh" );
|
||||
|
||||
|
||||
# Codierung Hex
|
||||
@ -114,9 +117,18 @@ ESA2000_Parse($$)
|
||||
$v[3] = hex(substr($val,8,4));
|
||||
$v[4] = hex(substr($val,18,4)) ^ 25; # XOR 25, whyever bit 1,4,5 are swapped?!?! Probably a (receive-) error in CUL-FW?
|
||||
|
||||
$v[5] = sprintf("CNT: %d%s CUM: %d CUR: %d TICKS: %d",
|
||||
$v[1], $v[0], $v[2], $v[3], $v[4]);
|
||||
$v[11] = time();
|
||||
# check if low-rate or high-rate. note that this is different per electricity company! (Here weekday from 6-20 is high rate)
|
||||
my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime;
|
||||
if ( (0 < $wday ) && ($wday < 6) && (5 < $hour) && ($hour < 20) ) {
|
||||
$v[17] = 1;
|
||||
} else {
|
||||
$v[17] = 0;
|
||||
}
|
||||
|
||||
$v[5] = sprintf("CNT: %d%s CUM: %d CUR: %d TICKS: %d %s",
|
||||
$v[1], $v[0], $v[2], $v[3], $v[4], $v[17] ? "HR" : "LR");
|
||||
|
||||
if (defined($def->{READINGS}{$txt[11]}{VAL})) {
|
||||
$v[9] = $v[11] - $def->{READINGS}{$txt[11]}{VAL}; # seconds since last update
|
||||
}
|
||||
@ -127,36 +139,83 @@ ESA2000_Parse($$)
|
||||
}
|
||||
$v[8] = $v[3]/$v[4]; # calculate kWh diff from readings (raw from device....), whats this relly?
|
||||
if(defined($def->{READINGS}{$txt[2]}{VAL})) {
|
||||
$v[10] = $v[2] - $def->{READINGS}{$txt[2]}{VAL}; # shoudl be the same as actual_ticks if no packets are lost
|
||||
if($def->{READINGS}{$txt[2]}{VAL} <=$v[2]) { # check for resetted counter.... only accept increase in counter
|
||||
$v[10] = $v[2] - $def->{READINGS}{$txt[2]}{VAL}; # shoudl be the same as actual_ticks if no packets are lost
|
||||
}
|
||||
}
|
||||
if(defined($v[10])) {
|
||||
$v[6] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[6]}{VAL}) ? $def->{READINGS}{$txt[6]}{VAL} : 0); # cumulate kWh to ensure tick-changes are calculated correctly (does this ever happen?)
|
||||
if(defined($def->{READINGS}{$txt[14]}{TIME})) {
|
||||
if(substr($now,0,10) eq substr($def->{READINGS}{$txt[14]}{TIME},0,10)) { # a bit clumsy, I agree, but it works and its logical and this is pearl, right?
|
||||
$v[14] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[14]}{VAL}) ? $def->{READINGS}{$txt[14]}{VAL} : 0); # cumulate kWh to ensure tick-changes are calculated correctly (does this ever happen?)
|
||||
if ($v[17]) {
|
||||
$v[18] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[18]}{VAL}) ? $def->{READINGS}{$txt[18]}{VAL} : 0); # high-rate
|
||||
} else {
|
||||
$v[19] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[19]}{VAL}) ? $def->{READINGS}{$txt[19]}{VAL} : 0); # low-rate
|
||||
}
|
||||
} else {
|
||||
$v[14] = $v[10]/$v[4]
|
||||
$v[14] = $v[10]/$v[4];
|
||||
if ($v[17]) {
|
||||
$v[18] = $v[10]/$v[4];
|
||||
} else {
|
||||
$v[19] = $v[10]/$v[4];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$v[14] = $v[10]/$v[4]
|
||||
$v[14] = $v[10]/$v[4];
|
||||
if ($v[17]) {
|
||||
$v[18] = $v[10]/$v[4];
|
||||
} else {
|
||||
$v[19] = $v[10]/$v[4];
|
||||
}
|
||||
}
|
||||
if(defined($def->{READINGS}{$txt[15]}{TIME})) {
|
||||
if(substr($now,0,7) eq substr($def->{READINGS}{$txt[15]}{TIME},0,7)) { # a bit clumsy, I agree, but it works and its logical and this is pearl, right?
|
||||
$v[15] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[15]}{VAL}) ? $def->{READINGS}{$txt[15]}{VAL} : 0); # cumulate kWh to ensure tick-changes are calculated correctly (does this ever happen?)
|
||||
if ($v[17]) {
|
||||
$v[20] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[20]}{VAL}) ? $def->{READINGS}{$txt[20]}{VAL} : 0); # high-rate
|
||||
} else {
|
||||
$v[21] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[21]}{VAL}) ? $def->{READINGS}{$txt[21]}{VAL} : 0); # low-rate
|
||||
}
|
||||
} else {
|
||||
$v[15] = $v[10]/$v[4]
|
||||
$v[15] = $v[10]/$v[4];
|
||||
if ($v[17]) {
|
||||
$v[20] = $v[10]/$v[4];
|
||||
} else {
|
||||
$v[21] = $v[10]/$v[4];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$v[15] = $v[10]/$v[4]
|
||||
$v[15] = $v[10]/$v[4];
|
||||
if ($v[17]) {
|
||||
$v[20] = $v[10]/$v[4];
|
||||
} else {
|
||||
$v[21] = $v[10]/$v[4];
|
||||
}
|
||||
}
|
||||
if(defined($def->{READINGS}{$txt[16]}{TIME})) {
|
||||
if(substr($now,0,4) eq substr($def->{READINGS}{$txt[16]}{TIME},0,4)) { # a bit clumsy, I agree, but it works and its logical and this is pearl, right?
|
||||
$v[16] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[16]}{VAL}) ? $def->{READINGS}{$txt[16]}{VAL} : 0); # cumulate kWh to ensure tick-changes are calculated correctly (does this ever happen?)
|
||||
if ($v[17]) {
|
||||
$v[22] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[22]}{VAL}) ? $def->{READINGS}{$txt[22]}{VAL} : 0); # high-rate
|
||||
} else {
|
||||
$v[23] = $v[10]/$v[4] + (defined($def->{READINGS}{$txt[23]}{VAL}) ? $def->{READINGS}{$txt[23]}{VAL} : 0); # low-rate
|
||||
}
|
||||
} else {
|
||||
$v[16] = $v[10]/$v[4]
|
||||
$v[16] = $v[10]/$v[4];
|
||||
if ($v[17]) {
|
||||
$v[22] = $v[10]/$v[4];
|
||||
} else {
|
||||
$v[23] = $v[10]/$v[4];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$v[16] = $v[10]/$v[4]
|
||||
$v[16] = $v[10]/$v[4];
|
||||
if ($v[17]) {
|
||||
$v[22] = $v[10]/$v[4];
|
||||
} else {
|
||||
$v[23] = $v[10]/$v[4];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$v[6] = 0;
|
||||
@ -185,8 +244,8 @@ ESA2000_Parse($$)
|
||||
$v[13] = $v[12] + $attr{$name}{"count_2"};
|
||||
}
|
||||
|
||||
$val = sprintf("CNT: %d%s CUM: %0.3f CUR: %0.3f TICKS: %d",
|
||||
$v[1], $v[0], $v[6], $v[7], $v[4]);
|
||||
$val = sprintf("CNT: %d%s CUM: %0.3f CUR: %0.3f TICKS: %d %s",
|
||||
$v[1], $v[0], $v[6], $v[7], $v[4], $v[17] ? "HR" : "LR");
|
||||
|
||||
} else {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user