From bd0a9e57a41c84c1055b72136d708540317d87d4 Mon Sep 17 00:00:00 2001
From: markusbloch <>
Date: Wed, 28 May 2014 22:01:44 +0000
Subject: [PATCH] YAMAHA_AVR: execute all HTTP requests now non-blocking
git-svn-id: https://svn.fhem.de/fhem/trunk@5996 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 2 +
fhem/FHEM/71_YAMAHA_AVR.pm | 1550 ++++++++++++++++++------------------
2 files changed, 761 insertions(+), 791 deletions(-)
diff --git a/fhem/CHANGED b/fhem/CHANGED
index 68b98d419..ae7ffdee9 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
+ - bugfix: YAMAHA_AVR: don't let FHEM hang anymore, when the receiver
+ is not reachable
- change: 55_GDS.pm: use Blocking.pm for retrieval of large files
- change: YAMAHA_BD: make YAMAHA_BD more performant by using non-blocking
HTTP request (from HttpUtils.pm)
diff --git a/fhem/FHEM/71_YAMAHA_AVR.pm b/fhem/FHEM/71_YAMAHA_AVR.pm
index bf88ccdd2..daec0d92c 100755
--- a/fhem/FHEM/71_YAMAHA_AVR.pm
+++ b/fhem/FHEM/71_YAMAHA_AVR.pm
@@ -78,21 +78,15 @@ YAMAHA_AVR_GetStatus($;$)
# get the model informations and available zones if no informations are available
if(not defined($hash->{ACTIVE_ZONE}) or not defined($hash->{helper}{ZONES}) or not defined($hash->{MODEL}) or not defined($hash->{FIRMWARE}) or not defined($hash->{helper}{DSP_MODES}))
{
- unless(defined(YAMAHA_AVR_getModel($hash)))
- {
- YAMAHA_AVR_ResetTimer($hash) unless($local == 1);
- return;
- }
+ YAMAHA_AVR_getModel($hash);
+ YAMAHA_AVR_ResetTimer($hash) unless($local == 1);
+ return;
}
- # get all available inputs if nothing is available
- if(not defined($hash->{helper}{INPUTS}) or length($hash->{helper}{INPUTS}) == 0)
+ # get all available inputs and scenes if nothing is available
+ if((not defined($hash->{helper}{INPUTS}) or length($hash->{helper}{INPUTS}) == 0) or (not defined($hash->{helper}{SCENES}) or length($hash->{helper}{SCENES}) == 0))
{
- unless(defined(YAMAHA_AVR_getInputs($hash)))
- {
- YAMAHA_AVR_ResetTimer($hash) unless($local == 1);
- return;
- }
+ YAMAHA_AVR_getInputs($hash);
}
my $zone = YAMAHA_AVR_getParamName($hash, $hash->{ACTIVE_ZONE}, $hash->{helper}{ZONES});
@@ -103,220 +97,9 @@ YAMAHA_AVR_GetStatus($;$)
return "No Zone available";
}
- my $return = YAMAHA_AVR_SendCommand($hash, "<$zone>GetParam$zone>");
-
- #Log3 $name, 4, "YAMAHA_AVR: GetStatus-Request returned: $return" if(defined($return));
-
- if(not defined($return) or $return eq "")
- {
- YAMAHA_AVR_ResetTimer($hash) unless($local == 1);
- return;
- }
-
- readingsBeginUpdate($hash);
-
- if($return =~ /(.+)<\/Power>/)
- {
- $power = $1;
-
- if($power eq "Standby")
- {
- $power = "off";
- }
- readingsBulkUpdate($hash, "power", lc($power));
- readingsBulkUpdate($hash, "state", lc($power));
- }
-
- # current volume and mute status
- if($return =~ /(.+)<\/Val>(.+)<\/Exp>.+<\/Unit><\/Lvl>(.+)<\/Mute>.*<\/Volume>/)
- {
- readingsBulkUpdate($hash, "volumeStraight", ($1 / 10 ** $2));
- readingsBulkUpdate($hash, "volume", YAMAHA_AVR_volume_abs2rel(($1 / 10 ** $2)));
- readingsBulkUpdate($hash, "mute", lc($3));
-
- $hash->{helper}{USE_SHORT_VOL_CMD} = "0";
- }
- elsif($return =~ /(.+)<\/Val>(.+)<\/Exp>.+<\/Unit><\/Lvl>(.+)<\/Mute>.*<\/Vol>/)
- {
- readingsBulkUpdate($hash, "volumeStraight", ($1 / 10 ** $2));
- readingsBulkUpdate($hash, "volume", YAMAHA_AVR_volume_abs2rel(($1 / 10 ** $2)));
- readingsBulkUpdate($hash, "mute", lc($3));
-
- $hash->{helper}{USE_SHORT_VOL_CMD} = "1";
- }
-
-
- # (only available in zones other than mainzone) absolute or relative volume change to the mainzone
- if($return =~ /.*?