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: