From a7e2740c65681030851e05e6ef87c358cef15926 Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Thu, 20 Nov 2014 20:08:00 +0000 Subject: [PATCH] 36_LaCrosse.pm: added corr1 and corr2 correction offsets git-svn-id: https://svn.fhem.de/fhem/trunk@7027 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/36_LaCrosse.pm | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/fhem/FHEM/36_LaCrosse.pm b/fhem/FHEM/36_LaCrosse.pm index 1c1f62ae1..82aaf57ec 100644 --- a/fhem/FHEM/36_LaCrosse.pm +++ b/fhem/FHEM/36_LaCrosse.pm @@ -39,8 +39,8 @@ LaCrosse_Define($$) my ($hash, $def) = @_; my @a = split("[ \t][ \t]*", $def); - if(@a != 3 ) { - my $msg = "wrong syntax: define LaCrosse "; + if(int(@a) < 3 || int(@a) > 5) { + my $msg = "wrong syntax: define LaCrosse [corr1...corr2]"; Log3 undef, 2, $msg; return $msg; } @@ -51,6 +51,12 @@ LaCrosse_Define($$) my $name = $a[0]; my $addr = $a[2]; + $hash->{corr1} = ((int(@a) > 3) ? $a[3] : 0); + $hash->{corr2} = ((int(@a) > 4) ? $a[4] : 0); + #$hash->{corr3} = ((int(@a) > 5) ? $a[5] : 0); + #$hash->{corr4} = ((int(@a) > 6) ? $a[6] : 0); + + #return "$addr is not a 1 byte hex value" if( $addr !~ /^[\da-f]{2}$/i ); #return "$addr is not an allowed address" if( $addr eq "00" ); @@ -263,12 +269,12 @@ LaCrosse_Parse($$) $temperature = int($temperature*10 + 0.5) / 10; $humidity = int($humidity*10 + 0.5) / 10; - readingsBulkUpdate($rhash, "temperature$channel", $temperature); - readingsBulkUpdate($rhash, "humidity$channel", $humidity) if( $humidity && $humidity <= 99 ); + readingsBulkUpdate($rhash, "temperature$channel", $temperature + $rhash->{corr1}); + readingsBulkUpdate($rhash, "humidity$channel", $humidity + $rhash->{corr2} ) if( $humidity && $humidity <= 99 ); if( !$channel ) { - my $state = "T: $temperature"; - $state .= " H: $humidity" if( $humidity && $humidity <= 99 ); + my $state = "T: ". ($temperature + $rhash->{corr1}); + $state .= " H: ". ($humidity + $rhash->{corr2}) if( $humidity && $humidity <= 99 ); $state .= " D: $dewpoint" if( $dewpoint ); readingsBulkUpdate($rhash, "state", $state) if( Value($rname) ne $state ); } @@ -314,9 +320,10 @@ LaCrosse_Attr(@) Define
    - define <name> LaCrosse <addr>
    + define <name> LaCrosse <addr> [corr1...corr2]

    - addr is a 2 digit hex number to identify the LaCrosse device.

    + addr is a 2 digit hex number to identify the LaCrosse device.
    + corr1..corr2 are up to 2 numerical correction factors, which will be added to the respective value to calibrate the device.

    Note: devices are autocreated only if LaCrossePairForSec is active for the JeeLink IODevice device.