2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

39_alexa.pm: fixed startup race condition

git-svn-id: https://svn.fhem.de/fhem/trunk@18239 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2019-01-13 14:11:13 +00:00
parent fe0ce73263
commit 5bdf9df45c

View File

@ -133,7 +133,10 @@ alexa_Define($$)
#CommandAttr(undef, "$name alexaFHEM-filter alexaName=..*") if( !AttrVal($name, 'alexaFHEM-filter', undef ) ); #CommandAttr(undef, "$name alexaFHEM-filter alexaName=..*") if( !AttrVal($name, 'alexaFHEM-filter', undef ) );
CommandAttr(undef, "$name devStateIcon stopped:control_home\@red:start stopping:control_on_off\@orange running.*:control_on_off\@green:stop") if( !AttrVal($name, 'devStateIcon', undef ) ); if( !AttrVal($name, 'devStateIcon', undef ) ) {
CommandAttr(undef, "$name stateFormat alexaFHEM");
CommandAttr(undef, "$name devStateIcon stopped:control_home\@red:start stopping:control_on_off\@orange running.*:control_on_off\@green:stop")
}
if( $init_done ) { if( $init_done ) {
@ -161,8 +164,7 @@ alexa_Notify($$)
sub sub
alexa_Undefine($$) alexa_Undefine($$)
{ {
my ($hash, $arg) = @_; my ($hash, $name) = @_;
my $name = $hash->{NAME};
if( $hash->{PID} ) { if( $hash->{PID} ) {
$hash->{undefine} = 1; $hash->{undefine} = 1;
@ -176,9 +178,9 @@ alexa_Undefine($$)
return undef; return undef;
} }
sub sub
alexa_Shutdown($$) alexa_Shutdown($)
{ {
my ($hash, $arg) = @_; my ($hash) = @_;
alexa_stoppedAlexaFHEM($hash); alexa_stoppedAlexaFHEM($hash);
@ -671,7 +673,7 @@ alexa_stoppedAlexaFHEM($)
if( $hash->{undefine} ) { if( $hash->{undefine} ) {
delete $hash->{undefine}; delete $hash->{undefine};
CommandDelete(undef, $name); CommandDelete(undef, $name);
Log3 $name, 3, "$name: alexaFHEM deleted"; Log3 $name, 2, "$name: alexaFHEM deleted";
} elsif( $hash->{start} ) { } elsif( $hash->{start} ) {
alexa_startAlexaFHEM($hash) alexa_startAlexaFHEM($hash)
@ -886,7 +888,6 @@ alexa_Get($$@)
} }
} }
} }
Log 1, Dumper \%types;
my $verbsOfIntent = {}; my $verbsOfIntent = {};
my $intentsOfVerb = {}; my $intentsOfVerb = {};
@ -1258,16 +1259,16 @@ alexa_Attr($$$)
my $hash = $defs{$name}; my $hash = $defs{$name};
if( $cmd eq "set" && $attrVal ne "0" ) { if( $cmd eq "set" && $attrVal ne "0" ) {
$attrVal = 1; $attrVal = 1;
alexa_stopAlexaFHEM($hash); alexa_stopAlexaFHEM($hash) if( $init_done );
} else { } else {
$attr{$name}{$attrName} = 0; $attr{$name}{$attrName} = 0;
alexa_startAlexaFHEM($hash); alexa_startAlexaFHEM($hash) if( $init_done );
} }
} elsif( $attrName eq 'disabledForIntervals' ) { } elsif( $attrName eq 'disabledForIntervals' ) {
alexa_startAlexaFHEM($hash); alexa_startAlexaFHEM($hash) if( $init_done );
} elsif( $attrName eq 'skillId' ) { } elsif( $attrName eq 'skillId' ) {
if( $cmd eq "set" && $attrVal ) { if( $cmd eq "set" && $attrVal ) {
@ -1296,7 +1297,7 @@ alexa_Attr($$$)
$attr{$name}{$attrName} = $attrVal; $attr{$name}{$attrName} = $attrVal;
alexa_startAlexaFHEM($hash); alexa_startAlexaFHEM($hash) if( $init_done );
} elsif( $attrName eq 'alexaFHEM-auth' ) { } elsif( $attrName eq 'alexaFHEM-auth' ) {
if( $cmd eq "set" && $attrVal ) { if( $cmd eq "set" && $attrVal ) {
@ -1304,7 +1305,7 @@ alexa_Attr($$$)
} }
$attr{$name}{$attrName} = $attrVal; $attr{$name}{$attrName} = $attrVal;
alexa_startAlexaFHEM($hash); alexa_startAlexaFHEM($hash) if( $init_done );
if( $cmd eq "set" && $orig ne $attrVal ) { if( $cmd eq "set" && $orig ne $attrVal ) {
$attr{$name}{$attrName} = $attrVal; $attr{$name}{$attrName} = $attrVal;
@ -1314,12 +1315,12 @@ alexa_Attr($$$)
} elsif( $attrName eq 'alexaFHEM-host' ) { } elsif( $attrName eq 'alexaFHEM-host' ) {
$attr{$name}{$attrName} = $attrVal; $attr{$name}{$attrName} = $attrVal;
alexa_startAlexaFHEM($hash); alexa_startAlexaFHEM($hash) if( $init_done );
} elsif( $attrName eq 'alexaFHEM-sshUser' ) { } elsif( $attrName eq 'alexaFHEM-sshUser' ) {
$attr{$name}{$attrName} = $attrVal; $attr{$name}{$attrName} = $attrVal;
alexa_startAlexaFHEM($hash); alexa_startAlexaFHEM($hash) if( $init_done );
} }