From 0ffeb8ae51819e5b1dc5f992c5a3b22263ec0b31 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Mon, 10 Oct 2016 17:48:19 +0000 Subject: [PATCH] fhem.pl: add readingsBulkUpdateIfChanged (Forum #58797) git-svn-id: https://svn.fhem.de/fhem/trunk@12311 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/fhem.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fhem/fhem.pl b/fhem/fhem.pl index c6f3f80b0..a54fda748 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -4044,9 +4044,19 @@ readingsEndUpdate($$) return undef; } -# +sub +readingsBulkUpdateIfChanged($$$@) # Forum #58797 +{ + my ($hash,$reading,$value,$changed)= @_; + return undef if($value eq ReadingsVal($hash->{NAME},$reading,"")); + return readingsBulkUpdate($hash,$reading,$value,$changed); +} + # Call readingsBulkUpdate to update the reading. # Example: readingsUpdate($hash,"temperature",$value); +# Optional parameter $changed: if defined, and is 0, do not trigger events. If +# 1, trigger. If not defined, the name of the reading decides (starting with . +# is 0, else 1). The event-on-* filtering is done additionally. # sub readingsBulkUpdate($$$@)