2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-22 20:24:36 +00:00

Add event for state

git-svn-id: https://svn.fhem.de/fhem/trunk@3512 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
dirkho 2013-07-27 21:58:30 +00:00
parent 156ce16261
commit ac697024d2

View File

@ -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);
}