use NOTIFYDEV

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@4730 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2014-01-24 19:38:03 +00:00
parent 60036736a5
commit 0c3b24f98c
4 changed files with 12 additions and 32 deletions

View File

@ -26,6 +26,7 @@ sub HUEBridge_Initialize($)
#Consumer #Consumer
$hash->{DefFn} = "HUEBridge_Define"; $hash->{DefFn} = "HUEBridge_Define";
$hash->{NOTIFYDEV} = "global";
$hash->{NotifyFn} = "HUEBridge_Notify"; $hash->{NotifyFn} = "HUEBridge_Notify";
$hash->{SetFn} = "HUEBridge_Set"; $hash->{SetFn} = "HUEBridge_Set";
$hash->{GetFn} = "HUEBridge_Get"; $hash->{GetFn} = "HUEBridge_Get";
@ -91,7 +92,6 @@ HUEBridge_Define($$)
} }
if( $init_done ) { if( $init_done ) {
delete $modules{$hash->{TYPE}}{NotifyFn};
HUEBridge_OpenDev( $hash ); HUEBridge_OpenDev( $hash );
} }
@ -109,13 +109,7 @@ HUEBridge_Notify($$)
return if($attr{$name} && $attr{$name}{disable}); return if($attr{$name} && $attr{$name}{disable});
delete $modules{$type}{NotifyFn}; HUEBridge_OpenDev($hash);
delete $hash->{NTFY_ORDER} if($hash->{NTFY_ORDER});
foreach my $d (keys %defs) {
next if($defs{$d}{TYPE} ne "$type");
HUEBridge_OpenDev($defs{$d});
}
return undef; return undef;
} }

View File

@ -32,6 +32,7 @@ mailcheck_Initialize($)
$hash->{ReadFn} = "mailcheck_Read"; $hash->{ReadFn} = "mailcheck_Read";
$hash->{DefFn} = "mailcheck_Define"; $hash->{DefFn} = "mailcheck_Define";
$hash->{NOTIFYDEV} = "global";
$hash->{NotifyFn} = "mailcheck_Notify"; $hash->{NotifyFn} = "mailcheck_Notify";
$hash->{UndefFn} = "mailcheck_Undefine"; $hash->{UndefFn} = "mailcheck_Undefine";
#$hash->{SetFn} = "mailcheck_Set"; #$hash->{SetFn} = "mailcheck_Set";
@ -80,7 +81,6 @@ mailcheck_Define($$)
$hash->{HAS_MIME} = $mailcheck_hasMIME; $hash->{HAS_MIME} = $mailcheck_hasMIME;
if( $init_done ) { if( $init_done ) {
delete $modules{mailcheck}->{NotifyFn};
mailcheck_Disconnect($hash); mailcheck_Disconnect($hash);
mailcheck_Connect($hash); mailcheck_Connect($hash);
} elsif( $hash->{STATE} ne "???" ) { } elsif( $hash->{STATE} ne "???" ) {
@ -98,12 +98,7 @@ mailcheck_Notify($$)
return if($dev->{NAME} ne "global"); return if($dev->{NAME} ne "global");
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}})); return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
delete $modules{$hash->{TYPE}}->{NotifyFn}; mailcheck_Connect($hash);
foreach my $d (keys %defs) {
next if($defs{$d}{TYPE} ne $hash->{TYPE});
mailcheck_Connect($defs{$d});
}
} }
sub sub

View File

@ -40,6 +40,7 @@ withings_Initialize($)
my ($hash) = @_; my ($hash) = @_;
$hash->{DefFn} = "withings_Define"; $hash->{DefFn} = "withings_Define";
$hash->{NOTIFYDEV} = "global";
$hash->{NotifyFn} = "withings_Notify"; $hash->{NotifyFn} = "withings_Notify";
$hash->{UndefFn} = "withings_Undefine"; $hash->{UndefFn} = "withings_Undefine";
#$hash->{SetFn} = "withings_Set"; #$hash->{SetFn} = "withings_Set";
@ -117,7 +118,6 @@ withings_Define($$)
$hash->{STATE} = "Initialized"; $hash->{STATE} = "Initialized";
if( $init_done ) { if( $init_done ) {
delete $modules{withings}->{NotifyFn};
withings_initUser($hash) if( $hash->{SUBTYPE} eq "USER" ); withings_initUser($hash) if( $hash->{SUBTYPE} eq "USER" );
withings_connect($hash) if( $hash->{SUBTYPE} eq "ACCOUNT" ); withings_connect($hash) if( $hash->{SUBTYPE} eq "ACCOUNT" );
withings_initDevice($hash) if( $hash->{SUBTYPE} eq "DEVICE" ); withings_initDevice($hash) if( $hash->{SUBTYPE} eq "DEVICE" );
@ -134,14 +134,9 @@ withings_Notify($$)
return if($dev->{NAME} ne "global"); return if($dev->{NAME} ne "global");
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}})); return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
delete $modules{$hash->{TYPE}}->{NotifyFn}; withings_initUser($hash) if( $hash->{SUBTYPE} eq "USER" );
withings_connect($hash) if( $hash->{SUBTYPE} eq "ACCOUNT" );
foreach my $d (keys %defs) { withings_initDevice($hash) if( $hash->{SUBTYPE} eq "DEVICE" );
next if($defs{$d}{TYPE} ne $hash->{TYPE});
withings_initUser($defs{$d}) if( $defs{$d}->{SUBTYPE} eq "USER" );
withings_connect($defs{$d}) if( $defs{$d}->{SUBTYPE} eq "ACCOUNT" );
withings_initDevice($defs{$d}) if( $defs{$d}->{SUBTYPE} eq "DEVICE" );
}
} }
sub sub

View File

@ -16,6 +16,7 @@ CO20_Initialize($)
my ($hash) = @_; my ($hash) = @_;
$hash->{DefFn} = "CO20_Define"; $hash->{DefFn} = "CO20_Define";
$hash->{NOTIFYDEV} = "global";
$hash->{NotifyFn} = "CO20_Notify"; $hash->{NotifyFn} = "CO20_Notify";
$hash->{UndefFn} = "CO20_Undefine"; $hash->{UndefFn} = "CO20_Undefine";
#$hash->{SetFn} = "CO20_Set"; #$hash->{SetFn} = "CO20_Set";
@ -47,7 +48,6 @@ CO20_Define($$)
$hash->{NAME} = $name; $hash->{NAME} = $name;
if( $init_done ) { if( $init_done ) {
delete $modules{CO20}->{NotifyFn};
CO20_Disconnect($hash); CO20_Disconnect($hash);
CO20_Connect($hash); CO20_Connect($hash);
} elsif( $hash->{STATE} ne "???" ) { } elsif( $hash->{STATE} ne "???" ) {
@ -62,14 +62,10 @@ CO20_Notify($$)
{ {
my ($hash,$dev) = @_; my ($hash,$dev) = @_;
if( grep(m/^INITIALIZED$/, @{$dev->{CHANGED}}) ) { return if($dev->{NAME} ne "global");
delete $modules{CO20}->{NotifyFn}; return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
foreach my $d (keys %defs) { CO20_Connect($hash);
next if($defs{$d}{TYPE} ne "CO20");
CO20_Connect($defs{$d});
}
}
} }
my $VENDOR = 0x03eb; my $VENDOR = 0x03eb;