09_USF1000.pm: suppress inplausible readings from USF1000
git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@429 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
1
CHANGED
1
CHANGED
@@ -523,3 +523,4 @@
|
|||||||
- bugfix: Fixes for Windows by Klaus
|
- bugfix: Fixes for Windows by Klaus
|
||||||
- bugfix: Another "rereadcfg" bugfix
|
- bugfix: Another "rereadcfg" bugfix
|
||||||
- feature: Update to the current (1.27) CUL FHT interface
|
- feature: Update to the current (1.27) CUL FHT interface
|
||||||
|
- feature: suppress inplausible readings from USF1000
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ USF1000_Parse($$)
|
|||||||
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
|
return "" if($def->{IODev} && $def->{IODev}{NAME} ne $hash->{NAME});
|
||||||
|
|
||||||
|
|
||||||
|
my $t= TimeNow();
|
||||||
|
|
||||||
# Msg format:
|
# Msg format:
|
||||||
# 01 23 45 67 8901 2345 6789 01 23 45 67
|
# 01 23 45 67 8901 2345 6789 01 23 45 67
|
||||||
# 81 0c 04 .. 0101 a001 a5ce aa 00 cc xx
|
# 81 0c 04 .. 0101 a001 a5ce aa 00 cc xx
|
||||||
@@ -112,7 +114,10 @@ USF1000_Parse($$)
|
|||||||
my $lowbattery= (hex($cc) & 0x40 ? 1 : 0);
|
my $lowbattery= (hex($cc) & 0x40 ? 1 : 0);
|
||||||
my $testmode= (hex($cc) & 0x80 ? 1 : 0);
|
my $testmode= (hex($cc) & 0x80 ? 1 : 0);
|
||||||
my $distance= hex($xx)/100.0; # in meters
|
my $distance= hex($xx)/100.0; # in meters
|
||||||
|
my $valid= (($distance>0.00) && ($distance<2.55));
|
||||||
|
|
||||||
|
|
||||||
|
if($valid) {
|
||||||
my $wlevel = $def->{HEIGHT}-($distance-$def->{OFFSET}); # water level
|
my $wlevel = $def->{HEIGHT}-($distance-$def->{OFFSET}); # water level
|
||||||
|
|
||||||
my $geometry= $def->{GEOMETRY};
|
my $geometry= $def->{GEOMETRY};
|
||||||
@@ -120,7 +125,6 @@ USF1000_Parse($$)
|
|||||||
my $volume; # current volume in tank in liters
|
my $volume; # current volume in tank in liters
|
||||||
my $flevel; # fill level in percent
|
my $flevel; # fill level in percent
|
||||||
|
|
||||||
|
|
||||||
if($geometry eq "cub") {
|
if($geometry eq "cub") {
|
||||||
# cuboid
|
# cuboid
|
||||||
$volume = $def->{LENGTH}*$def->{WIDTH}*$wlevel*1000.0;
|
$volume = $def->{LENGTH}*$def->{WIDTH}*$wlevel*1000.0;
|
||||||
@@ -134,7 +138,6 @@ USF1000_Parse($$)
|
|||||||
$flevel = int($volume/$capacity*100.0+0.5);
|
$flevel = int($volume/$capacity*100.0+0.5);
|
||||||
$volume= int($volume/10.0+0.5)*10.0;
|
$volume= int($volume/10.0+0.5)*10.0;
|
||||||
|
|
||||||
my $t= TimeNow();
|
|
||||||
|
|
||||||
my $state= sprintf("v: %d V: %d", $flevel, $volume);
|
my $state= sprintf("v: %d V: %d", $flevel, $volume);
|
||||||
|
|
||||||
@@ -150,6 +153,7 @@ USF1000_Parse($$)
|
|||||||
$def->{READINGS}{level}{VAL} = $flevel;
|
$def->{READINGS}{level}{VAL} = $flevel;
|
||||||
$def->{READINGS}{volume}{TIME} = $t;
|
$def->{READINGS}{volume}{TIME} = $t;
|
||||||
$def->{READINGS}{volume}{VAL} = $volume;
|
$def->{READINGS}{volume}{VAL} = $volume;
|
||||||
|
}
|
||||||
|
|
||||||
my $warnings= ($lowbattery ? "Battery low" : "");
|
my $warnings= ($lowbattery ? "Battery low" : "");
|
||||||
if($testmode) {
|
if($testmode) {
|
||||||
|
|||||||
Reference in New Issue
Block a user