mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-16 16:56:04 +00:00
RESIDENTS: also send global notification after module has finished initialization
git-svn-id: https://svn.fhem.de/fhem/trunk@14064 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8c79cfbc45
commit
5ce53d7f0a
@ -18,7 +18,7 @@ sub RESIDENTS_Initialize($) {
|
||||
$hash->{AttrFn} = "RESIDENTStk_Attr";
|
||||
$hash->{NotifyFn} = "RESIDENTStk_Notify";
|
||||
|
||||
$hash->{'.READY'} = 0;
|
||||
$hash->{READY} = 0;
|
||||
$hash->{NotifyOrderPrefix} = "45-";
|
||||
$hash->{AttrList} =
|
||||
"disable:1,0 disabledForIntervals do_not_notify:1,0 "
|
||||
|
@ -19,7 +19,7 @@ sub GUEST_Initialize($) {
|
||||
$hash->{AttrFn} = "RESIDENTStk_Attr";
|
||||
$hash->{NotifyFn} = "RESIDENTStk_Notify";
|
||||
|
||||
$hash->{'.READY'} = 0;
|
||||
$hash->{READY} = 0;
|
||||
$hash->{NotifyOrderPrefix} = "35-";
|
||||
$hash->{AttrList} =
|
||||
"disable:1,0 disabledForIntervals do_not_notify:1,0 "
|
||||
|
@ -19,7 +19,7 @@ sub ROOMMATE_Initialize($) {
|
||||
$hash->{AttrFn} = "RESIDENTStk_Attr";
|
||||
$hash->{NotifyFn} = "RESIDENTStk_Notify";
|
||||
|
||||
$hash->{'.READY'} = 0;
|
||||
$hash->{READY} = 0;
|
||||
$hash->{NotifyOrderPrefix} = "40-";
|
||||
$hash->{AttrList} =
|
||||
"disable:1,0 disabledForIntervals do_not_notify:1,0 "
|
||||
|
@ -54,7 +54,8 @@ sub RESIDENTStk_Define($$) {
|
||||
|| $a[2] =~ /^[A-Za-z\d._]+(?:,[A-Za-z\d._]*)*$/ );
|
||||
|
||||
$modules{$TYPE}{defptr}{$name} = \$hash;
|
||||
$hash->{NOTIFYDEV} = "global";
|
||||
$hash->{'.READY'} = 0;
|
||||
$hash->{NOTIFYDEV} = "global";
|
||||
$hash->{RESIDENTGROUPS} = $a[2] if ( defined( $a[2] ) );
|
||||
|
||||
# set default settings on first define
|
||||
@ -114,6 +115,7 @@ sub RESIDENTStk_Undefine($$) {
|
||||
my ( $hash, $name ) = @_;
|
||||
|
||||
RESIDENTStk_StopInternalTimers($hash);
|
||||
return undef unless ($init_done);
|
||||
|
||||
# update parent residents
|
||||
if ( defined( $hash->{RESIDENTGROUPS} ) ) {
|
||||
@ -1077,20 +1079,41 @@ sub RESIDENTStk_Notify($$) {
|
||||
my $devType = GetType($devName);
|
||||
|
||||
if ( $devName eq "global" ) {
|
||||
delete $dev->{CHANGEDWITHSTATE};
|
||||
my $events = deviceEvents( $dev, 0 );
|
||||
return "" unless ($events);
|
||||
|
||||
foreach ( @{$events} ) {
|
||||
|
||||
# module internal notifications
|
||||
if ( $_ =~ m/^$TYPE(?:\s+(.*))?$/ ) {
|
||||
|
||||
# internal init completed by all defined devices
|
||||
if ( $1 && $1 eq "INITIALIZED" && !$hash->{'.READY'} ) {
|
||||
$hash->{'.READY'} = 1;
|
||||
DoTrigger( "global", "INITIALIZED $name", 1 );
|
||||
}
|
||||
}
|
||||
|
||||
# init RESIDENTS, ROOMMATE or GUEST devices after boot
|
||||
if ( $_ =~
|
||||
elsif ( $_ =~
|
||||
m/^(INITIALIZED|REREADCFG|DEFINED|MODIFIED|RENAMED|DELETED)(?:\s+(.*))?$/
|
||||
)
|
||||
{
|
||||
RESIDENTStk_findResidentSlaves($hash)
|
||||
if ( $TYPE eq "RESIDENTS" );
|
||||
RESIDENTStk_findDummySlaves($name)
|
||||
if ( $TYPE ne "RESIDENTS" && $TYPE ne "dummy" );
|
||||
next if ( $1 eq "INITIALIZED" && $2 );
|
||||
next if ( $2 && $2 eq $name );
|
||||
|
||||
if ( $1 eq "REREADCFG" ) {
|
||||
next unless ( $modules{$TYPE}{READY} );
|
||||
$modules{$TYPE}{READY} = 0;
|
||||
}
|
||||
|
||||
if ( $TYPE eq "RESIDENTS" ) {
|
||||
RESIDENTStk_findResidentSlaves($hash);
|
||||
}
|
||||
else {
|
||||
RESIDENTStk_findDummySlaves($name);
|
||||
}
|
||||
}
|
||||
|
||||
# only process attribute events
|
||||
@ -3454,8 +3477,8 @@ sub RESIDENTStk_StopInternalTimers($) {
|
||||
RESIDENTStk_RemoveInternalTimer( "DurationTimer", $hash );
|
||||
}
|
||||
|
||||
sub RESIDENTStk_findResidentSlaves($;$) {
|
||||
my ( $hash, $rgr_wakeupDevice ) = @_;
|
||||
sub RESIDENTStk_findResidentSlaves($) {
|
||||
my ($hash) = @_;
|
||||
return
|
||||
unless ( ref($hash) eq "HASH" && defined( $hash->{NAME} ) );
|
||||
|
||||
@ -3497,8 +3520,6 @@ sub RESIDENTStk_findDummySlaves($) {
|
||||
my $TYPE = GetType($name);
|
||||
my $prefix = RESIDENTStk_GetPrefixFromType($name);
|
||||
|
||||
return undef unless ($init_done);
|
||||
|
||||
my $wakeupDevice = AttrVal( $name, $prefix . "wakeupDevice", undef );
|
||||
my $presenceDevices = AttrVal( $name, $prefix . "presenceDevices", undef );
|
||||
|
||||
@ -3530,14 +3551,19 @@ sub RESIDENTStk_findDummySlaves($) {
|
||||
}
|
||||
}
|
||||
|
||||
# finish initialization
|
||||
if ( $hash->{'.READY'} ) {
|
||||
DoTrigger( "global", "MODIFIED $name", 1 );
|
||||
# finish module initialization
|
||||
if ( $modules{$TYPE}{READY} == 0 ) {
|
||||
Log 1, "DEBUG+++ module $TYPE INITIALIZED";
|
||||
$modules{$TYPE}{READY} = 1;
|
||||
DoTrigger( "global", "$TYPE INITIALIZED", 1 );
|
||||
}
|
||||
else {
|
||||
$hash->{'.READY'} = 1;
|
||||
DoTrigger( "global", "INITIALIZED $name", 1 );
|
||||
|
||||
# internal modification
|
||||
elsif ( $hash->{'.READY'} ) {
|
||||
Log 1, "DEBUG+++ $name CHANGED_CONFIG";
|
||||
DoTrigger( "global", "CHANGED_CONFIG $name", 1 );
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user