2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-15 03:59:11 +00:00

39_alexa.pm: listen to *** status messages from alexa-fhem

git-svn-id: https://svn.fhem.de/fhem/trunk@18248 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2019-01-14 08:41:43 +00:00
parent f14564a19d
commit 6211ea93f1

View File

@ -283,6 +283,21 @@ alexa_Read($)
Log3 $name, 3, "$name: $buf";
}
if( $buf =~ m/^\*\*\* ([^\s]+) (.+)/ ) {
my $service = $1;
my $message = $2;
if( $service eq 'FHEM:' ) {
if( $message =~ m/^connection failed(: (.*))?/ ) {
my $code = $2;
$hash->{reason} = 'failed to connect to fhem';
$hash->{reason} .= ": $code" if( $code );
alexa_stopAlexaFHEM($hash);
}
}
}
return undef;
}
@ -470,6 +485,8 @@ alexa_startAlexaFHEM($)
my ($hash) = @_;
my $name = $hash->{NAME};
return undef if( !$init_done );
my $key = ReadingsVal($name, 'alexaFHEM.skillRegKey', undef);
if( !$key ) {
my $key = getKeyValue('alexaFHEM.skillRegKey');
@ -668,7 +685,13 @@ alexa_stoppedAlexaFHEM($)
Log3 $name, 3, "$name: alexaFHEM stopped";
$hash->{LAST_STOP} = FmtDateTime( gettimeofday() );
readingsSingleUpdate($hash, 'alexaFHEM', 'stopped', 1 );
if( $hash->{reason} ) {
readingsSingleUpdate($hash, 'alexaFHEM', "stopped: $hash->{reason}", 1 );
delete $hash->{reason};
} else {
readingsSingleUpdate($hash, 'alexaFHEM', 'stopped', 1 );
}
if( $hash->{undefine} ) {
delete $hash->{undefine};