Aussetzen des get http Requests bei absetzen eines set http request

This commit is contained in:
Marko Oldenburg 2015-07-29 13:31:43 +02:00
parent 960e71edb6
commit 32b6d81661

View File

@ -128,12 +128,11 @@ sub AMAD_GetUpdateTimer($)
sub AMAD_Set($$@) sub AMAD_Set($$@)
{ {
my ($hash, $name, $cmd, @val) = @_; my ($hash, $name, $cmd, @val) = @_;
my $resultStr = "";
my $list = "screenMsg" my $list = "screenMsg"
. " ttsMsg" . " ttsMsg"
. " setVolume" . " setVolume"
. " MediaPlayer:play,stop,next,back"; . " mediaPlayer:play,stop,next,back";
# set screenMsg # set screenMsg
if ( lc $cmd eq 'screenmsg') { if ( lc $cmd eq 'screenmsg') {
@ -150,7 +149,7 @@ sub AMAD_Set($$@)
Log3 $name, 3, "AMAD ($name) - set $name $cmd ".join(" ", @val); Log3 $name, 3, "AMAD ($name) - set $name $cmd ".join(" ", @val);
return AMAD_SetVolume ($hash, @val); return AMAD_SetVolume ($hash, @val);
} }
# set mediaplayer # set mediaPlayer
elsif ( lc $cmd eq 'mediaplayer') { elsif ( lc $cmd eq 'mediaplayer') {
Log3 $name, 3, "AMAD ($name) - set $name $cmd ".join(" ", @val); Log3 $name, 3, "AMAD ($name) - set $name $cmd ".join(" ", @val);
return AMAD_mediaplayer ($hash, @val); return AMAD_mediaplayer ($hash, @val);
@ -166,7 +165,7 @@ sub AMAD_RetrieveAutomagicInfo
my $host = $hash->{HOST}; my $host = $hash->{HOST};
my $port = $hash->{PORT}; my $port = $hash->{PORT};
my $url = "http://" . $host . ":" . $port . "/automagic/test"; my $url = "http://" . $host . ":" . $port . "/automagic/deviceInfo";
if ($blocking) { if ($blocking) {
my $response = HttpUtils_BlockingGet( my $response = HttpUtils_BlockingGet(
@ -219,7 +218,7 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$)
return; return;
} }
$hash->{RETRIEVECACHE} = $data; # $hash->{RETRIEVECACHE} = $data; # zu Testzwecken
my @valuestring = split('@@', $data); my @valuestring = split('@@', $data);
my %buffer; my %buffer;
@ -235,45 +234,58 @@ sub AMAD_RetrieveAutomagicInfoFinished($$$)
readingsBulkUpdate($hash, $t, $v) if (defined($v)); readingsBulkUpdate($hash, $t, $v) if (defined($v));
} }
readingsEndUpdate($hash, 1); readingsEndUpdate($hash, 1);
return undef;
}
sub AMAD_HTTP_Request {
my ($hash, $url) = @_;
my $name = $hash->{NAME};
my $state = $hash->{STATE};
$hash->{STATE} = "Send http Request";
HttpUtils_BlockingGet(
{
url => $url,
timeout => 5,
#noshutdown => 0,
}
);
Log3 $name, 3, "AMAD ($name) - Send http Request with URL $url";
$hash->{STATE} = $state;
return undef;
} }
sub AMAD_SetScreenMsg($@) sub AMAD_SetScreenMsg($@)
{ {
my ($hash, @msg) = @_; my ($hash, @data) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $host = $hash->{HOST}; my $host = $hash->{HOST};
my $port = $hash->{PORT}; my $port = $hash->{PORT};
my $url = "http://" . $host . ":" . $port . "/automagic/screenMsg?message=@msg";
my $response = HttpUtils_BlockingGet( my $msg = join(" ", @data);
{ $msg =~ s/\s/%20/g;
url => $url,
timeout => 5,
#noshutdown => 0,
}
);
Log3 $name, 3, "AMAD ($name) - Send http Request Screen Message @msg with URL $url";
return undef; my $url = "http://" . $host . ":" . $port . "/automagic/screenMsg?message=$msg";
return AMAD_HTTP_Request ($hash,$url);
} }
sub AMAD_SetTtsMsg($@) { sub AMAD_SetTtsMsg($@) {
my ($hash, @msg) = @_; my ($hash, @data) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $host = $hash->{HOST}; my $host = $hash->{HOST};
my $port = $hash->{PORT}; my $port = $hash->{PORT};
my $url = "http://" . $host . ":" . $port . "/automagic/ttsMsg?message=@msg";
my $response = HttpUtils_BlockingGet( my $msg = join(" ", @data);
{ $msg =~ s/\s/%20/g;
url => $url,
timeout => 5,
#noshutdown => 0,
}
);
Log3 $name, 3, "AMAD ($name) - Send http Request TTS Message @msg with URL $url";
return undef; my $url = "http://" . $host . ":" . $port . "/automagic/ttsMsg?message=$msg";
return AMAD_HTTP_Request ($hash,$url);
} }
sub AMAD_SetVolume($@) { sub AMAD_SetVolume($@) {