From 24b59127e4f92ceb417bbc64af941d25efd06a39 Mon Sep 17 00:00:00 2001 From: jpawlowski Date: Sat, 4 May 2019 22:52:00 +0000 Subject: [PATCH] 10_RESIDENTS: add lastHomestate readings git-svn-id: https://svn.fhem.de/fhem/trunk@19330 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_RESIDENTS.pm | 44 ++-- fhem/demolog/fhem.save | 507 +++++++++++++++++++------------------- 2 files changed, 275 insertions(+), 276 deletions(-) diff --git a/fhem/FHEM/10_RESIDENTS.pm b/fhem/FHEM/10_RESIDENTS.pm index ce4e8bdb8..c79cb3f00 100644 --- a/fhem/FHEM/10_RESIDENTS.pm +++ b/fhem/FHEM/10_RESIDENTS.pm @@ -1134,7 +1134,6 @@ sub RESIDENTS_UpdateReadings (@) { foreach my $obj ( split( /,/, $residentsDevs_totalPresent ) ) { my $TYPE = GetType($obj); next unless $TYPE; - $state_homealone++; my $subtype = 'generic'; $subtype = InternalVal( $obj, 'SUBTYPE', 'pet' ) @@ -1165,11 +1164,16 @@ sub RESIDENTS_UpdateReadings (@) { if ( !$newstate_prefix || $importance2 < $importance ); } } - readingsBulkUpdateIfChanged( $hash, "residentsHomealone", - $state_homealone ); - readingsBulkUpdateIfChanged( $hash, "residentsHomealoneType", + readingsBulkUpdateIfChanged( $hash, "lastHomealoneType", + ReadingsVal( $name, "homealoneType", "-" ) ) + if ( ReadingsVal( $name, "homealoneType", undef ) ); + readingsBulkUpdateIfChanged( $hash, "lastHomealoneSubtype", + ReadingsVal( $name, "homealoneSubtype", "-" ) ) + if ( ReadingsVal( $name, "homealoneSubtype", undef ) ); + + readingsBulkUpdateIfChanged( $hash, "homealoneType", $homealone_type ? $homealone_type : '-' ); - readingsBulkUpdateIfChanged( $hash, "residentsHomealoneSubtype", + readingsBulkUpdateIfChanged( $hash, "homealoneSubtype", $homealone_subtype ? $homealone_subtype : '-' ); $newstate = $newstate_prefix . '_' . $newstate @@ -1423,6 +1427,12 @@ sub RESIDENTS_UpdateReadings (@) { Generated Readings/Events: