From 340a989b450a2a6b60a9d6932795fb0b6d8f1cd2 Mon Sep 17 00:00:00 2001 From: choenig <> Date: Sun, 11 Jul 2021 12:06:25 +0000 Subject: [PATCH] 10_WS980: v1.4.0 - allow to skip invalid values git-svn-id: https://svn.fhem.de/fhem/trunk@24726 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/10_WS980.pm | 67 ++++++++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 38a7ff281..5a03f1f46 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: 10_WS980: allow to ignore invalid values - feature: 49_SSCam: new value 8.2.8-xxxx for attr simu_SVSversion - bugfix: 76_SMAInverter:fix ETOTAL/LOADTOTAL bug - feature: 76_SMAInverter: hide unavailable data diff --git a/fhem/FHEM/10_WS980.pm b/fhem/FHEM/10_WS980.pm index a2c67984c..07a6b5749 100644 --- a/fhem/FHEM/10_WS980.pm +++ b/fhem/FHEM/10_WS980.pm @@ -33,7 +33,7 @@ use warnings; use IO::Socket::INET; use POSIX qw(strftime); -my $version = "1.3.0"; +my $version = "1.4.0"; #------------------------------------------------------------------------------------------------------ # global constants @@ -165,6 +165,7 @@ sub WS980_Initialize($) $hash->{AttrList} = "altitude ". "events:textField-long ". "connection:Keep-Alive,Close ". + "invalidValues:updateReading,skip,skipAndLog ". "requests:multiple-strict,".join(",", sort keys %{REQUESTS()})." ". "showRawBuffer:1 ". "silentReconnect:1 ". @@ -293,6 +294,20 @@ sub WS980_AttrFn(@) } } + ####################### + #### invalidValues #### + + if ($attrName eq "invalidValues") { + if ($cmd eq "set") { + if ($attrVal eq "updateReading" || $attrVal eq "skip" || $attrVal eq "skipAndLog") { + return undef; + } + else { + return "'invalidValues' must be either updateReading, skip or skipAndLog"; + } + } + } + ################ #### events #### @@ -522,6 +537,7 @@ sub WS980_handleMultiValuesUpdate($$$) WS980_Log($hash, 5, "decoding block: " . WS980_hexDump($buf)); my $showRawBuffer = AttrVal($name, "showRawBuffer", "0") eq "1" ? 1 : 0; + my $invalidValues = AttrVal($name, "invalidValues", "updateReading"); for (my $i = 0; $i < length($buf); ) { @@ -564,7 +580,12 @@ sub WS980_handleMultiValuesUpdate($$$) my $value = hex(WS980_binToHex($rawValue)); if ($value eq $errVal) { - $value = "n/a"; + if ($invalidValues eq "updateReading") { + $value = 'n/a'; + } else { + WS980_Log($hash, 4, "skipping invalid value of \"$reading\"") if ($invalidValues eq "skipAndLog"); + next; + } } else { # convert negative values my $lbit = 1 << ($bytes * 2 * 4) - 1; @@ -1365,14 +1386,14 @@ sub WS980_Log($$$) =begin html - +

WS980