2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 09:16:53 +00:00

PRESENCE: store threshold counter in state file for restarts

git-svn-id: https://svn.fhem.de/fhem/trunk@13159 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markusbloch 2017-01-20 21:33:39 +00:00
parent 040f4350bb
commit c1559f31f2
2 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- change: 73_PRESENCE: store threshold counter in state file for restarts
- feature: 98_DOIFtools.pm: new report filter for event rate - feature: 98_DOIFtools.pm: new report filter for event rate
- new: 96_Snapcast.pm: New module to control a snapcast server - new: 96_Snapcast.pm: New module to control a snapcast server
- update: 98_DOIFtools.pm: improved Attribute handling, help corrections - update: 98_DOIFtools.pm: improved Attribute handling, help corrections

View File

@ -271,6 +271,12 @@ PRESENCE_Notify($$)
if($dev_name eq "global" and grep(m/^(?:DEFINED $name|MODIFIED $name|INITIALIZED|REREADCFG)$/, @{$events})) if($dev_name eq "global" and grep(m/^(?:DEFINED $name|MODIFIED $name|INITIALIZED|REREADCFG)$/, @{$events}))
{ {
if(grep(m/^(?:INITIALIZED|REREADCFG)$/, @{$events}))
{
$hash->{helper}{ABSENT_COUNT} = int(ReadingsVal($name, ".absenceThresholdCounter", 0));
$hash->{helper}{PRESENT_COUNT} = int(ReadingsVal($name, ".presenceThresholdCounter", 0));
}
if($hash->{MODE} =~ /(lan-ping|local-bluetooth|fritzbox|shellscript|function)/) if($hash->{MODE} =~ /(lan-ping|local-bluetooth|fritzbox|shellscript|function)/)
{ {
delete $hash->{helper}{RUNNING_PID} if(defined($hash->{helper}{RUNNING_PID})); delete $hash->{helper}{RUNNING_PID} if(defined($hash->{helper}{RUNNING_PID}));
@ -1283,14 +1289,15 @@ sub PRESENCE_ProcessState($$)
{ {
if(++$count >= $absenceThreshold) if(++$count >= $absenceThreshold)
{ {
readingsBulkUpdate($hash, ".absenceThresholdCounter", 0);
readingsBulkUpdate($hash, "state", "absent"); readingsBulkUpdate($hash, "state", "absent");
readingsBulkUpdate($hash, "presence", "absent"); readingsBulkUpdate($hash, "presence", "absent");
} }
else else
{ {
$hash->{helper}{ABSENT_COUNT} = $count; $hash->{helper}{ABSENT_COUNT} = $count;
readingsBulkUpdate($hash, ".absenceThresholdCounter", $count);
readingsBulkUpdate($hash, "state", "maybe absent"); readingsBulkUpdate($hash, "state", "maybe absent");
readingsBulkUpdate($hash, "presence", "maybe absent"); readingsBulkUpdate($hash, "presence", "maybe absent");
@ -1327,6 +1334,7 @@ sub PRESENCE_ProcessState($$)
{ {
if(++$count >= $presenceThreshold) if(++$count >= $presenceThreshold)
{ {
readingsBulkUpdate($hash, ".presenceThresholdCounter", "0");
readingsBulkUpdate($hash, "state", "present"); readingsBulkUpdate($hash, "state", "present");
readingsBulkUpdate($hash, "presence", "present"); readingsBulkUpdate($hash, "presence", "present");
@ -1336,6 +1344,7 @@ sub PRESENCE_ProcessState($$)
{ {
$hash->{helper}{PRESENT_COUNT} = $count; $hash->{helper}{PRESENT_COUNT} = $count;
readingsBulkUpdate($hash, ".presenceThresholdCounter", $count);
readingsBulkUpdate($hash, "state", "maybe present"); readingsBulkUpdate($hash, "state", "maybe present");
readingsBulkUpdate($hash, "presence", "maybe present"); readingsBulkUpdate($hash, "presence", "maybe present");