From ac697024d21b8ed1ec5a426ab066a3f9728a2b56 Mon Sep 17 00:00:00 2001 From: dirkho <> Date: Sat, 27 Jul 2013 21:58:30 +0000 Subject: [PATCH] Add event for state git-svn-id: https://svn.fhem.de/fhem/trunk@3512 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/51_I2C_BMP180.pm | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/fhem/FHEM/51_I2C_BMP180.pm b/fhem/FHEM/51_I2C_BMP180.pm index 8f181ed27..e63f64835 100644 --- a/fhem/FHEM/51_I2C_BMP180.pm +++ b/fhem/FHEM/51_I2C_BMP180.pm @@ -229,34 +229,24 @@ sub I2C_BMP180_Set($@) { ); my $altitude = AttrVal('global', 'altitude', 0); - my $txtAltitude = ''; - my $pressureNN = 0; - # if altitude given - if ($altitude != 0) { - # simple barometric height formula - $pressureNN = sprintf( - '%.' . AttrVal($hash->{NAME}, 'roundPressureDecimal', 1) . 'f', - $pressure + ($altitude / 8.5) - ); - - $txtAltitude = ' in ' . $altitude . ' m, Pressure-NN: ' . $pressureNN . ' hPa'; - } - + # simple barometric height formula + my $pressureNN = sprintf( + '%.' . AttrVal($hash->{NAME}, 'roundPressureDecimal', 1) . 'f', + $pressure + ($altitude / 8.5) + ); + readingsBeginUpdate($hash); readingsBulkUpdate( $hash, 'state', - 'Temp: ' . $temperature . ' °C , Pressure: ' . $pressure . ' hPa' . $txtAltitude, - 0 + 'T: ' . $temperature . ' P: ' . $pressure . ' P-NN: ' . $pressureNN ); readingsBulkUpdate($hash, 'temperature', $temperature); readingsBulkUpdate($hash, 'pressure', $pressure); - # if altitude given - if ($altitude >= 0) { - readingsBulkUpdate($hash, 'pressure-nn', $pressureNN); - } + readingsBulkUpdate($hash, 'pressure-nn', $pressureNN); + readingsBulkUpdate($hash, 'altitude', $altitude, 0); readingsEndUpdate($hash, 1); }