mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-03 16:56:54 +00:00
39_alexa.pm: added fallback to first defined web device if WEB ist not defined
git-svn-id: https://svn.fhem.de/fhem/trunk@18257 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
cf45b9318c
commit
1017e7b35b
@ -169,6 +169,7 @@ alexa_Undefine($$)
|
||||
|
||||
if( $hash->{PID} ) {
|
||||
$hash->{undefine} = 1;
|
||||
#$hash->{undefine} = $hash->{CL};
|
||||
alexa_stopAlexaFHEM($hash);
|
||||
|
||||
return "$name will be deleted after alexa-fhem has stopped or after 5 seconds. whatever comes first.";
|
||||
@ -467,9 +468,22 @@ alexa_configDefault($;$)
|
||||
$conf->{connections}[0]->{filter} = 'alexaName=..*' if( !$conf->{connections}[0]->{filter} );
|
||||
$conf->{connections}[0]->{uid} = $< if( $conf->{sshproxy} );
|
||||
|
||||
if( my $web = $defs{WEB} ) {
|
||||
$conf->{connections}[0]->{port} = $web->{PORT};
|
||||
$conf->{connections}[0]->{webname} = AttrVal( 'WEB', 'webname', 'fhem' );
|
||||
my $web = $defs{WEB};
|
||||
if( !$web ) {
|
||||
if( my @names = devspec2array('TYPE=FHEMWEB:FILTER=TEMPORARY!=1') ) {
|
||||
$web = $defs{$names[0]} if( defined($defs{$names[0]}) );
|
||||
|
||||
Log3 $name, 4, "$name: using $names[0] as FHEMWEB device." if( $web );
|
||||
}
|
||||
} else {
|
||||
Log3 $name, 4, "$name: using WEB as FHEMWEB device." if( $web );
|
||||
}
|
||||
|
||||
if( $web ) {
|
||||
$conf->{connections}[0]->{port} = $web->{PORT} if( !$conf->{connections}[0]->{port} );
|
||||
$conf->{connections}[0]->{webname} = AttrVal( 'WEB', 'webname', 'fhem' ) if( !$conf->{connections}[0]->{webname} );
|
||||
} else {
|
||||
Log3 $name, 2, "$name: no FHEMWEB device found. please adjust config file manualy.";
|
||||
}
|
||||
|
||||
$json = JSON->new->pretty->utf8->encode($conf);
|
||||
@ -709,10 +723,16 @@ alexa_stoppedAlexaFHEM($)
|
||||
}
|
||||
|
||||
if( $hash->{undefine} ) {
|
||||
my $cl = $hash->{undefine};
|
||||
|
||||
delete $hash->{undefine};
|
||||
CommandDelete(undef, $name);
|
||||
Log3 $name, 2, "$name: alexaFHEM deleted";
|
||||
|
||||
if( ref($cl) eq 'HASH' && $cl->{canAsyncOutput} ) {
|
||||
asyncOutput( $cl, "$name: alexaFHEM deleted\n" );
|
||||
}
|
||||
|
||||
} elsif( $hash->{shutdown} ) {
|
||||
delete $hash->{shutdown};
|
||||
CancelDelayedShutdown($name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user