From 461e9c2b3892e9d950f47e2627eb54219bef2710 Mon Sep 17 00:00:00 2001 From: jpawlowski Date: Sat, 20 Feb 2016 20:59:38 +0000 Subject: [PATCH] 10_RESIDENTS.pm: only run readingsBeginUpdate once git-svn-id: https://svn.fhem.de/fhem/trunk@10897 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_RESIDENTS.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/10_RESIDENTS.pm b/fhem/FHEM/10_RESIDENTS.pm index e446a9698..396ae629c 100644 --- a/fhem/FHEM/10_RESIDENTS.pm +++ b/fhem/FHEM/10_RESIDENTS.pm @@ -149,6 +149,8 @@ sub RESIDENTS_Notify($$) { return if ( !$dev->{CHANGED} ); # Some previous notify deleted the array. + readingsBeginUpdate($hash); + foreach my $change ( @{ $dev->{CHANGED} } ) { Log3 $hash, 5, @@ -198,15 +200,17 @@ sub RESIDENTS_Notify($$) { ); # update statistics - readingsBeginUpdate($hash); readingsBulkUpdate( $hash, "lastActivity", ReadingsVal( $devName, "state", $change ) ); readingsBulkUpdate( $hash, "lastActivityBy", $realname ); readingsBulkUpdate( $hash, "lastActivityByDev", $devName ); - readingsEndUpdate( $hash, 1 ); + } + } + readingsEndUpdate( $hash, 1 ); + return; } @@ -552,7 +556,9 @@ sub RESIDENTS_Set($@) { return "No Argument given, choose one of ROOMMATE GUEST "; } + readingsBeginUpdate($hash); RESIDENTS_UpdateReadings($hash); + readingsEndUpdate( $hash, 1 ); } # create @@ -1150,8 +1156,6 @@ sub RESIDENTS_UpdateReadings (@) { } # update counter - readingsBeginUpdate($hash); - readingsBulkUpdate( $hash, "residentsTotal", $state_total ) if ( ReadingsVal( $name, "residentsTotal", "" ) ne $state_total ); @@ -1571,8 +1575,6 @@ sub RESIDENTS_UpdateReadings (@) { } } - - readingsEndUpdate( $hash, 1 ); } 1; @@ -1905,6 +1907,7 @@ sub RESIDENTS_UpdateReadings (@) { wakeuptimer   -   adds a wake-up timer dummy device with enhanced functions to start with wake-up automations