From 220929854ed2e827c744b13a352fdb78a502876e Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sat, 14 Aug 2010 11:42:46 +0000 Subject: [PATCH] sanity checks for CUL_WS git-svn-id: https://svn.fhem.de/fhem/trunk@696 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 8 ++++- fhem/FHEM/14_CUL_WS.pm | 79 +++++++++++++++++++----------------------- fhem/TODO | 3 +- fhem/docs/HOWTO.html | 3 ++ fhem/docs/fhem.html | 30 +++++++++------- 5 files changed, 65 insertions(+), 58 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index fb86d8e42..d41a96ee2 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,4 +1,4 @@ -- =DATE= (4.10) +- =DATE= (5.0) - feature: KM271 - bugfix: 99_SUNRISE_EL endless loop bug - feature: CUL: optional baudrate spec in definition @@ -15,6 +15,12 @@ are connected, adjust matching rule - feature: Copy&Paste in SVG - feature: Debian/Ubuntu Package. Install-path changes to satisfy lintian + - feature: Allnet 3076/4027/4000T + - feature: RFXCOMM Module for Oregon Weatherstations + - feature: Davis VantagePro2 + - feature: ELV USB-WDE1 + - feature: addvaltriggers CUL attribute for adding RSSI as a trigger + - feature: CUL_WS sanity check for large temp differences. - 2010-03-13 (4.9) - bugfix: changed the fhem prompt from FHZ> to fhem> diff --git a/fhem/FHEM/14_CUL_WS.pm b/fhem/FHEM/14_CUL_WS.pm index 8b9294222..47a1cbedb 100755 --- a/fhem/FHEM/14_CUL_WS.pm +++ b/fhem/FHEM/14_CUL_WS.pm @@ -1,4 +1,4 @@ -# $Id: 14_CUL_WS.pm,v 1.26 2010-01-26 23:31:17 mr_p Exp $ +# $Id: 14_CUL_WS.pm,v 1.27 2010-08-14 11:42:46 rudolfkoenig Exp $ # ############################################## package main; @@ -279,60 +279,53 @@ CUL_WS_Parse($$) } Log GetLogLevel($name,4), "CUL_WS $devtype $name: $val"; + # Sanity checks + if($NotifyTemperature && $hash->{READINGS}{temperature}{VAL}) { + my $tval = $hash->{READINGS}{strangetemp} ? + $hash->{READINGS}{strangetemp}{VAL} : + $hash->{READINGS}{temperature}{VAL}; + my $diff = ($NotifyTemperature - $tval)+0; + if($diff < -15.0 || $diff > 15.0) { + Log 2, "$name: Temp difference ($diff) too large: $val, skipping it"; + $hash->{READINGS}{strangetemp}{VAL} = $NotifyTemperature; + $hash->{READINGS}{strangetemp}{TIME} = $tm; + return ""; + } + } + delete $hash->{READINGS}{strangetemp} if($hash->{READINGS}); - if(defined($hum) && $hum < 0) { + if(defined($hum) && ($hum < 0 || $hum > 100)) { Log 1, "BOGUS: $name reading: $val, skipping it"; - return $name; + return ""; } + $hash->{STATE} = $val; # List overview - $hash->{READINGS}{state}{TIME} = TimeNow(); # For list + $hash->{READINGS}{state}{TIME} = $tm; # For list $hash->{READINGS}{state}{VAL} = $val; $hash->{CHANGED}[0] = $val; # For notify my $i=1; my $j; my @Notifies=split(" ", $NotifyType); - for($j=0; $j{READINGS}{$NotifyMappings{$Notifies[$j]}}{TIME} = TimeNow(); - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{VAL} = $NotifyTemperature; - $hash->{CHANGED}[$i++] = $NotifyMappings{$Notifies[$j]} . ": " . $NotifyTemperature; - } elsif($Notifies[$j] eq "H") { - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{TIME} = TimeNow(); - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{VAL} = $NotifyHumidity; - $hash->{CHANGED}[$i++] = $NotifyMappings{$Notifies[$j]} . ": " . $NotifyHumidity; - } elsif($Notifies[$j] eq "R") { - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{TIME} = TimeNow(); - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{VAL} = $NotifyRain; - $hash->{CHANGED}[$i++] = $NotifyMappings{$Notifies[$j]} . ": " . $NotifyRain; - } elsif($Notifies[$j] eq "W") { - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{TIME} = TimeNow(); - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{VAL} = $NotifyWind; - $hash->{CHANGED}[$i++] = $NotifyMappings{$Notifies[$j]} . ": " . $NotifyWind; - } elsif($Notifies[$j] eq "WD") { - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{TIME} = TimeNow(); - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{VAL} = $NotifyWindDir; - $hash->{CHANGED}[$i++] = $NotifyMappings{$Notifies[$j]} . ": " . $NotifyWindDir; - } elsif($Notifies[$j] eq "WS") { - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{TIME} = TimeNow(); - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{VAL} = $NotifyWindSwing; - $hash->{CHANGED}[$i++] = $NotifyMappings{$Notifies[$j]} . ": " . $NotifyWindSwing; - } elsif($Notifies[$j] eq "IR") { - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{TIME} = TimeNow(); - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{VAL} = $NotifyIsRaining; - $hash->{CHANGED}[$i++] = $NotifyMappings{$Notifies[$j]} . ": " . $NotifyIsRaining; - } elsif($Notifies[$j] eq "B") { - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{TIME} = TimeNow(); - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{VAL} = $NotifyBrightness; - $hash->{CHANGED}[$i++] = $NotifyMappings{$Notifies[$j]} . ": " . $NotifyBrightness; - } elsif($Notifies[$j] eq "P") { - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{TIME} = TimeNow(); - $hash->{READINGS}{$NotifyMappings{$Notifies[$j]}}{VAL} = $NotifyPressure; - $hash->{CHANGED}[$i++] = $NotifyMappings{$Notifies[$j]} . ": " . $NotifyPressure; - } - } + for($j=0; $j{READINGS}{$nm}{TIME} = $tm; + $hash->{READINGS}{$nm}{VAL} = $val; + $hash->{CHANGED}[$i++] = "$nm: $val"; + } $hash->{READINGS}{DEVTYPE}{VAL}=$devtype; $hash->{READINGS}{DEVTYPE}{TIME}=$tm; diff --git a/fhem/TODO b/fhem/TODO index c7c958224..3dd41a52e 100644 --- a/fhem/TODO +++ b/fhem/TODO @@ -1,6 +1,5 @@ FHEM: -- CUL_WS safety check -- document autocreate rename anomaly (rename filelog only) +- fix autocreate rename anomaly (rename filelog only) - implement PID - implement wiki decisions - autodetect physical hardware diff --git a/fhem/docs/HOWTO.html b/fhem/docs/HOWTO.html index 2592f3e0b..06ed8e68d 100644 --- a/fhem/docs/HOWTO.html +++ b/fhem/docs/HOWTO.html @@ -108,6 +108,9 @@ rename to rename the automatically created device, e.g. type in the input field of the web frontend:
       rename FHT_1234 fht.kitchen
+ NOTE: you have to rename the device itself, the attached FileLog + and weblink will be renamed automatically. The other way round (renaming + the FileLog or weblink) does not work correctly right now. diff --git a/fhem/docs/fhem.html b/fhem/docs/fhem.html index bb347b41f..3a81531e5 100644 --- a/fhem/docs/fhem.html +++ b/fhem/docs/fhem.html @@ -62,7 +62,10 @@