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

20_ROOMMATE,20_GUEST: add new attribute r*_presenceDevices

git-svn-id: https://svn.fhem.de/fhem/trunk@13036 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2017-01-10 17:22:32 +00:00
parent 9ab3f41d51
commit c0aedc28ef
3 changed files with 91 additions and 8 deletions

View File

@ -1,5 +1,8 @@
# 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.
- feature: 20_ROOMMATE,20_GUEST: introduce new attribute r*_presenceDevices
to allow easy status synchronisation with
other FHEM devices (e.g. PRESENCE module)
- bugfix: 93_DbLog.pm: is now version 2.8.6, some small bugfixes
(thanks a lot to DS_Starter)
- update: 55_InfoPanel.pm: attribute mobileApp added

View File

@ -50,7 +50,7 @@ sub GUEST_Initialize($) {
$hash->{NotifyFn} = "GUEST_Notify";
$hash->{UndefFn} = "GUEST_Undefine";
$hash->{AttrList} =
"rg_locationHome rg_locationWayhome rg_locationUnderway rg_autoGoneAfter:12,16,24,26,28,30,36,48,60 rg_showAllStates:0,1 rg_realname:group,alias rg_states:multiple-strict,home,gotosleep,asleep,awoken,absent,gone rg_locations rg_moods rg_moodDefault rg_moodSleepy rg_noDuration:0,1 rg_wakeupDevice rg_geofenceUUIDs "
"rg_locationHome rg_locationWayhome rg_locationUnderway rg_autoGoneAfter:12,16,24,26,28,30,36,48,60 rg_showAllStates:0,1 rg_realname:group,alias rg_states:multiple-strict,home,gotosleep,asleep,awoken,absent,gone rg_locations rg_moods rg_moodDefault rg_moodSleepy rg_noDuration:0,1 rg_wakeupDevice rg_geofenceUUIDs rg_presenceDevices "
. $readingFnAttributes;
}
@ -243,9 +243,9 @@ sub GUEST_Notify($$) {
# process child notifies
elsif ( $devName ne $hashName ) {
my @registeredWakeupdevs =
split( /,/, $attr{$hashName}{rg_wakeupDevice} )
if ( defined( $attr{$hashName}{rg_wakeupDevice} )
&& $attr{$hashName}{rg_wakeupDevice} ne "" );
split( ',', AttrVal( $hashName, "rg_wakeupDevice", "" ) );
my @presenceDevices =
split( ',', AttrVal( $hashName, "rg_presenceDevices", "" ) );
# if we have registered wakeup devices
if (@registeredWakeupdevs) {
@ -287,6 +287,39 @@ sub GUEST_Notify($$) {
}
}
}
# process PRESENCE
elsif (@presenceDevices) {
my $counter = {
absent => 0,
present => 0,
};
foreach (@presenceDevices) {
next unless ( $_ eq $devName );
my $presenceState =
ReadingsVal( $_, "presence", ReadingsVal( $_, "state", "" ) );
next
unless ( $presenceState =~
/^((absent|disappeared|unavailable)|(present|appeared|available|))$/i
);
$counter->{absent}++ if ($2);
$counter->{present}++ if ($3);
last;
}
if ( $counter->{absent} && !$counter->{present} ) {
Log3 $hashName, 4,
"GUEST $hashName: Syncing status with $devName = absent";
fhem "set $hashName:FILTER=presence=present absent";
}
elsif ( !$counter->{absent} && $counter->{present} ) {
Log3 $hashName, 4,
"GUEST $hashName: Syncing status with $devName = present";
fhem "set $hashName:FILTER=presence=absent home";
}
}
}
return;
@ -1409,6 +1442,9 @@ sub GUEST_StartInternalTimers($$) {
<li>
<b>rg_passPresenceTo</b> - synchronize presence state with other GUEST or GUEST devices; separte devices by space
</li>
<li>
<b>rg_presenceDevices</b> - take over presence state from any other FHEM device. Separate more than one device with comma meaning ALL of them need to be either present or absent to trigger update of this ROOMMATE device.
</li>
<li>
<b>rg_realname</b> - whenever GUEST wants to use the realname it uses the value of attribute alias or group; defaults to group
</li>
@ -1707,6 +1743,9 @@ sub GUEST_StartInternalTimers($$) {
<li>
<b>rg_passPresenceTo</b> - synchronisiere die Anwesenheit mit anderen GUEST oder ROOMMATE Devices; mehrere Devices durch Leerzeichen trennen
</li>
<li>
<b>rg_presenceDevices</b> - &uuml;bernehmen des presence Status von einem anderen FHEM Device. Bei mehreren Devices diese mit Komma trennen, um ein Update des GUEST Devices auszul&ouml;sen, sobald ALLE Devices entweder absent oder present sind.
</li>
<li>
<b>rg_realname</b> - wo immer GUEST den richtigen Namen verwenden m&ouml;chte nutzt es den Wert des Attributs alias oder group; Standard ist group
</li>

View File

@ -50,7 +50,7 @@ sub ROOMMATE_Initialize($) {
$hash->{NotifyFn} = "ROOMMATE_Notify";
$hash->{UndefFn} = "ROOMMATE_Undefine";
$hash->{AttrList} =
"rr_locationHome rr_locationWayhome rr_locationUnderway rr_autoGoneAfter:12,16,24,26,28,30,36,48,60 rr_showAllStates:0,1 rr_realname:group,alias rr_states:multiple-strict,home,gotosleep,asleep,awoken,absent,gone rr_locations rr_moods rr_moodDefault rr_moodSleepy rr_passPresenceTo rr_noDuration:0,1 rr_wakeupDevice rr_geofenceUUIDs "
"rr_locationHome rr_locationWayhome rr_locationUnderway rr_autoGoneAfter:12,16,24,26,28,30,36,48,60 rr_showAllStates:0,1 rr_realname:group,alias rr_states:multiple-strict,home,gotosleep,asleep,awoken,absent,gone rr_locations rr_moods rr_moodDefault rr_moodSleepy rr_passPresenceTo rr_noDuration:0,1 rr_wakeupDevice rr_geofenceUUIDs rr_presenceDevices "
. $readingFnAttributes;
}
@ -248,9 +248,9 @@ sub ROOMMATE_Notify($$) {
# process child notifies
elsif ( $devName ne $hashName ) {
my @registeredWakeupdevs =
split( /,/, $attr{$hashName}{rr_wakeupDevice} )
if ( defined( $attr{$hashName}{rr_wakeupDevice} )
&& $attr{$hashName}{rr_wakeupDevice} ne "" );
split( ',', AttrVal( $hashName, "rr_wakeupDevice", "" ) );
my @presenceDevices =
split( ',', AttrVal( $hashName, "rr_presenceDevices", "" ) );
# if we have registered wakeup devices
if (@registeredWakeupdevs) {
@ -292,6 +292,41 @@ sub ROOMMATE_Notify($$) {
}
}
}
# process PRESENCE
elsif (@presenceDevices) {
my $counter = {
absent => 0,
present => 0,
};
foreach (@presenceDevices) {
next unless ( $_ eq $devName );
my $presenceState =
ReadingsVal( $_, "presence", ReadingsVal( $_, "state", "" ) );
next
unless ( $presenceState =~
/^((absent|disappeared|unavailable)|(present|appeared|available|))$/i
);
$counter->{absent}++ if ($2);
$counter->{present}++ if ($3);
last;
}
if ( $counter->{absent} && !$counter->{present} ) {
Log3 $hashName, 4,
"ROOMMATE $hashName: "
. "Syncing status with $devName = absent";
fhem "set $hashName:FILTER=presence=present absent";
}
elsif ( !$counter->{absent} && $counter->{present} ) {
Log3 $hashName, 4,
"ROOMMATE $hashName: "
. "Syncing status with $devName = present";
fhem "set $hashName:FILTER=presence=absent home";
}
}
}
return;
@ -1397,6 +1432,9 @@ sub ROOMMATE_StartInternalTimers($$) {
<li>
<b>rr_passPresenceTo</b> - synchronize presence state with other ROOMMATE or GUEST devices; separte devices by space
</li>
<li>
<b>rr_presenceDevices</b> - take over presence state from any other FHEM device. Separate more than one device with comma meaning ALL of them need to be either present or absent to trigger update of this ROOMMATE device.
</li>
<li>
<b>rr_realname</b> - whenever ROOMMATE wants to use the realname it uses the value of attribute alias or group; defaults to group
</li>
@ -1695,6 +1733,9 @@ sub ROOMMATE_StartInternalTimers($$) {
<li>
<b>rr_passPresenceTo</b> - synchronisiere die Anwesenheit mit anderen ROOMMATE oder GUEST Devices; mehrere Devices durch Leerzeichen trennen
</li>
<li>
<b>rr_presenceDevices</b> - &uuml;bernehmen des presence Status von einem anderen FHEM Device. Bei mehreren Devices diese mit Komma trennen, um ein Update des ROOMMATE Devices auszul&ouml;sen, sobald ALLE Devices entweder absent oder present sind.
</li>
<li>
<b>rr_realname</b> - wo immer ROOMMATE den richtigen Namen verwenden m&ouml;chte nutzt es den Wert des Attributs alias oder group; Standard ist group
</li>