mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 02:10:32 +00:00
12_HProtocolGateway: fix Filllevel decimal, Strapping table linear interpolation
git-svn-id: https://svn.fhem.de/fhem/trunk@17508 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
753440b287
commit
55ed9026fa
@ -28,6 +28,7 @@ package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
use DevIo;
|
||||
use Math::Round qw/round/;
|
||||
|
||||
my @tankList = undef;
|
||||
|
||||
@ -192,8 +193,8 @@ sub HProtocolGateway_ParseMessage($$) {
|
||||
# convert to HEX
|
||||
$check = sprintf '%02X', $check;
|
||||
|
||||
# Unitronics Vision130
|
||||
if ($water == 0 && $temperature == 0 && $probe_offset == 0 && $version == 0 && $error == 0 && $checksum == 0 ) {
|
||||
# Unitronics
|
||||
if ($version == 0 && $error == 0 && $checksum == 0) {
|
||||
$check = 0;
|
||||
}
|
||||
|
||||
@ -203,7 +204,7 @@ sub HProtocolGateway_ParseMessage($$) {
|
||||
my $mode = AttrVal($tankHash->{NAME},"mode","");
|
||||
|
||||
if ($mode eq "FillLevel") {
|
||||
$filllevel = $tankdata;
|
||||
$filllevel = $tankdata/100;
|
||||
$volume = HProtocolGateway_Tank($hash,$tankHash,$filllevel);
|
||||
} elsif ($mode eq "Volume") {
|
||||
$volume = $tankdata;
|
||||
@ -363,14 +364,17 @@ sub HProtocolGateway_Tank($$$) {
|
||||
}
|
||||
close $fh;
|
||||
|
||||
my $messwert = $filllevel/100;
|
||||
my $volume = 0;
|
||||
|
||||
my $volume1 = 0;
|
||||
my $level1 = 0;
|
||||
foreach my $level (sort keys %TankChartHash) {
|
||||
if ($level ne "level" && $messwert <= $level) {
|
||||
$volume = $TankChartHash{$level};
|
||||
if ($level ne "level" && $filllevel <= $level) {
|
||||
$volume = $volume1 + ($TankChartHash{$level} - $volume1) / ($level - $level1) * ($filllevel-$level1);
|
||||
$volume = Math::Round::nearest('0.01',$volume);
|
||||
last;
|
||||
}
|
||||
$level1 = $level;
|
||||
$volume1 = $TankChartHash{$level};
|
||||
}
|
||||
return $volume;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ sub HProtocolTank_Attr (@) {
|
||||
<li>waterlevel<br />
|
||||
0..9999 Water level in mm</li>
|
||||
<li>probe_offset<br />
|
||||
-9999 - +9999 Probe offset in mm)</li>
|
||||
-9999 - +9999 Probe offset in mm</li>
|
||||
<li>version<br />
|
||||
00..999 Software version</li>
|
||||
<li>error<br />
|
||||
|
Loading…
x
Reference in New Issue
Block a user