From 57a4bf4b087cf8564b962da683193a472511893a Mon Sep 17 00:00:00 2001 From: justme1968 Date: Wed, 11 Dec 2013 20:20:58 +0000 Subject: [PATCH] state bug fix git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@4363 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/36_LaCrosse.pm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fhem/FHEM/36_LaCrosse.pm b/fhem/FHEM/36_LaCrosse.pm index 8a047f602..351b8a9ac 100644 --- a/fhem/FHEM/36_LaCrosse.pm +++ b/fhem/FHEM/36_LaCrosse.pm @@ -176,6 +176,14 @@ LaCrosse_Parse($$) if( $type == 0x00 ) { $channel = "" if( $channel == 1 ); + if( my $resolution = AttrVal( $rname, "resolution", 0 ) ) { + $temperature = int($temperature*10 / $resolution + 0.5) * $resolution / 10; + $humidity = int($humidity / $resolution + 0.5) * $resolution; + + $temperature = int($temperature*10 + 0.5) / 10; + $humidity = int($humidity + 0.5) / 10; + } + if( AttrVal( $rname, "doAverage", 0 ) ) { $humidity = ($rhash->{"previousH$channel"}*3+$humidity)/4; $temperature = ($rhash->{"previousT$channel"}*3+$temperature)/4; @@ -187,13 +195,6 @@ LaCrosse_Parse($$) readingsBeginUpdate($rhash); - my $temperature = $temperature; - my $resolution = AttrVal( $rname, "resolution", 0 ); - if( $resolution ) { - $temperature = int($temperature*10 / $resolution + 0.5) * $resolution / 10; - $humidity = int($humidity / $resolution + 0.5) * $resolution; - } - readingsBulkUpdate($rhash, "temperature$channel", $temperature); readingsBulkUpdate($rhash, "humidity$channel", $humidity) if( $humidity && $humidity <= 99 ); @@ -207,7 +208,7 @@ LaCrosse_Parse($$) if( !$channel ) { my $state = "T: $temperature"; $state .= " H: $humidity" if( $humidity && $humidity <= 99 ); - $state .= " D: $humidity" if( $dewpoint ); + $state .= " D: $dewpoint" if( $dewpoint ); readingsBulkUpdate($rhash, "state", $state) if( Value($rname) ne $state ); }