From 18ecbbb19fd8843086a5a4b0c812f95d8df6c5cb Mon Sep 17 00:00:00 2001 From: markusbloch <> Date: Sat, 13 May 2017 08:53:10 +0000 Subject: [PATCH] 73_PRESENCE: fix restart of threshold counter after FHEM restart (thx to DeeSPe & CoolTux, Forum: #71744) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@14263 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 1 + FHEM/73_PRESENCE.pm | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGED b/CHANGED index af8f045da..59cef1ac6 100644 --- a/CHANGED +++ b/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. + - bugfix: 73_PRESENCE: fix restart of threshold counter after FHEM restart - feature: 44_S7: new attribute receiveTimeoutMs - feature: 38_CO20: introduced state reading - change: 73_NUKIBridge,74_NUKIDevice: fix Perlwarnings diff --git a/FHEM/73_PRESENCE.pm b/FHEM/73_PRESENCE.pm index 5b93b5397..7db72b648 100755 --- a/FHEM/73_PRESENCE.pm +++ b/FHEM/73_PRESENCE.pm @@ -1289,7 +1289,8 @@ sub PRESENCE_ProcessState($$) { if(++$count >= $absenceThreshold) { - readingsBulkUpdate($hash, ".absenceThresholdCounter", 0); + readingsBulkUpdate($hash, ".presenceThresholdCounter", 0); + readingsBulkUpdate($hash, ".absenceThresholdCounter", ($count-1)); readingsBulkUpdate($hash, "state", "absent"); readingsBulkUpdate($hash, "presence", "absent"); } @@ -1297,6 +1298,7 @@ sub PRESENCE_ProcessState($$) { $hash->{helper}{ABSENT_COUNT} = $count; + readingsBulkUpdate($hash, ".presenceThresholdCounter", 0); readingsBulkUpdate($hash, ".absenceThresholdCounter", $count); readingsBulkUpdate($hash, "state", "maybe absent"); readingsBulkUpdate($hash, "presence", "maybe absent"); @@ -1334,7 +1336,8 @@ sub PRESENCE_ProcessState($$) { if(++$count >= $presenceThreshold) { - readingsBulkUpdate($hash, ".presenceThresholdCounter", "0"); + readingsBulkUpdate($hash, ".absenceThresholdCounter", 0); + readingsBulkUpdate($hash, ".presenceThresholdCounter", ($count-1)); readingsBulkUpdate($hash, "state", "present"); readingsBulkUpdate($hash, "presence", "present"); @@ -1344,6 +1347,7 @@ sub PRESENCE_ProcessState($$) { $hash->{helper}{PRESENT_COUNT} = $count; + readingsBulkUpdate($hash, ".absenceThresholdCounter", 0); readingsBulkUpdate($hash, ".presenceThresholdCounter", $count); readingsBulkUpdate($hash, "state", "maybe present"); readingsBulkUpdate($hash, "presence", "maybe present");